forked from MyPureCloud/platform-client-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
knowledgedocumentversion.go
144 lines (100 loc) · 3.99 KB
/
knowledgedocumentversion.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package platformclientv2
import (
"time"
"github.com/leekchan/timeutil"
"encoding/json"
"strconv"
"strings"
)
// Knowledgedocumentversion
type Knowledgedocumentversion struct {
// Id - Globally unique identifier for the document version.
Id *string `json:"id"`
// DatePublished - Published date of document version. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
DatePublished *time.Time `json:"datePublished"`
// Document - The document which is versioned.
Document *Knowledgedocumentresponse `json:"document"`
// RestoreFromVersionId - The globally unique identifier for the document version. If the value is provided, the document is restored to the given version. If not, it publishes the draft changes as a new version of the document.
RestoreFromVersionId *string `json:"restoreFromVersionId,omitempty"`
// VersionNumber - Version Number of the document.
VersionNumber *int `json:"versionNumber"`
// DateExpires - Expiry date of document version, applicable only to the 'Archived' version of the document. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
DateExpires *time.Time `json:"dateExpires"`
// SelfUri - The URI for this object
SelfUri *string `json:"selfUri"`
}
func (o *Knowledgedocumentversion) MarshalJSON() ([]byte, error) {
// Redundant initialization to avoid unused import errors for models with no Time values
_ = timeutil.Timedelta{}
type Alias Knowledgedocumentversion
DatePublished := new(string)
if o.DatePublished != nil {
*DatePublished = timeutil.Strftime(o.DatePublished, "%Y-%m-%dT%H:%M:%S.%fZ")
} else {
DatePublished = nil
}
DateExpires := new(string)
if o.DateExpires != nil {
*DateExpires = timeutil.Strftime(o.DateExpires, "%Y-%m-%dT%H:%M:%S.%fZ")
} else {
DateExpires = nil
}
return json.Marshal(&struct {
Id *string `json:"id"`
DatePublished *string `json:"datePublished"`
Document *Knowledgedocumentresponse `json:"document"`
RestoreFromVersionId *string `json:"restoreFromVersionId,omitempty"`
VersionNumber *int `json:"versionNumber"`
DateExpires *string `json:"dateExpires"`
SelfUri *string `json:"selfUri"`
*Alias
}{
Id: o.Id,
DatePublished: DatePublished,
Document: o.Document,
RestoreFromVersionId: o.RestoreFromVersionId,
VersionNumber: o.VersionNumber,
DateExpires: DateExpires,
SelfUri: o.SelfUri,
Alias: (*Alias)(o),
})
}
func (o *Knowledgedocumentversion) UnmarshalJSON(b []byte) error {
var KnowledgedocumentversionMap map[string]interface{}
err := json.Unmarshal(b, &KnowledgedocumentversionMap)
if err != nil {
return err
}
if Id, ok := KnowledgedocumentversionMap["id"].(string); ok {
o.Id = &Id
}
if datePublishedString, ok := KnowledgedocumentversionMap["datePublished"].(string); ok {
DatePublished, _ := time.Parse("2006-01-02T15:04:05.999999Z", datePublishedString)
o.DatePublished = &DatePublished
}
if Document, ok := KnowledgedocumentversionMap["document"].(map[string]interface{}); ok {
DocumentString, _ := json.Marshal(Document)
json.Unmarshal(DocumentString, &o.Document)
}
if RestoreFromVersionId, ok := KnowledgedocumentversionMap["restoreFromVersionId"].(string); ok {
o.RestoreFromVersionId = &RestoreFromVersionId
}
if VersionNumber, ok := KnowledgedocumentversionMap["versionNumber"].(float64); ok {
VersionNumberInt := int(VersionNumber)
o.VersionNumber = &VersionNumberInt
}
if dateExpiresString, ok := KnowledgedocumentversionMap["dateExpires"].(string); ok {
DateExpires, _ := time.Parse("2006-01-02T15:04:05.999999Z", dateExpiresString)
o.DateExpires = &DateExpires
}
if SelfUri, ok := KnowledgedocumentversionMap["selfUri"].(string); ok {
o.SelfUri = &SelfUri
}
return nil
}
// String returns a JSON representation of the model
func (o *Knowledgedocumentversion) String() string {
j, _ := json.Marshal(o)
str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\u`, `\u`, -1))
return str
}