callbacks structs

This commit is contained in:
Pavel 2023-12-21 10:53:18 +03:00
parent b5e7c3ff33
commit 81a09e24d4
2 changed files with 67 additions and 0 deletions

30
system_time.go Normal file
View 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))
}

View File

@ -1358,6 +1358,43 @@ type Activity struct {
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.
type Tag struct {
Name string `json:"name,omitempty"`