Skip to content

Commit 0d73e1d

Browse files
committed
Release v3.0.11
1 parent 1978cfc commit 0d73e1d

File tree

14 files changed

+746
-228
lines changed

14 files changed

+746
-228
lines changed

client/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
brands "github.com/trycourier/courier-go/v3/brands"
1313
bulk "github.com/trycourier/courier-go/v3/bulk"
1414
core "github.com/trycourier/courier-go/v3/core"
15+
inbound "github.com/trycourier/courier-go/v3/inbound"
1516
lists "github.com/trycourier/courier-go/v3/lists"
1617
messages "github.com/trycourier/courier-go/v3/messages"
1718
notifications "github.com/trycourier/courier-go/v3/notifications"
@@ -35,6 +36,7 @@ type Client struct {
3536
Automations *automations.Client
3637
Brands *brands.Client
3738
Bulk *bulk.Client
39+
Inbound *inbound.Client
3840
Lists *lists.Client
3941
Messages *messages.Client
4042
Notifications *notifications.Client
@@ -62,6 +64,7 @@ func NewClient(opts ...option.RequestOption) *Client {
6264
Automations: automations.NewClient(opts...),
6365
Brands: brands.NewClient(opts...),
6466
Bulk: bulk.NewClient(opts...),
67+
Inbound: inbound.NewClient(opts...),
6568
Lists: lists.NewClient(opts...),
6669
Messages: messages.NewClient(opts...),
6770
Notifications: notifications.NewClient(opts...),

core/request_option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (r *RequestOptions) cloneHeader() http.Header {
5151
headers := r.HTTPHeader.Clone()
5252
headers.Set("X-Fern-Language", "Go")
5353
headers.Set("X-Fern-SDK-Name", "github.com/trycourier/courier-go/v3")
54-
headers.Set("X-Fern-SDK-Version", "v3.0.10")
54+
headers.Set("X-Fern-SDK-Version", "v3.0.11")
5555
return headers
5656
}
5757

inbound.go

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
package api
4+
5+
import (
6+
json "encoding/json"
7+
fmt "fmt"
8+
core "github.com/trycourier/courier-go/v3/core"
9+
)
10+
11+
type InboundTrackEvent struct {
12+
// A descriptive name of the event. This name will appear as a trigger in the Courier Automation Trigger node.
13+
Event string `json:"event" url:"event"`
14+
// A required unique identifier that will be used to de-duplicate requests. If not unique, will respond with 409 Conflict status
15+
MessageId string `json:"messageId" url:"messageId"`
16+
Properties map[string]interface{} `json:"properties,omitempty" url:"properties,omitempty"`
17+
// The user id assocatiated with the track
18+
UserId *string `json:"userId,omitempty" url:"userId,omitempty"`
19+
type_ string
20+
21+
_rawJSON json.RawMessage
22+
}
23+
24+
func (i *InboundTrackEvent) Type() string {
25+
return i.type_
26+
}
27+
28+
func (i *InboundTrackEvent) UnmarshalJSON(data []byte) error {
29+
type embed InboundTrackEvent
30+
var unmarshaler = struct {
31+
embed
32+
}{
33+
embed: embed(*i),
34+
}
35+
if err := json.Unmarshal(data, &unmarshaler); err != nil {
36+
return err
37+
}
38+
*i = InboundTrackEvent(unmarshaler.embed)
39+
i.type_ = "track"
40+
i._rawJSON = json.RawMessage(data)
41+
return nil
42+
}
43+
44+
func (i *InboundTrackEvent) MarshalJSON() ([]byte, error) {
45+
type embed InboundTrackEvent
46+
var marshaler = struct {
47+
embed
48+
Type string `json:"type"`
49+
}{
50+
embed: embed(*i),
51+
Type: "track",
52+
}
53+
return json.Marshal(marshaler)
54+
}
55+
56+
func (i *InboundTrackEvent) String() string {
57+
if len(i._rawJSON) > 0 {
58+
if value, err := core.StringifyJSON(i._rawJSON); err == nil {
59+
return value
60+
}
61+
}
62+
if value, err := core.StringifyJSON(i); err == nil {
63+
return value
64+
}
65+
return fmt.Sprintf("%#v", i)
66+
}
67+
68+
type TrackAcceptedResponse struct {
69+
// A successful call returns a `202` status code along with a `requestId` in the response body.
70+
MessageId string `json:"messageId" url:"messageId"`
71+
72+
_rawJSON json.RawMessage
73+
}
74+
75+
func (t *TrackAcceptedResponse) UnmarshalJSON(data []byte) error {
76+
type unmarshaler TrackAcceptedResponse
77+
var value unmarshaler
78+
if err := json.Unmarshal(data, &value); err != nil {
79+
return err
80+
}
81+
*t = TrackAcceptedResponse(value)
82+
t._rawJSON = json.RawMessage(data)
83+
return nil
84+
}
85+
86+
func (t *TrackAcceptedResponse) String() string {
87+
if len(t._rawJSON) > 0 {
88+
if value, err := core.StringifyJSON(t._rawJSON); err == nil {
89+
return value
90+
}
91+
}
92+
if value, err := core.StringifyJSON(t); err == nil {
93+
return value
94+
}
95+
return fmt.Sprintf("%#v", t)
96+
}

inbound/client.go

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
package inbound
4+
5+
import (
6+
bytes "bytes"
7+
context "context"
8+
json "encoding/json"
9+
errors "errors"
10+
v3 "github.com/trycourier/courier-go/v3"
11+
core "github.com/trycourier/courier-go/v3/core"
12+
option "github.com/trycourier/courier-go/v3/option"
13+
io "io"
14+
http "net/http"
15+
)
16+
17+
type Client struct {
18+
baseURL string
19+
caller *core.Caller
20+
header http.Header
21+
}
22+
23+
func NewClient(opts ...option.RequestOption) *Client {
24+
options := core.NewRequestOptions(opts...)
25+
return &Client{
26+
baseURL: options.BaseURL,
27+
caller: core.NewCaller(
28+
&core.CallerParams{
29+
Client: options.HTTPClient,
30+
MaxAttempts: options.MaxAttempts,
31+
},
32+
),
33+
header: options.ToHeader(),
34+
}
35+
}
36+
37+
func (c *Client) Track(
38+
ctx context.Context,
39+
request *v3.InboundTrackEvent,
40+
opts ...option.RequestOption,
41+
) (*v3.TrackAcceptedResponse, error) {
42+
options := core.NewRequestOptions(opts...)
43+
44+
baseURL := "https://api.courier.com"
45+
if c.baseURL != "" {
46+
baseURL = c.baseURL
47+
}
48+
if options.BaseURL != "" {
49+
baseURL = options.BaseURL
50+
}
51+
endpointURL := baseURL + "/" + "inbound/courier"
52+
53+
headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())
54+
55+
errorDecoder := func(statusCode int, body io.Reader) error {
56+
raw, err := io.ReadAll(body)
57+
if err != nil {
58+
return err
59+
}
60+
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
61+
decoder := json.NewDecoder(bytes.NewReader(raw))
62+
switch statusCode {
63+
case 400:
64+
value := new(v3.BadRequestError)
65+
value.APIError = apiError
66+
if err := decoder.Decode(value); err != nil {
67+
return apiError
68+
}
69+
return value
70+
case 409:
71+
value := new(v3.ConflictError)
72+
value.APIError = apiError
73+
if err := decoder.Decode(value); err != nil {
74+
return apiError
75+
}
76+
return value
77+
}
78+
return apiError
79+
}
80+
81+
var response *v3.TrackAcceptedResponse
82+
if err := c.caller.Call(
83+
ctx,
84+
&core.CallParams{
85+
URL: endpointURL,
86+
Method: http.MethodPost,
87+
MaxAttempts: options.MaxAttempts,
88+
Headers: headers,
89+
Client: options.HTTPClient,
90+
Request: request,
91+
Response: &response,
92+
ErrorDecoder: errorDecoder,
93+
},
94+
); err != nil {
95+
return nil, err
96+
}
97+
return response, nil
98+
}

lists.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
core "github.com/trycourier/courier-go/v3/core"
99
)
1010

