mirror of
https://github.com/retailcrm/mg-bot-api-client-go.git
synced 2025-04-07 07:03:31 +03:00
Метод dialogs/history
This commit is contained in:
parent
2b05530ce7
commit
4c79fef443
2 changed files with 57 additions and 0 deletions
40
v1/client.go
40
v1/client.go
|
@ -785,6 +785,46 @@ func (c *MgClient) UploadFileByURL(request UploadFileByUrlRequest) (UploadFileRe
|
|||
return resp, status, err
|
||||
}
|
||||
|
||||
// ResponsibleHistory get history of responsibles
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = v1.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// data, status, err := client.ResponsibleHistory(ResponsibleHistoryRequest{DialogID:1})
|
||||
//
|
||||
// if err != nil {
|
||||
// fmt.Printf("%v", err)
|
||||
// }
|
||||
//
|
||||
// if status >= http.StatusBadRequest {
|
||||
// fmt.Printf("%v", err)
|
||||
// }
|
||||
//
|
||||
// for _, historyItem := range data {
|
||||
// fmt.Printf("%v %v\n", historyItem.AssignedAt)
|
||||
// }
|
||||
func (c *MgClient) ResponsibleHistory(request ResponsibleHistoryRequest) ([]ResponsibleHistoryResponseItem, int, error) {
|
||||
var resp []ResponsibleHistoryResponseItem
|
||||
var b []byte
|
||||
outgoing, _ := query.Values(request)
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("/dialogs/history?%s", outgoing.Encode()), b)
|
||||
if err != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
if status > http.StatusCreated || status < http.StatusOK {
|
||||
return resp, status, c.Error(data)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &resp); err != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
// WsMeta let you receive url & headers to open web socket connection
|
||||
func (c *MgClient) WsMeta(events []string) (string, http.Header, error) {
|
||||
var url string
|
||||
|
|
17
v1/types.go
17
v1/types.go
|
@ -210,6 +210,12 @@ type (
|
|||
UploadFileByUrlRequest struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
ResponsibleHistoryRequest struct {
|
||||
ChatID uint64 `url:"chat_id,omitempty" json:"chat_id"`
|
||||
DialogID uint64 `url:"dialog_id,omitempty" json:"dialog_id"`
|
||||
Limit int `url:"int,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
// Response types
|
||||
|
@ -353,6 +359,17 @@ type (
|
|||
Url *string `json:"source_url"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
ResponsibleHistoryResponseItem struct {
|
||||
ID uint64 `json:"id"`
|
||||
DialogID uint64 `json:"dialog_id"`
|
||||
Responsible UserRef `json:"responsible"`
|
||||
AssignedBy *UserRef `json:"assigned_by"`
|
||||
UnassignedBy *UserRef `json:"unassigned_by"`
|
||||
UnassignReason string `json:"unassign_reason"`
|
||||
UnassignedAt *string `json:"unassigned_at"`
|
||||
AssignedAt string `json:"assigned_at"`
|
||||
}
|
||||
)
|
||||
|
||||
// WS event types
|
||||
|
|
Loading…
Add table
Reference in a new issue