-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebhooks.go
131 lines (114 loc) · 3.3 KB
/
webhooks.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
// This file was auto-generated by Fern from our API Definition.
package polytomic
import (
json "encoding/json"
fmt "fmt"
core "github.com/polytomic/polytomic-go/core"
time "time"
)
type CreateWebhooksSchema struct {
Endpoint string `json:"endpoint" url:"endpoint"`
OrganizationId *string `json:"organization_id,omitempty" url:"organization_id,omitempty"`
Secret string `json:"secret" url:"secret"`
}
type UpdateWebhooksSchema struct {
Endpoint string `json:"endpoint" url:"endpoint"`
OrganizationId *string `json:"organization_id,omitempty" url:"organization_id,omitempty"`
Secret string `json:"secret" url:"secret"`
}
type Webhook struct {
CreatedAt *time.Time `json:"created_at,omitempty" url:"created_at,omitempty"`
Endpoint *string `json:"endpoint,omitempty" url:"endpoint,omitempty"`
Id *string `json:"id,omitempty" url:"id,omitempty"`
OrganizationId *string `json:"organization_id,omitempty" url:"organization_id,omitempty"`
Secret *string `json:"secret,omitempty" url:"secret,omitempty"`
_rawJSON json.RawMessage
}
func (w *Webhook) UnmarshalJSON(data []byte) error {
type embed Webhook
var unmarshaler = struct {
embed
CreatedAt *core.DateTime `json:"created_at,omitempty"`
}{
embed: embed(*w),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*w = Webhook(unmarshaler.embed)
w.CreatedAt = unmarshaler.CreatedAt.TimePtr()
w._rawJSON = json.RawMessage(data)
return nil
}
func (w *Webhook) MarshalJSON() ([]byte, error) {
type embed Webhook
var marshaler = struct {
embed
CreatedAt *core.DateTime `json:"created_at,omitempty"`
}{
embed: embed(*w),
CreatedAt: core.NewOptionalDateTime(w.CreatedAt),
}
return json.Marshal(marshaler)
}
func (w *Webhook) String() string {
if len(w._rawJSON) > 0 {
if value, err := core.StringifyJSON(w._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(w); err == nil {
return value
}
return fmt.Sprintf("%#v", w)
}
type WebhookEnvelope struct {
Data *Webhook `json:"data,omitempty" url:"data,omitempty"`
_rawJSON json.RawMessage
}
func (w *WebhookEnvelope) UnmarshalJSON(data []byte) error {
type unmarshaler WebhookEnvelope
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*w = WebhookEnvelope(value)
w._rawJSON = json.RawMessage(data)
return nil
}
func (w *WebhookEnvelope) String() string {
if len(w._rawJSON) > 0 {
if value, err := core.StringifyJSON(w._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(w); err == nil {
return value
}
return fmt.Sprintf("%#v", w)
}
type WebhookListEnvelope struct {
Data []*Webhook `json:"data,omitempty" url:"data,omitempty"`
_rawJSON json.RawMessage
}
func (w *WebhookListEnvelope) UnmarshalJSON(data []byte) error {
type unmarshaler WebhookListEnvelope
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*w = WebhookListEnvelope(value)
w._rawJSON = json.RawMessage(data)
return nil
}
func (w *WebhookListEnvelope) String() string {
if len(w._rawJSON) > 0 {
if value, err := core.StringifyJSON(w._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(w); err == nil {
return value
}
return fmt.Sprintf("%#v", w)
}