-
Notifications
You must be signed in to change notification settings - Fork 1
/
portal_management_link.go
118 lines (111 loc) · 4.52 KB
/
portal_management_link.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
package models
import (
"encoding/json"
"log"
"time"
)
// PortalManagementLink represents a PortalManagementLink struct.
type PortalManagementLink struct {
Url *string `json:"url,omitempty"`
FetchCount *int `json:"fetch_count,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
NewLinkAvailableAt *time.Time `json:"new_link_available_at,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
LastInviteSentAt Optional[time.Time] `json:"last_invite_sent_at"`
AdditionalProperties map[string]any `json:"_"`
}
// MarshalJSON implements the json.Marshaler interface for PortalManagementLink.
// It customizes the JSON marshaling process for PortalManagementLink objects.
func (p PortalManagementLink) MarshalJSON() (
[]byte,
error) {
return json.Marshal(p.toMap())
}
// toMap converts the PortalManagementLink object to a map representation for JSON marshaling.
func (p PortalManagementLink) toMap() map[string]any {
structMap := make(map[string]any)
MapAdditionalProperties(structMap, p.AdditionalProperties)
if p.Url != nil {
structMap["url"] = p.Url
}
if p.FetchCount != nil {
structMap["fetch_count"] = p.FetchCount
}
if p.CreatedAt != nil {
structMap["created_at"] = p.CreatedAt.Format(time.RFC3339)
}
if p.NewLinkAvailableAt != nil {
structMap["new_link_available_at"] = p.NewLinkAvailableAt.Format(time.RFC3339)
}
if p.ExpiresAt != nil {
structMap["expires_at"] = p.ExpiresAt.Format(time.RFC3339)
}
if p.LastInviteSentAt.IsValueSet() {
var LastInviteSentAtVal *string = nil
if p.LastInviteSentAt.Value() != nil {
val := p.LastInviteSentAt.Value().Format(time.RFC3339)
LastInviteSentAtVal = &val
}
if p.LastInviteSentAt.Value() != nil {
structMap["last_invite_sent_at"] = LastInviteSentAtVal
} else {
structMap["last_invite_sent_at"] = nil
}
}
return structMap
}
// UnmarshalJSON implements the json.Unmarshaler interface for PortalManagementLink.
// It customizes the JSON unmarshaling process for PortalManagementLink objects.
func (p *PortalManagementLink) UnmarshalJSON(input []byte) error {
var temp portalManagementLink
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "url", "fetch_count", "created_at", "new_link_available_at", "expires_at", "last_invite_sent_at")
if err != nil {
return err
}
p.AdditionalProperties = additionalProperties
p.Url = temp.Url
p.FetchCount = temp.FetchCount
if temp.CreatedAt != nil {
CreatedAtVal, err := time.Parse(time.RFC3339, *temp.CreatedAt)
if err != nil {
log.Fatalf("Cannot Parse created_at as % s format.", time.RFC3339)
}
p.CreatedAt = &CreatedAtVal
}
if temp.NewLinkAvailableAt != nil {
NewLinkAvailableAtVal, err := time.Parse(time.RFC3339, *temp.NewLinkAvailableAt)
if err != nil {
log.Fatalf("Cannot Parse new_link_available_at as % s format.", time.RFC3339)
}
p.NewLinkAvailableAt = &NewLinkAvailableAtVal
}
if temp.ExpiresAt != nil {
ExpiresAtVal, err := time.Parse(time.RFC3339, *temp.ExpiresAt)
if err != nil {
log.Fatalf("Cannot Parse expires_at as % s format.", time.RFC3339)
}
p.ExpiresAt = &ExpiresAtVal
}
p.LastInviteSentAt.ShouldSetValue(temp.LastInviteSentAt.IsValueSet())
if temp.LastInviteSentAt.Value() != nil {
LastInviteSentAtVal, err := time.Parse(time.RFC3339, (*temp.LastInviteSentAt.Value()))
if err != nil {
log.Fatalf("Cannot Parse last_invite_sent_at as % s format.", time.RFC3339)
}
p.LastInviteSentAt.SetValue(&LastInviteSentAtVal)
}
return nil
}
// portalManagementLink is a temporary struct used for validating the fields of PortalManagementLink.
type portalManagementLink struct {
Url *string `json:"url,omitempty"`
FetchCount *int `json:"fetch_count,omitempty"`
CreatedAt *string `json:"created_at,omitempty"`
NewLinkAvailableAt *string `json:"new_link_available_at,omitempty"`
ExpiresAt *string `json:"expires_at,omitempty"`
LastInviteSentAt Optional[string] `json:"last_invite_sent_at"`
}