mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-24 13:56:04 +03:00
add mgTransport
callbacks
This commit is contained in:
commit
c9e5b1f79d
30
system_time.go
Normal file
30
system_time.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package retailcrm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SystemTime time.Time
|
||||||
|
|
||||||
|
const systemTimeLayout = "2006-01-02 15:04:05"
|
||||||
|
|
||||||
|
// UnmarshalJSON parses time.Time from system format.
|
||||||
|
func (st *SystemTime) UnmarshalJSON(b []byte) (err error) {
|
||||||
|
s := strings.Trim(string(b), `"`)
|
||||||
|
nt, err := time.Parse(systemTimeLayout, s)
|
||||||
|
*st = SystemTime(nt)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON will marshal time.Time to system format.
|
||||||
|
func (st SystemTime) MarshalJSON() ([]byte, error) {
|
||||||
|
return []byte(st.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns the time in the custom format
|
||||||
|
func (st *SystemTime) String() string {
|
||||||
|
t := time.Time(*st)
|
||||||
|
return fmt.Sprintf("%q", t.Format(systemTimeLayout))
|
||||||
|
}
|
49
types.go
49
types.go
@ -1254,8 +1254,14 @@ type Action struct {
|
|||||||
|
|
||||||
// MgTransport type.
|
// MgTransport type.
|
||||||
type MgTransport struct {
|
type MgTransport struct {
|
||||||
WebhookURL string `json:"webhookUrl,omitempty"`
|
WebhookURL string `json:"webhookUrl,omitempty"`
|
||||||
RefreshToken bool `json:"refreshToken,omitempty"`
|
RefreshToken bool `json:"refreshToken,omitempty"`
|
||||||
|
Actions *MgTransportActions `json:"actions,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MgTransportActions struct {
|
||||||
|
Visits string `json:"visits,omitempty"`
|
||||||
|
Online string `json:"online,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MgBot type.
|
// MgBot type.
|
||||||
@ -1355,6 +1361,45 @@ type Activity struct {
|
|||||||
Freeze bool `json:"freeze"`
|
Freeze bool `json:"freeze"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChatCustomerOnline struct {
|
||||||
|
LastOnline SystemTime `json:"lastOnline"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatVisitsResponse struct {
|
||||||
|
UTM *ChatUTM `json:"utm,omitempty"`
|
||||||
|
Device ChatDevice `json:"device"`
|
||||||
|
Country string `json:"country"`
|
||||||
|
City string `json:"city"`
|
||||||
|
LastVisit ChatLastVisit `json:"lastVisit"`
|
||||||
|
CountVisits uint `json:"countVisits"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatLastVisit struct {
|
||||||
|
CreatedAt SystemTime `json:"createdAt"`
|
||||||
|
EndedAt *SystemTime `json:"endedAt,omitempty"`
|
||||||
|
Source string `json:"source"`
|
||||||
|
Pages []ChatVisitedPage `json:"pages"`
|
||||||
|
Duration uint `json:"duration"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatVisitedPage struct {
|
||||||
|
DateTime SystemTime `json:"dateTime"`
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatDevice struct {
|
||||||
|
Lang string `json:"lang"`
|
||||||
|
Browser string `json:"browser"`
|
||||||
|
OS string `json:"os"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatUTM struct {
|
||||||
|
Source string `json:"source"`
|
||||||
|
Medium string `json:"medium"`
|
||||||
|
Campaign string `json:"campaign"`
|
||||||
|
}
|
||||||
|
|
||||||
// Tag struct.
|
// Tag struct.
|
||||||
type Tag struct {
|
type Tag struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
Loading…
Reference in New Issue
Block a user