Skip to content

Commit

Permalink
changing to field to single object instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-ayoub-segment committed Dec 12, 2024
1 parent 98504f7 commit 7c9a30b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Object {
Object {
"bcc": Array [
Object {
"email": "[email protected]",
"email": "[email protected]",
"name": "!s3p^",
},
],
"cc": Array [
Object {
"email": "[email protected]",
"email": "[email protected]",
"name": "!s3p^",
},
],
Expand All @@ -37,14 +37,14 @@ Object {
},
"to": Array [
Object {
"email": "[email protected]",
"email": "[email protected]",
"name": "!s3p^",
},
],
},
],
"reply_to": Object {
"email": "[email protected]",
"email": "[email protected]",
"name": "!s3p^",
},
"template_id": "d-1234567890",
Expand All @@ -54,20 +54,20 @@ Object {
exports[`Testing snapshot for Sendgrid's sendEmail destination action: required fields 1`] = `
Object {
"from": Object {
"email": "[email protected]",
"email": "[email protected]",
},
"personalizations": Array [
Object {
"headers": Object {},
"to": Array [
Object {
"email": "[email protected]",
"email": "[email protected]",
},
],
},
],
"reply_to": Object {
"email": "[email protected]",
"email": "[email protected]",
},
"template_id": "d-1234567890",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const fields: Record<string, InputField> = {
label: 'Email',
description: 'The email address of the sender.',
type: 'string',
format: 'email',
required: true
},
name: {
Expand All @@ -36,14 +37,15 @@ export const fields: Record<string, InputField> = {
label: 'To',
description: 'Recipient details.',
type: 'object',
multiple: true,
multiple: false,
required: true,
additionalProperties: false,
defaultObjectUI: 'keyvalue',
properties: {
email: {
label: 'Email',
description: 'The email address of the recipient.',
format: 'email',
type: 'string',
required: true
},
Expand All @@ -55,17 +57,12 @@ export const fields: Record<string, InputField> = {
}
},
default: {
'@arrayPath': [
'$.properties',
{
email: {
'@path': '$.email'
},
name: {
'@path': '$.name'
}
}
]
email: {
'@path': '$.properties.email'
},
name: {
'@path': '$.properties.name'
}
}
},
cc: {
Expand All @@ -81,6 +78,7 @@ export const fields: Record<string, InputField> = {
label: 'Email',
description: 'The email address of the CC recipient.',
type: 'string',
format: 'email',
required: true
},
name: {
Expand All @@ -105,6 +103,7 @@ export const fields: Record<string, InputField> = {
label: 'Email',
description: 'The email address of the BCC recipient.',
type: 'string',
format: 'email',
required: true
},
name: {
Expand Down Expand Up @@ -170,6 +169,7 @@ export const fields: Record<string, InputField> = {
label: 'Email',
description: 'The email to reply to.',
type: 'string',
format: 'email',
required: false
},
name: {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function send(request: RequestClient, payload: Payload) {
const json: SendEmailReq = {
personalizations: [
{
to: payload.to.map((to) => ({ email: to.email, name: to?.name ?? undefined })),
to: [{ email: payload.to.email, name: payload.to?.name ?? undefined }],
cc: payload.cc?.map((cc) => ({ email: cc.email, name: cc?.name ?? undefined })) ?? undefined,
bcc: payload.bcc?.map((bcc) => ({ email: bcc.email, name: bcc?.name ?? undefined })) ?? undefined,
headers:
Expand Down

0 comments on commit 7c9a30b

Please sign in to comment.