2018-06-20 21:59:12 +00:00
|
|
|
package connectwise
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Callback struct {
|
2018-06-22 20:14:21 +00:00
|
|
|
ID int
|
2018-06-20 21:59:12 +00:00
|
|
|
Description string
|
|
|
|
Url string
|
|
|
|
ObjectId int
|
|
|
|
Type string
|
|
|
|
Level string
|
|
|
|
MemberId int
|
|
|
|
InactiveFlag bool
|
|
|
|
}
|
|
|
|
|
2018-06-23 03:14:08 +00:00
|
|
|
func (cw *ConnectwiseSite) GetCallbacks() *[]Callback {
|
2018-06-22 20:14:21 +00:00
|
|
|
|
2018-06-23 03:14:08 +00:00
|
|
|
Url := cw.BuildUrl("/system/callbacks")
|
|
|
|
body := cw.GetRequest(Url)
|
2018-06-23 00:47:39 +00:00
|
|
|
|
|
|
|
callbacks := []Callback{}
|
2018-06-22 20:14:21 +00:00
|
|
|
check(json.Unmarshal(body, &callbacks))
|
|
|
|
|
|
|
|
return &callbacks
|
2018-06-20 21:59:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-23 00:47:39 +00:00
|
|
|
//TBD: This should return something?
|
2018-06-23 03:14:08 +00:00
|
|
|
func (cw *ConnectwiseSite) NewCallback(callback Callback) {
|
2018-06-20 21:59:12 +00:00
|
|
|
|
2018-06-23 03:14:08 +00:00
|
|
|
Url := cw.BuildUrl("/system/callbacks")
|
2018-06-20 21:59:12 +00:00
|
|
|
jsonCallback, err := json.Marshal(callback)
|
|
|
|
check(err)
|
|
|
|
|
|
|
|
jsonBuffer := bytes.NewReader(jsonCallback)
|
|
|
|
|
2018-06-23 03:14:08 +00:00
|
|
|
cw.PostRequest(Url, jsonBuffer)
|
2018-06-20 21:59:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-23 03:14:08 +00:00
|
|
|
func (cw *ConnectwiseSite) DeleteCallback(callback int) {
|
2018-06-20 21:59:12 +00:00
|
|
|
|
2018-06-23 03:14:08 +00:00
|
|
|
Url := cw.BuildUrl(fmt.Sprintf("/system/callbacks/%d", callback))
|
|
|
|
body := cw.DeleteRequest(Url)
|
2018-06-20 21:59:12 +00:00
|
|
|
fmt.Print(string(body))
|
|
|
|
|
|
|
|
}
|