-
Notifications
You must be signed in to change notification settings - Fork 13
/
voicemailcopyrecord.go
87 lines (65 loc) · 2.05 KB
/
voicemailcopyrecord.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package platformclientv2
import (
"time"
"github.com/leekchan/timeutil"
"encoding/json"
"strconv"
"strings"
)
// Voicemailcopyrecord
type Voicemailcopyrecord struct {
// User - The user that the voicemail message was copied to/from
User *User `json:"user,omitempty"`
// Group - The group that the voicemail message was copied to/from
Group *Group `json:"group,omitempty"`
// Date - The date when the voicemail was copied. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
Date *time.Time `json:"date,omitempty"`
}
func (o *Voicemailcopyrecord) MarshalJSON() ([]byte, error) {
// Redundant initialization to avoid unused import errors for models with no Time values
_ = timeutil.Timedelta{}
type Alias Voicemailcopyrecord
Date := new(string)
if o.Date != nil {
*Date = timeutil.Strftime(o.Date, "%Y-%m-%dT%H:%M:%S.%fZ")
} else {
Date = nil
}
return json.Marshal(&struct {
User *User `json:"user,omitempty"`
Group *Group `json:"group,omitempty"`
Date *string `json:"date,omitempty"`
*Alias
}{
User: o.User,
Group: o.Group,
Date: Date,
Alias: (*Alias)(o),
})
}
func (o *Voicemailcopyrecord) UnmarshalJSON(b []byte) error {
var VoicemailcopyrecordMap map[string]interface{}
err := json.Unmarshal(b, &VoicemailcopyrecordMap)
if err != nil {
return err
}
if User, ok := VoicemailcopyrecordMap["user"].(map[string]interface{}); ok {
UserString, _ := json.Marshal(User)
json.Unmarshal(UserString, &o.User)
}
if Group, ok := VoicemailcopyrecordMap["group"].(map[string]interface{}); ok {
GroupString, _ := json.Marshal(Group)
json.Unmarshal(GroupString, &o.Group)
}
if dateString, ok := VoicemailcopyrecordMap["date"].(string); ok {
Date, _ := time.Parse("2006-01-02T15:04:05.999999Z", dateString)
o.Date = &Date
}
return nil
}
// String returns a JSON representation of the model
func (o *Voicemailcopyrecord) String() string {
j, _ := json.Marshal(o)
str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\u`, `\u`, -1))
return str
}