11+
type AddSubscribersToList struct {
12+
Recipients []*PutSubscriptionsRecipient `json:"recipients,omitempty" url:"recipients,omitempty"`
13+
}
14+
1115
type GetSubscriptionForListRequest struct {
1216
// A unique identifier that allows for fetching the next set of list subscriptions
1317
Cursor *string `json:"-" url:"cursor,omitempty"`
@@ -205,3 +209,7 @@ func (p *PutSubscriptionsRecipient) String() string {
205209
}
206210
return fmt.Sprintf("%#v", p)
207211
}
212+
213+
type SubscribeUsersToListRequest struct {
214+
Recipients []*PutSubscriptionsRecipient `json:"recipients,omitempty" url:"recipients,omitempty"`
215+
}

lists/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func (c *Client) UpdateSubscribers(
336336
ctx context.Context,
337337
// A unique identifier representing the list you wish to retrieve.
338338
listId string,
339-
request []*v3.PutSubscriptionsRecipient,
339+
request *v3.SubscribeUsersToListRequest,
340340
opts ...option.RequestOption,
341341
) error {
342342
options := core.NewRequestOptions(opts...)
@@ -393,7 +393,7 @@ func (c *Client) AddSubscribers(
393393
ctx context.Context,
394394
// A unique identifier representing the list you wish to retrieve.
395395
listId string,
396-
request []*v3.PutSubscriptionsRecipient,
396+
request *v3.AddSubscribersToList,
397397
opts ...option.IdempotentRequestOption,
398398
) error {
399399
options := core.NewIdempotentRequestOptions(opts...)

messages.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ type MessageDetails struct {
8282
// The current status of the message.
8383
Status MessageStatus `json:"status,omitempty" url:"status,omitempty"`
8484
// A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch.
85-
Enqueued int `json:"enqueued" url:"enqueued"`
85+
Enqueued int64 `json:"enqueued" url:"enqueued"`
8686
// A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch.
87-
Sent int `json:"sent" url:"sent"`
87+
Sent int64 `json:"sent" url:"sent"`
8888
// A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch.
89-
Delivered int `json:"delivered" url:"delivered"`
89+
Delivered int64 `json:"delivered" url:"delivered"`
9090
// A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch.
91-
Opened int `json:"opened" url:"opened"`
91+
Opened int64 `json:"opened" url:"opened"`
9292
// A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch.
93-
Clicked int `json:"clicked" url:"clicked"`
93+
Clicked int64 `json:"clicked" url:"clicked"`
9494
// A unique identifier associated with the recipient of the delivered message.
9595
Recipient string `json:"recipient" url:"recipient"`
9696
// A unique identifier associated with the event of the delivered message.
@@ -129,7 +129,7 @@ func (m *MessageDetails) String() string {
129129
}
130130

131131
type MessageHistoryResponse struct {
132-
Results []*MessageDetails `json:"results,omitempty" url:"results,omitempty"`
132+
Results []map[string]interface{} `json:"results,omitempty" url:"results,omitempty"`
133133

134134
_rawJSON json.RawMessage
135135
}

notifications.go

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -68,74 +68,6 @@ func (b *BaseCheck) String() string {
6868
return fmt.Sprintf("%#v", b)
6969
}
7070

71-
type NotificationBlock struct {
72-
Alias *string `json:"alias,omitempty" url:"alias,omitempty"`
73-
Context *string `json:"context,omitempty" url:"context,omitempty"`
74-
Id string `json:"id" url:"id"`
75-
Type BlockType `json:"type,omitempty" url:"type,omitempty"`
76-
Content *NotificationContent `json:"content,omitempty" url:"content,omitempty"`
77-
Locales map[string]*NotificationContent `json:"locales,omitempty" url:"locales,omitempty"`
78-
Checksum *string `json:"checksum,omitempty" url:"checksum,omitempty"`
79-
80-
_rawJSON json.RawMessage
81-
}
82-
83-
func (n *NotificationBlock) UnmarshalJSON(data []byte) error {
84-
type unmarshaler NotificationBlock
85-
var value unmarshaler
86-
if err := json.Unmarshal(data, &value); err != nil {
87-
return err
88-
}
89-
*n = NotificationBlock(value)
90-
n._rawJSON = json.RawMessage(data)
91-
return nil
92-
}
93-
94-
func (n *NotificationBlock) String() string {
95-
if len(n._rawJSON) > 0 {
96-
if value, err := core.StringifyJSON(n._rawJSON); err == nil {
97-
return value
98-
}
99-
}
100-
if value, err := core.StringifyJSON(n); err == nil {
101-
return value
102-
}
103-
return fmt.Sprintf("%#v", n)
104-
}
105-
106-
type NotificationChannel struct {
107-
Id string `json:"id" url:"id"`
108-
Type *string `json:"type,omitempty" url:"type,omitempty"`
109-
Content *NotificationChannelContent `json:"content,omitempty" url:"content,omitempty"`
110-
Locales map[string]*NotificationChannelContent `json:"locales,omitempty" url:"locales,omitempty"`
111-
Checksum *string `json:"checksum,omitempty" url:"checksum,omitempty"`
112-
113-
_rawJSON json.RawMessage
114-
}
115-
116-
func (n *NotificationChannel) UnmarshalJSON(data []byte) error {
117-
type unmarshaler NotificationChannel
118-
var value unmarshaler
119-
if err := json.Unmarshal(data, &value); err != nil {
120-
return err
121-
}
122-
*n = NotificationChannel(value)
123-
n._rawJSON = json.RawMessage(data)
124-
return nil
125-
}
126-
127-
func (n *NotificationChannel) String() string {
128-
if len(n._rawJSON) > 0 {
129-
if value, err := core.StringifyJSON(n._rawJSON); err == nil {
130-
return value
131-
}
132-
}
133-
if value, err := core.StringifyJSON(n); err == nil {
134-
return value
135-
}
136-
return fmt.Sprintf("%#v", n)
137-
}
138-
13971
type NotificationGetContentResponse struct {
14072
Blocks []*NotificationBlock `json:"blocks,omitempty" url:"blocks,omitempty"`
14173
Channels []*NotificationChannel `json:"channels,omitempty" url:"channels,omitempty"`
@@ -254,13 +186,3 @@ func (s *SubmissionChecksReplaceResponse) String() string {
254186
}
255187
return fmt.Sprintf("%#v", s)
256188
}
257-
258-
type NotificationDraftUpdateVariationsParams struct {
259-
Blocks []*NotificationBlock `json:"blocks,omitempty" url:"blocks,omitempty"`
260-
Channels []*NotificationChannel `json:"channels,omitempty" url:"channels,omitempty"`
261-
}
262-
263-
type NotificationUpdateVariationsParams struct {
264-
Blocks []*NotificationBlock `json:"blocks,omitempty" url:"blocks,omitempty"`
265-
Channels []*NotificationChannel `json:"channels,omitempty" url:"channels,omitempty"`
266-
}

0 commit comments

Comments
 (0)