Skip to content

Commit

Permalink
Release v3.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Aug 27, 2024
1 parent 1978cfc commit 0d73e1d
Show file tree
Hide file tree
Showing 14 changed files with 746 additions and 228 deletions.
3 changes: 3 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
brands "github.com/trycourier/courier-go/v3/brands"
bulk "github.com/trycourier/courier-go/v3/bulk"
core "github.com/trycourier/courier-go/v3/core"
inbound "github.com/trycourier/courier-go/v3/inbound"
lists "github.com/trycourier/courier-go/v3/lists"
messages "github.com/trycourier/courier-go/v3/messages"
notifications "github.com/trycourier/courier-go/v3/notifications"
Expand All @@ -35,6 +36,7 @@ type Client struct {
Automations *automations.Client
Brands *brands.Client
Bulk *bulk.Client
Inbound *inbound.Client
Lists *lists.Client
Messages *messages.Client
Notifications *notifications.Client
Expand Down Expand Up @@ -62,6 +64,7 @@ func NewClient(opts ...option.RequestOption) *Client {
Automations: automations.NewClient(opts...),
Brands: brands.NewClient(opts...),
Bulk: bulk.NewClient(opts...),
Inbound: inbound.NewClient(opts...),
Lists: lists.NewClient(opts...),
Messages: messages.NewClient(opts...),
Notifications: notifications.NewClient(opts...),
Expand Down
2 changes: 1 addition & 1 deletion core/request_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (r *RequestOptions) cloneHeader() http.Header {
headers := r.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/trycourier/courier-go/v3")
headers.Set("X-Fern-SDK-Version", "v3.0.10")
headers.Set("X-Fern-SDK-Version", "v3.0.11")
return headers
}

Expand Down
96 changes: 96 additions & 0 deletions inbound.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// This file was auto-generated by Fern from our API Definition.

package api

import (
json "encoding/json"
fmt "fmt"
core "github.com/trycourier/courier-go/v3/core"
)

type InboundTrackEvent struct {
// A descriptive name of the event. This name will appear as a trigger in the Courier Automation Trigger node.
Event string `json:"event" url:"event"`
// A required unique identifier that will be used to de-duplicate requests. If not unique, will respond with 409 Conflict status
MessageId string `json:"messageId" url:"messageId"`
Properties map[string]interface{} `json:"properties,omitempty" url:"properties,omitempty"`
// The user id assocatiated with the track
UserId *string `json:"userId,omitempty" url:"userId,omitempty"`
type_ string

_rawJSON json.RawMessage
}

func (i *InboundTrackEvent) Type() string {
return i.type_
}

func (i *InboundTrackEvent) UnmarshalJSON(data []byte) error {
type embed InboundTrackEvent
var unmarshaler = struct {
embed
}{
embed: embed(*i),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*i = InboundTrackEvent(unmarshaler.embed)
i.type_ = "track"
i._rawJSON = json.RawMessage(data)
return nil
}

func (i *InboundTrackEvent) MarshalJSON() ([]byte, error) {
type embed InboundTrackEvent
var marshaler = struct {
embed
Type string `json:"type"`
}{
embed: embed(*i),
Type: "track",
}
return json.Marshal(marshaler)
}

func (i *InboundTrackEvent) String() string {
if len(i._rawJSON) > 0 {
if value, err := core.StringifyJSON(i._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(i); err == nil {
return value
}
return fmt.Sprintf("%#v", i)
}

type TrackAcceptedResponse struct {
// A successful call returns a `202` status code along with a `requestId` in the response body.
MessageId string `json:"messageId" url:"messageId"`

_rawJSON json.RawMessage
}

func (t *TrackAcceptedResponse) UnmarshalJSON(data []byte) error {
type unmarshaler TrackAcceptedResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*t = TrackAcceptedResponse(value)
t._rawJSON = json.RawMessage(data)
return nil
}

func (t *TrackAcceptedResponse) String() string {
if len(t._rawJSON) > 0 {
if value, err := core.StringifyJSON(t._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(t); err == nil {
return value
}
return fmt.Sprintf("%#v", t)
}
98 changes: 98 additions & 0 deletions inbound/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// This file was auto-generated by Fern from our API Definition.

package inbound

import (
bytes "bytes"
context "context"
json "encoding/json"
errors "errors"
v3 "github.com/trycourier/courier-go/v3"
core "github.com/trycourier/courier-go/v3/core"
option "github.com/trycourier/courier-go/v3/option"
io "io"
http "net/http"
)

type Client struct {
baseURL string
caller *core.Caller
header http.Header
}

func NewClient(opts ...option.RequestOption) *Client {
options := core.NewRequestOptions(opts...)
return &Client{
baseURL: options.BaseURL,
caller: core.NewCaller(
&core.CallerParams{
Client: options.HTTPClient,
MaxAttempts: options.MaxAttempts,
},
),
header: options.ToHeader(),
}
}

func (c *Client) Track(
ctx context.Context,
request *v3.InboundTrackEvent,
opts ...option.RequestOption,
) (*v3.TrackAcceptedResponse, error) {
options := core.NewRequestOptions(opts...)

baseURL := "https://api.courier.com"
if c.baseURL != "" {
baseURL = c.baseURL
}
if options.BaseURL != "" {
baseURL = options.BaseURL
}
endpointURL := baseURL + "/" + "inbound/courier"

headers := core.MergeHeaders(c.header.Clone(), options.ToHeader())

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 400:
value := new(v3.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 409:
value := new(v3.ConflictError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *v3.TrackAcceptedResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodPost,
MaxAttempts: options.MaxAttempts,
Headers: headers,
Client: options.HTTPClient,
Request: request,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return nil, err
}
return response, nil
}
8 changes: 8 additions & 0 deletions lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
core "github.com/trycourier/courier-go/v3/core"
)

type AddSubscribersToList struct {
Recipients []*PutSubscriptionsRecipient `json:"recipients,omitempty" url:"recipients,omitempty"`
}

type GetSubscriptionForListRequest struct {
// A unique identifier that allows for fetching the next set of list subscriptions
Cursor *string `json:"-" url:"cursor,omitempty"`
Expand Down Expand Up @@ -205,3 +209,7 @@ func (p *PutSubscriptionsRecipient) String() string {
}
return fmt.Sprintf("%#v", p)
}

type SubscribeUsersToListRequest struct {
Recipients []*PutSubscriptionsRecipient `json:"recipients,omitempty" url:"recipients,omitempty"`
}
4 changes: 2 additions & 2 deletions lists/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func (c *Client) UpdateSubscribers(
ctx context.Context,
// A unique identifier representing the list you wish to retrieve.
listId string,
request []*v3.PutSubscriptionsRecipient,
request *v3.SubscribeUsersToListRequest,
opts ...option.RequestOption,
) error {
options := core.NewRequestOptions(opts...)
Expand Down Expand Up @@ -393,7 +393,7 @@ func (c *Client) AddSubscribers(
ctx context.Context,
// A unique identifier representing the list you wish to retrieve.
listId string,
request []*v3.PutSubscriptionsRecipient,
request *v3.AddSubscribersToList,
opts ...option.IdempotentRequestOption,
) error {
options := core.NewIdempotentRequestOptions(opts...)
Expand Down
12 changes: 6 additions & 6 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ type MessageDetails struct {
// The current status of the message.
Status MessageStatus `json:"status,omitempty" url:"status,omitempty"`
// A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch.
Enqueued int `json:"enqueued" url:"enqueued"`
Enqueued int64 `json:"enqueued" url:"enqueued"`
// A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch.
Sent int `json:"sent" url:"sent"`
Sent int64 `json:"sent" url:"sent"`
// A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch.
Delivered int `json:"delivered" url:"delivered"`
Delivered int64 `json:"delivered" url:"delivered"`
// A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch.
Opened int `json:"opened" url:"opened"`
Opened int64 `json:"opened" url:"opened"`
// 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.
Clicked int `json:"clicked" url:"clicked"`
Clicked int64 `json:"clicked" url:"clicked"`
// A unique identifier associated with the recipient of the delivered message.
Recipient string `json:"recipient" url:"recipient"`
// A unique identifier associated with the event of the delivered message.
Expand Down Expand Up @@ -129,7 +129,7 @@ func (m *MessageDetails) String() string {
}

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

_rawJSON json.RawMessage
}
Expand Down
78 changes: 0 additions & 78 deletions notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,74 +68,6 @@ func (b *BaseCheck) String() string {
return fmt.Sprintf("%#v", b)
}

type NotificationBlock struct {
Alias *string `json:"alias,omitempty" url:"alias,omitempty"`
Context *string `json:"context,omitempty" url:"context,omitempty"`
Id string `json:"id" url:"id"`
Type BlockType `json:"type,omitempty" url:"type,omitempty"`
Content *NotificationContent `json:"content,omitempty" url:"content,omitempty"`
Locales map[string]*NotificationContent `json:"locales,omitempty" url:"locales,omitempty"`
Checksum *string `json:"checksum,omitempty" url:"checksum,omitempty"`

_rawJSON json.RawMessage
}

func (n *NotificationBlock) UnmarshalJSON(data []byte) error {
type unmarshaler NotificationBlock
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*n = NotificationBlock(value)
n._rawJSON = json.RawMessage(data)
return nil
}

func (n *NotificationBlock) String() string {
if len(n._rawJSON) > 0 {
if value, err := core.StringifyJSON(n._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(n); err == nil {
return value
}
return fmt.Sprintf("%#v", n)
}

type NotificationChannel struct {
Id string `json:"id" url:"id"`
Type *string `json:"type,omitempty" url:"type,omitempty"`
Content *NotificationChannelContent `json:"content,omitempty" url:"content,omitempty"`
Locales map[string]*NotificationChannelContent `json:"locales,omitempty" url:"locales,omitempty"`
Checksum *string `json:"checksum,omitempty" url:"checksum,omitempty"`

_rawJSON json.RawMessage
}

func (n *NotificationChannel) UnmarshalJSON(data []byte) error {
type unmarshaler NotificationChannel
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*n = NotificationChannel(value)
n._rawJSON = json.RawMessage(data)
return nil
}

func (n *NotificationChannel) String() string {
if len(n._rawJSON) > 0 {
if value, err := core.StringifyJSON(n._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(n); err == nil {
return value
}
return fmt.Sprintf("%#v", n)
}

type NotificationGetContentResponse struct {
Blocks []*NotificationBlock `json:"blocks,omitempty" url:"blocks,omitempty"`
Channels []*NotificationChannel `json:"channels,omitempty" url:"channels,omitempty"`
Expand Down Expand Up @@ -254,13 +186,3 @@ func (s *SubmissionChecksReplaceResponse) String() string {
}
return fmt.Sprintf("%#v", s)
}

type NotificationDraftUpdateVariationsParams struct {
Blocks []*NotificationBlock `json:"blocks,omitempty" url:"blocks,omitempty"`
Channels []*NotificationChannel `json:"channels,omitempty" url:"channels,omitempty"`
}

type NotificationUpdateVariationsParams struct {
Blocks []*NotificationBlock `json:"blocks,omitempty" url:"blocks,omitempty"`
Channels []*NotificationChannel `json:"channels,omitempty" url:"channels,omitempty"`
}
Loading

0 comments on commit 0d73e1d

Please sign in to comment.