Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gosdk/internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "4.30.1" // x-release-please-version
const PackageVersion = "4.30.2" // x-release-please-version
56 changes: 25 additions & 31 deletions gosdk/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -1195,12 +1195,12 @@ type ElementalNodeUnion struct {
// [ElementalImageNodeWithType], [ElementalActionNodeWithType],
// [ElementalDividerNodeWithType], [ElementalQuoteNodeWithType],
// [ElementalHTMLNodeWithType].
Ref string `json:"ref"`
Content string `json:"content"`
Align string `json:"align"`
Ref string `json:"ref"`
Align string `json:"align"`
// This field is from variant [ElementalTextNodeWithType].
Bold string `json:"bold"`
Color string `json:"color"`
Content string `json:"content"`
FontSize string `json:"font_size"`
// This field is from variant [ElementalTextNodeWithType].
Format string `json:"format"`
Expand Down Expand Up @@ -1247,10 +1247,10 @@ type ElementalNodeUnion struct {
If respjson.Field
Loop respjson.Field
Ref respjson.Field
Content respjson.Field
Align respjson.Field
Bold respjson.Field
Color respjson.Field
Content respjson.Field
FontSize respjson.Field
Format respjson.Field
Italic respjson.Field
Expand Down Expand Up @@ -1335,12 +1335,6 @@ func (r ElementalNodeUnion) ToParam() ElementalNodeUnionParam {
return param.Override[ElementalNodeUnionParam](json.RawMessage(r.RawJSON()))
}

func ElementalNodeParamOfElementalTextNodeWithType(content string) ElementalNodeUnionParam {
var variant ElementalTextNodeWithTypeParam
variant.Content = content
return ElementalNodeUnionParam{OfElementalTextNodeWithType: &variant}
}

func ElementalNodeParamOfElementalImageNodeWithType(src string) ElementalNodeUnionParam {
var variant ElementalImageNodeWithTypeParam
variant.Src = src
Expand Down Expand Up @@ -1610,20 +1604,6 @@ func (u ElementalNodeUnionParam) GetRef() *string {
return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u ElementalNodeUnionParam) GetContent() *string {
if vt := u.OfElementalTextNodeWithType; vt != nil {
return (*string)(&vt.Content)
} else if vt := u.OfElementalActionNodeWithType; vt != nil {
return (*string)(&vt.Content)
} else if vt := u.OfElementalQuoteNodeWithType; vt != nil {
return (*string)(&vt.Content)
} else if vt := u.OfElementalHTMLNodeWithType; vt != nil {
return (*string)(&vt.Content)
}
return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u ElementalNodeUnionParam) GetAlign() *string {
if vt := u.OfElementalTextNodeWithType; vt != nil {
Expand All @@ -1648,6 +1628,20 @@ func (u ElementalNodeUnionParam) GetColor() *string {
return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u ElementalNodeUnionParam) GetContent() *string {
if vt := u.OfElementalTextNodeWithType; vt != nil && vt.Content.Valid() {
return &vt.Content.Value
} else if vt := u.OfElementalActionNodeWithType; vt != nil {
return (*string)(&vt.Content)
} else if vt := u.OfElementalQuoteNodeWithType; vt != nil {
return (*string)(&vt.Content)
} else if vt := u.OfElementalHTMLNodeWithType; vt != nil {
return (*string)(&vt.Content)
}
return nil
}

// Returns a pointer to the underlying variant's property, if present.
func (u ElementalNodeUnionParam) GetFontSize() *string {
if vt := u.OfElementalTextNodeWithType; vt != nil && vt.FontSize.Valid() {
Expand Down Expand Up @@ -1911,9 +1905,6 @@ func (r ElementalQuoteNodeWithTypeParam) MarshalJSON() (data []byte, err error)

// Represents a body of text to be rendered inside of the notification.
type ElementalTextNode struct {
// The text content displayed in the notification. Either this field must be
// specified, or the elements field
Content string `json:"content" api:"required"`
// Text alignment.
//
// Any of "left", "center", "right".
Expand All @@ -1922,6 +1913,9 @@ type ElementalTextNode struct {
Bold string `json:"bold" api:"nullable"`
// Specifies the color of text. Can be any valid css color value
Color string `json:"color" api:"nullable"`
// The text content displayed in the notification. Either this field must be
// specified, or the elements field
Content string `json:"content"`
// CSS px font size for this text block, e.g. `16px`. Overrides the size of the
// `text_style` preset. Email only.
FontSize string `json:"font_size" api:"nullable"`
Expand All @@ -1946,10 +1940,10 @@ type ElementalTextNode struct {
Underline string `json:"underline" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Content respjson.Field
Align respjson.Field
Bold respjson.Field
Color respjson.Field
Content respjson.Field
FontSize respjson.Field
Format respjson.Field
Italic respjson.Field
Expand Down Expand Up @@ -1981,15 +1975,15 @@ func (r ElementalTextNode) ToParam() ElementalTextNodeParam {

// Represents a body of text to be rendered inside of the notification.
type ElementalTextNodeParam struct {
// The text content displayed in the notification. Either this field must be
// specified, or the elements field
Content string `json:"content" api:"required"`
// Text alignment.
Align string `json:"align,omitzero"`
// Apply bold to the text
Bold param.Opt[string] `json:"bold,omitzero"`
// Specifies the color of text. Can be any valid css color value
Color param.Opt[string] `json:"color,omitzero"`
// The text content displayed in the notification. Either this field must be
// specified, or the elements field
Content param.Opt[string] `json:"content,omitzero"`
// CSS px font size for this text block, e.g. `16px`. Overrides the size of the
// `text_style` preset. Email only.
FontSize param.Opt[string] `json:"font_size,omitzero"`
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestBroadcastsPutContent(t *testing.T) {
"--api-key", "string",
"broadcasts", "put-content",
"--broadcast-id", "broadcastId",
"--content", "{elements: [{channels: [string], if: if, loop: loop, ref: ref, title: Spring Sale is here, type: meta}, {channels: [string], if: if, loop: loop, ref: ref, content: Hello! Check out our spring sale., align: left, bold: bold, color: color, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01'}",
"--content", "{elements: [{channels: [string], if: if, loop: loop, ref: ref, title: Spring Sale is here, type: meta}, {channels: [string], if: if, loop: loop, ref: ref, align: left, bold: bold, color: color, content: Hello! Check out our spring sale., font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01'}",
"--state", "DRAFT",
)
})
Expand All @@ -142,7 +142,7 @@ func TestBroadcastsPutContent(t *testing.T) {
"--api-key", "string",
"broadcasts", "put-content",
"--broadcast-id", "broadcastId",
"--content.elements", "[{channels: [string], if: if, loop: loop, ref: ref, title: Spring Sale is here, type: meta}, {channels: [string], if: if, loop: loop, ref: ref, content: Hello! Check out our spring sale., align: left, bold: bold, color: color, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}]",
"--content.elements", "[{channels: [string], if: if, loop: loop, ref: ref, title: Spring Sale is here, type: meta}, {channels: [string], if: if, loop: loop, ref: ref, align: left, bold: bold, color: color, content: Hello! Check out our spring sale., font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}]",
"--content.version", "2022-01-01",
"--state", "DRAFT",
)
Expand All @@ -165,10 +165,10 @@ func TestBroadcastsPutContent(t *testing.T) {
" if: if\n" +
" loop: loop\n" +
" ref: ref\n" +
" content: Hello! Check out our spring sale.\n" +
" align: left\n" +
" bold: bold\n" +
" color: color\n" +
" content: Hello! Check out our spring sale.\n" +
" font_size: font_size\n" +
" format: markdown\n" +
" italic: italic\n" +
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/journeytemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestJourneysTemplatesCreate(t *testing.T) {
"journeys:templates", "create",
"--template-id", "x",
"--channel", "email",
"--notification", "{brand: {id: id}, content: {elements: [{channels: [string], if: if, loop: loop, ref: ref, content: Welcome!, align: left, bold: bold, color: color, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01', scope: default}, name: Welcome email, subscription: {topic_id: topic_id}, tags: [string]}",
"--notification", "{brand: {id: id}, content: {elements: [{channels: [string], if: if, loop: loop, ref: ref, align: left, bold: bold, color: color, content: Welcome!, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01', scope: default}, name: Welcome email, subscription: {topic_id: topic_id}, tags: [string]}",
"--provider-key", "x",
"--state", "state",
"--idempotency-key", "order-ORD-456-user-123",
Expand All @@ -38,7 +38,7 @@ func TestJourneysTemplatesCreate(t *testing.T) {
"--template-id", "x",
"--channel", "email",
"--notification.brand", "{id: id}",
"--notification.content", "{elements: [{channels: [string], if: if, loop: loop, ref: ref, content: Welcome!, align: left, bold: bold, color: color, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01', scope: default}",
"--notification.content", "{elements: [{channels: [string], if: if, loop: loop, ref: ref, align: left, bold: bold, color: color, content: Welcome!, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01', scope: default}",
"--notification.name", "Welcome email",
"--notification.subscription", "{topic_id: topic_id}",
"--notification.tags", "[string]",
Expand All @@ -63,10 +63,10 @@ func TestJourneysTemplatesCreate(t *testing.T) {
" if: if\n" +
" loop: loop\n" +
" ref: ref\n" +
" content: Welcome!\n" +
" align: left\n" +
" bold: bold\n" +
" color: color\n" +
" content: Welcome!\n" +
" font_size: font_size\n" +
" format: markdown\n" +
" italic: italic\n" +
Expand Down Expand Up @@ -302,7 +302,7 @@ func TestJourneysTemplatesReplace(t *testing.T) {
"journeys:templates", "replace",
"--template-id", "x",
"--notification-id", "x",
"--notification", "{brand: {id: id}, content: {elements: [{channels: [string], if: if, loop: loop, ref: ref, content: content, align: left, bold: bold, color: color, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01', scope: default}, name: name, subscription: {topic_id: topic_id}, tags: [string]}",
"--notification", "{brand: {id: id}, content: {elements: [{channels: [string], if: if, loop: loop, ref: ref, align: left, bold: bold, color: color, content: content, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01', scope: default}, name: name, subscription: {topic_id: topic_id}, tags: [string]}",
"--state", "state",
)
})
Expand All @@ -319,7 +319,7 @@ func TestJourneysTemplatesReplace(t *testing.T) {
"--template-id", "x",
"--notification-id", "x",
"--notification.brand", "{id: id}",
"--notification.content", "{elements: [{channels: [string], if: if, loop: loop, ref: ref, content: content, align: left, bold: bold, color: color, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01', scope: default}",
"--notification.content", "{elements: [{channels: [string], if: if, loop: loop, ref: ref, align: left, bold: bold, color: color, content: content, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01', scope: default}",
"--notification.name", "name",
"--notification.subscription", "{topic_id: topic_id}",
"--notification.tags", "[string]",
Expand All @@ -340,10 +340,10 @@ func TestJourneysTemplatesReplace(t *testing.T) {
" if: if\n" +
" loop: loop\n" +
" ref: ref\n" +
" content: content\n" +
" align: left\n" +
" bold: bold\n" +
" color: color\n" +
" content: content\n" +
" font_size: font_size\n" +
" format: markdown\n" +
" italic: italic\n" +
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/tenanttemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestTenantsTemplatesReplace(t *testing.T) {
"tenants:templates", "replace",
"--tenant-id", "tenant_id",
"--template-id", "template_id",
"--template", "{content: {elements: [{channels: [string], if: if, loop: loop, ref: ref, content: 'Hello {{name}}', align: left, bold: bold, color: color, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01'}, channels: {foo: {brand_id: brand_id, if: if, metadata: {utm: {campaign: campaign, content: content, medium: medium, source: source, term: term}}, override: {foo: bar}, providers: [string], routing_method: all, timeouts: {channel: 0, provider: 0}}}, providers: {foo: {if: if, metadata: {utm: {campaign: campaign, content: content, medium: medium, source: source, term: term}}, override: {foo: bar}, timeouts: 0}}, routing: {channels: [email], method: single}}",
"--template", "{content: {elements: [{channels: [string], if: if, loop: loop, ref: ref, align: left, bold: bold, color: color, content: 'Hello {{name}}', font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01'}, channels: {foo: {brand_id: brand_id, if: if, metadata: {utm: {campaign: campaign, content: content, medium: medium, source: source, term: term}}, override: {foo: bar}, providers: [string], routing_method: all, timeouts: {channel: 0, provider: 0}}}, providers: {foo: {if: if, metadata: {utm: {campaign: campaign, content: content, medium: medium, source: source, term: term}}, override: {foo: bar}, timeouts: 0}}, routing: {channels: [email], method: single}}",
"--published=true",
)
})
Expand All @@ -100,7 +100,7 @@ func TestTenantsTemplatesReplace(t *testing.T) {
"tenants:templates", "replace",
"--tenant-id", "tenant_id",
"--template-id", "template_id",
"--template.content", "{elements: [{channels: [string], if: if, loop: loop, ref: ref, content: 'Hello {{name}}', align: left, bold: bold, color: color, font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01'}",
"--template.content", "{elements: [{channels: [string], if: if, loop: loop, ref: ref, align: left, bold: bold, color: color, content: 'Hello {{name}}', font_size: font_size, format: markdown, italic: italic, line_height: line_height, locales: {foo: {content: content}}, strikethrough: strikethrough, text_style: text, underline: underline, type: text}], version: '2022-01-01'}",
"--template.channels", "{foo: {brand_id: brand_id, if: if, metadata: {utm: {campaign: campaign, content: content, medium: medium, source: source, term: term}}, override: {foo: bar}, providers: [string], routing_method: all, timeouts: {channel: 0, provider: 0}}}",
"--template.providers", "{foo: {if: if, metadata: {utm: {campaign: campaign, content: content, medium: medium, source: source, term: term}}, override: {foo: bar}, timeouts: 0}}",
"--template.routing", "{channels: [email], method: single}",
Expand All @@ -119,10 +119,10 @@ func TestTenantsTemplatesReplace(t *testing.T) {
" if: if\n" +
" loop: loop\n" +
" ref: ref\n" +
" content: Hello {{name}}\n" +
" align: left\n" +
" bold: bold\n" +
" color: color\n" +
" content: Hello {{name}}\n" +
" font_size: font_size\n" +
" format: markdown\n" +
" italic: italic\n" +
Expand Down
Loading