diff --git a/gosdk/internal/version.go b/gosdk/internal/version.go index 25804f0..84a85ed 100644 --- a/gosdk/internal/version.go +++ b/gosdk/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "4.30.1" // x-release-please-version +const PackageVersion = "4.30.2" // x-release-please-version diff --git a/gosdk/shared/shared.go b/gosdk/shared/shared.go index 18fbac4..1e0b771 100644 --- a/gosdk/shared/shared.go +++ b/gosdk/shared/shared.go @@ -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"` @@ -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 @@ -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 @@ -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 { @@ -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() { @@ -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". @@ -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"` @@ -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 @@ -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"` diff --git a/pkg/cmd/broadcast_test.go b/pkg/cmd/broadcast_test.go index cd24e5e..45ad814 100644 --- a/pkg/cmd/broadcast_test.go +++ b/pkg/cmd/broadcast_test.go @@ -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", ) }) @@ -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", ) @@ -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" + diff --git a/pkg/cmd/journeytemplate_test.go b/pkg/cmd/journeytemplate_test.go index db6c0e8..97c63cb 100644 --- a/pkg/cmd/journeytemplate_test.go +++ b/pkg/cmd/journeytemplate_test.go @@ -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", @@ -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]", @@ -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" + @@ -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", ) }) @@ -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]", @@ -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" + diff --git a/pkg/cmd/tenanttemplate_test.go b/pkg/cmd/tenanttemplate_test.go index 9bbcfae..66c9f97 100644 --- a/pkg/cmd/tenanttemplate_test.go +++ b/pkg/cmd/tenanttemplate_test.go @@ -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", ) }) @@ -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}", @@ -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" +