62 lines
971 B
Go
62 lines
971 B
Go
package ext
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"ticket-pimp/bot/domain"
|
|
"time"
|
|
)
|
|
|
|
type Coda struct {
|
|
*Client
|
|
}
|
|
|
|
type ICoda interface {
|
|
ListDocs()
|
|
CreateTask(task domain.CodaIssue)
|
|
}
|
|
|
|
func NewCodaClient() *Coda {
|
|
|
|
client := NewClient().
|
|
SetTimeout(5 * time.Second).
|
|
SetCommonBearerAuthToken("0d5a6853-8bb1-4208-9014-318094f5b21c").
|
|
SetBaseURL("https://coda.io/apis/v1")
|
|
|
|
return &Coda{
|
|
Client: &Client{
|
|
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)
|
|
}
|