61 lines
977 B
Go
61 lines
977 B
Go
package services
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"ticket-pimp/internal/domain"
|
|
"time"
|
|
)
|
|
|
|
type Coda struct {
|
|
*CommonClient
|
|
}
|
|
|
|
type ICoda interface {
|
|
ListDocs()
|
|
CreateTask(task domain.CodaIssue)
|
|
}
|
|
|
|
func NewCodaClient(token string) *Coda {
|
|
|
|
client := NewClient().
|
|
SetTimeout(5 * time.Second).
|
|
SetCommonBearerAuthToken(token).
|
|
SetBaseURL("https://coda.io/apis/v1")
|
|
|
|
return &Coda{
|
|
CommonClient: &CommonClient{
|
|
client,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (c *Coda) ListDocs() {
|
|
|
|
const tableID = "grid-obBN3tWdeh"
|
|
const docID = "Ic3IZpQ3Wk"
|
|
|
|
//var i []RespObj
|
|
|
|
resp, _ := c.R().
|
|
SetQueryParam("tableTypes", "table").
|
|
//SetSuccessResult(&i).
|
|
Get("/docs/" + docID + "/tables/" + tableID + "/rows")
|
|
|
|
if resp.Err != nil {
|
|
log.Print(resp.Err)
|
|
return
|
|
}
|
|
|
|
log.Print(resp)
|
|
}
|
|
|
|
func (c *Coda) CreateTask(task domain.CodaIssue) {
|
|
resp, _ := c.R().
|
|
SetBody(task).
|
|
SetContentType("application/json").
|
|
Post("/docs/Ic3IZpQ3Wk/hooks/automation/grid-auto-NlUwM7F7Cr")
|
|
|
|
fmt.Print(resp)
|
|
}
|