Skip to content

Commit 785dc16

Browse files
authored
feat(tem): add support for flags (#1783)
1 parent 46c7afd commit 785dc16

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

api/tem/v1alpha1/tem_sdk.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,40 @@ func (enum *DomainStatus) UnmarshalJSON(data []byte) error {
129129
return nil
130130
}
131131

132+
type EmailFlag string
133+
134+
const (
135+
// If unspecified, the flag type is unknown by default
136+
EmailFlagUnknownFlag = EmailFlag("unknown_flag")
137+
// Refers to a non critical error received while sending the email(s). Soft bounced emails are retried
138+
EmailFlagSoftBounce = EmailFlag("soft_bounce")
139+
// Refers to a critical error that happened while sending the email(s)
140+
EmailFlagHardBounce = EmailFlag("hard_bounce")
141+
)
142+
143+
func (enum EmailFlag) String() string {
144+
if enum == "" {
145+
// return default value if empty
146+
return "unknown_flag"
147+
}
148+
return string(enum)
149+
}
150+
151+
func (enum EmailFlag) MarshalJSON() ([]byte, error) {
152+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
153+
}
154+
155+
func (enum *EmailFlag) UnmarshalJSON(data []byte) error {
156+
tmp := ""
157+
158+
if err := json.Unmarshal(data, &tmp); err != nil {
159+
return err
160+
}
161+
162+
*enum = EmailFlag(EmailFlag(tmp).String())
163+
return nil
164+
}
165+
132166
type EmailRcptType string
133167

134168
const (
@@ -390,6 +424,8 @@ type Email struct {
390424
TryCount uint32 `json:"try_count"`
391425
// LastTries: information about the last three attempts to send the email.
392426
LastTries []*EmailTry `json:"last_tries"`
427+
// Flags: flags categorize emails. They allow you to obtain more information about recurring errors, for example.
428+
Flags []EmailFlag `json:"flags"`
393429
}
394430

395431
// EmailTry: email. try.
@@ -579,6 +615,8 @@ type ListEmailsRequest struct {
579615
// OrderBy: (Optional) List emails corresponding to specific criteria.
580616
// Default value: created_at_desc
581617
OrderBy ListEmailsRequestOrderBy `json:"-"`
618+
// Flags: (Optional) List emails containing only specific flags.
619+
Flags []EmailFlag `json:"-"`
582620
}
583621

584622
// ListEmails: list emails.
@@ -611,6 +649,7 @@ func (s *API) ListEmails(req *ListEmailsRequest, opts ...scw.RequestOption) (*Li
611649
parameter.AddToQuery(query, "subject", req.Subject)
612650
parameter.AddToQuery(query, "search", req.Search)
613651
parameter.AddToQuery(query, "order_by", req.OrderBy)
652+
parameter.AddToQuery(query, "flags", req.Flags)
614653

615654
if fmt.Sprint(req.Region) == "" {
616655
return nil, errors.New("field Region cannot be empty in request")

0 commit comments

Comments
 (0)