mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-24 22:06:03 +03:00
callbacks structs
This commit is contained in:
parent
b5e7c3ff33
commit
81a09e24d4
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))
|
||||||
|
}
|
37
types.go
37
types.go
@ -1358,6 +1358,43 @@ type Activity struct {
|
|||||||
Freeze bool `json:"freeze"`
|
Freeze bool `json:"freeze"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChatCustomerOnline struct {
|
||||||
|
LastOnline SystemTime `json:"lastOnline"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatVisitsResponse struct {
|
||||||
|
LastVisit ChatLastVisit `json:"lastVisit"`
|
||||||
|
IP string `json:"ip"`
|
||||||
|
CountVisits uint `json:"countVisits"`
|
||||||
|
ChatDevice ChatDevice `json:"chatDevice"`
|
||||||
|
ChatUTM *ChatUTM `json:"chatUtm,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatLastVisit struct {
|
||||||
|
Source string `json:"source"`
|
||||||
|
Duration uint `json:"duration"`
|
||||||
|
CreatedAt SystemTime `json:"createdAt"`
|
||||||
|
EndedAt *SystemTime `json:"endedAt,omitempty"`
|
||||||
|
Pages []ChatVisitedPage `json:"pages"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatVisitedPage struct {
|
||||||
|
DateTime SystemTime `json:"dateTime"`
|
||||||
|
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