Skip to content

Commit

Permalink
Add enable batching
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-joshi99 committed Nov 24, 2023
1 parent a75cedd commit e9f2370
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const createImportJobPayload = (profiles: Payload[], listId?: string): {
type: 'profile-bulk-import-job',
attributes: {
profiles: {
data: profiles.map(({ list_id, ...attributes }) => ({
data: profiles.map(({ list_id, enable_batching, ...attributes }) => ({
type: 'profile',
attributes
}))
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 @@ -19,6 +19,11 @@ const action: ActionDefinition<Settings, Payload> = {
format: 'email',
default: { '@path': '$.traits.email' }
},
enable_batching: {
type: 'boolean',
label: 'Batch Data to Klaviyo',
description: 'When enabled, the action will use the klaviyo batch API.'
},
phone_number: {
label: 'Phone Number',
description: `Individual's phone number in E.164 format. If SMS is not enabled and if you use Phone Number as identifier, then you have to provide one of Email or External ID.`,
Expand Down Expand Up @@ -135,7 +140,7 @@ const action: ActionDefinition<Settings, Payload> = {
}
},
perform: async (request, { payload }) => {
const { email, external_id, phone_number, list_id, ...otherAttributes } = payload
const { email, external_id, phone_number, list_id, enable_batching, ...otherAttributes } = payload

if (!email && !phone_number && !external_id) {
throw new PayloadValidationError('One of External ID, Phone Number and Email is required.')
Expand Down Expand Up @@ -192,10 +197,8 @@ const action: ActionDefinition<Settings, Payload> = {

performBatch: async (request, { payload }) => {
payload = payload.filter((profile) => profile.email || profile.external_id || profile.phone_number)
console.log(payload)
const profilesWithList = payload.filter((profile) => profile.list_id)
const profilesWithoutList = payload.filter((profile) => !profile.list_id)
console.log(profilesWithList, profilesWithoutList)

let importResponseWithList
let importResponseWithoutList
Expand Down

0 comments on commit e9f2370

Please sign in to comment.