-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnotification_settings.go
174 lines (148 loc) · 8.86 KB
/
notification_settings.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Code generated by the Paddle SDK Generator; DO NOT EDIT.
package paddle
import "context"
// TrafficSource: Return entities that match the specified traffic source..
type TrafficSource string
const (
TrafficSourcePlatform TrafficSource = "platform"
TrafficSourceSimulation TrafficSource = "simulation"
TrafficSourceAll TrafficSource = "all"
)
// NotificationSettingType: Where notifications should be sent for this destination..
type NotificationSettingType string
const (
NotificationSettingTypeEmail NotificationSettingType = "email"
NotificationSettingTypeURL NotificationSettingType = "url"
)
// NotificationSetting: Represents a notification destination.
type NotificationSetting struct {
// ID: Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
ID string `json:"id,omitempty"`
// Description: Short description for this notification destination. Shown in the Paddle dashboard.
Description string `json:"description,omitempty"`
// Type: Where notifications should be sent for this destination.
Type NotificationSettingType `json:"type,omitempty"`
// Destination: Webhook endpoint URL or email address.
Destination string `json:"destination,omitempty"`
// Active: Whether Paddle should try to deliver events to this notification destination.
Active bool `json:"active,omitempty"`
// APIVersion: API version that returned objects for events should conform to. Must be a valid version of the Paddle API. Can't be a version older than your account default.
APIVersion int `json:"api_version,omitempty"`
// IncludeSensitiveFields: Whether potentially sensitive fields should be sent to this notification destination.
IncludeSensitiveFields bool `json:"include_sensitive_fields,omitempty"`
// SubscribedEvents: Represents an event type.
SubscribedEvents []EventType `json:"subscribed_events,omitempty"`
// EndpointSecretKey: Webhook destination secret key, prefixed with `pdl_ntfset_`. Used for signature verification.
EndpointSecretKey string `json:"endpoint_secret_key,omitempty"`
// TrafficSource: Whether Paddle should deliver real platform events, simulation events or both to this notification destination.
TrafficSource TrafficSource `json:"traffic_source,omitempty"`
}
// NotificationSettingsClient is a client for the Notification settings resource.
type NotificationSettingsClient struct {
doer Doer
}
// ListNotificationSettingsRequest is given as an input to ListNotificationSettings.
type ListNotificationSettingsRequest struct {
// After is a query parameter.
// Return entities after the specified Paddle ID when working with paginated endpoints. Used in the `meta.pagination.next` URL in responses for list operations.
After *string `in:"query=after;omitempty" json:"-"`
// PerPage is a query parameter.
/*
Set how many entities are returned per page. Paddle returns the maximum number of results if a number greater than the maximum is requested. Check `meta.pagination.per_page` in the response to see how many were returned.
Default: `200`; Maximum: `200`.
*/
PerPage *int `in:"query=per_page;omitempty" json:"-"`
// OrderBy is a query parameter.
/*
Order returned entities by the specified field and direction (`[ASC]` or `[DESC]`). For example, `?order_by=id[ASC]`.
Valid fields for ordering: `id`.
*/
OrderBy *string `in:"query=order_by;omitempty" json:"-"`
// Active is a query parameter.
// Determine whether returned entities are active (`true`) or not (`false`).
Active *bool `in:"query=active;omitempty" json:"-"`
// TrafficSource is a query parameter.
// Return entities that match the specified traffic source.
TrafficSource *string `in:"query=traffic_source;omitempty" json:"-"`
}
// ListNotificationSettings performs the GET operation on a Notification settings resource.
func (c *NotificationSettingsClient) ListNotificationSettings(ctx context.Context, req *ListNotificationSettingsRequest) (res *Collection[*NotificationSetting], err error) {
if err := c.doer.Do(ctx, "GET", "/notification-settings", req, &res); err != nil {
return nil, err
}
return res, nil
}
// CreateNotificationSettingRequest is given as an input to CreateNotificationSetting.
type CreateNotificationSettingRequest struct {
// Description: Short description for this notification destination. Shown in the Paddle Dashboard.
Description string `json:"description,omitempty"`
// Destination: Webhook endpoint URL or email address.
Destination string `json:"destination,omitempty"`
// SubscribedEvents: Type of event sent by Paddle, in the format `entity.event_type`.
SubscribedEvents []EventTypeName `json:"subscribed_events,omitempty"`
// Type: Where notifications should be sent for this destination.
Type NotificationSettingType `json:"type,omitempty"`
// APIVersion: API version that returned objects for events should conform to. Must be a valid version of the Paddle API. Can't be a version older than your account default. If omitted, defaults to your account default version.
APIVersion *int `json:"api_version,omitempty"`
// IncludeSensitiveFields: Whether potentially sensitive fields should be sent to this notification destination. If omitted, defaults to `false`.
IncludeSensitiveFields *bool `json:"include_sensitive_fields,omitempty"`
// TrafficSource: Whether Paddle should deliver real platform events, simulation events or both to this notification destination. If omitted, defaults to `platform`.
TrafficSource *TrafficSource `json:"traffic_source,omitempty"`
}
// CreateNotificationSetting performs the POST operation on a Notification settings resource.
func (c *NotificationSettingsClient) CreateNotificationSetting(ctx context.Context, req *CreateNotificationSettingRequest) (res *NotificationSetting, err error) {
if err := c.doer.Do(ctx, "POST", "/notification-settings", req, &res); err != nil {
return nil, err
}
return res, nil
}
// GetNotificationSettingRequest is given as an input to GetNotificationSetting.
type GetNotificationSettingRequest struct {
// URL path parameters.
NotificationSettingID string `in:"path=notification_setting_id" json:"-"`
}
// GetNotificationSetting performs the GET operation on a Notification settings resource.
func (c *NotificationSettingsClient) GetNotificationSetting(ctx context.Context, req *GetNotificationSettingRequest) (res *NotificationSetting, err error) {
if err := c.doer.Do(ctx, "GET", "/notification-settings/{notification_setting_id}", req, &res); err != nil {
return nil, err
}
return res, nil
}
// UpdateNotificationSettingRequest is given as an input to UpdateNotificationSetting.
type UpdateNotificationSettingRequest struct {
// URL path parameters.
NotificationSettingID string `in:"path=notification_setting_id" json:"-"`
// Description: Short description for this notification destination. Shown in the Paddle Dashboard.
Description *PatchField[string] `json:"description,omitempty"`
// Destination: Webhook endpoint URL or email address.
Destination *PatchField[string] `json:"destination,omitempty"`
// Active: Whether Paddle should try to deliver events to this notification destination.
Active *PatchField[bool] `json:"active,omitempty"`
// APIVersion: API version that returned objects for events should conform to. Must be a valid version of the Paddle API. Can't be a version older than your account default. Defaults to your account default if omitted.
APIVersion *PatchField[int] `json:"api_version,omitempty"`
// IncludeSensitiveFields: Whether potentially sensitive fields should be sent to this notification destination.
IncludeSensitiveFields *PatchField[bool] `json:"include_sensitive_fields,omitempty"`
// SubscribedEvents: Type of event sent by Paddle, in the format `entity.event_type`.
SubscribedEvents *PatchField[[]EventTypeName] `json:"subscribed_events,omitempty"`
// TrafficSource: Whether Paddle should deliver real platform events, simulation events or both to this notification destination.
TrafficSource *PatchField[TrafficSource] `json:"traffic_source,omitempty"`
}
// UpdateNotificationSetting performs the PATCH operation on a Notification settings resource.
func (c *NotificationSettingsClient) UpdateNotificationSetting(ctx context.Context, req *UpdateNotificationSettingRequest) (res *NotificationSetting, err error) {
if err := c.doer.Do(ctx, "PATCH", "/notification-settings/{notification_setting_id}", req, &res); err != nil {
return nil, err
}
return res, nil
}
// DeleteNotificationSettingRequest is given as an input to DeleteNotificationSetting.
type DeleteNotificationSettingRequest struct {
// URL path parameters.
NotificationSettingID string `in:"path=notification_setting_id" json:"-"`
}
// DeleteNotificationSetting performs the DELETE operation on a Notification settings resource.
func (c *NotificationSettingsClient) DeleteNotificationSetting(ctx context.Context, req *DeleteNotificationSettingRequest) (err error) {
if err := c.doer.Do(ctx, "DELETE", "/notification-settings/{notification_setting_id}", req, nil); err != nil {
return err
}
return nil
}