diff --git a/src/cdk/v2/destinations/clicksend/procWorkflow.yaml b/src/cdk/v2/destinations/clicksend/procWorkflow.yaml index 6a8646d812..0833bba198 100644 --- a/src/cdk/v2/destinations/clicksend/procWorkflow.yaml +++ b/src/cdk/v2/destinations/clicksend/procWorkflow.yaml @@ -62,8 +62,6 @@ steps: from : $.getDestinationExternalID(^.message,'CLICKSEND_SENDER_EMAIL') || ^.destination.Config.defaultSenderEmail, schedule : $.deduceSchedule(.properties.schedule,{{{{$.getGenericPaths("timestamp")}}}}, ^.destination.Config) }); - console.log(JSON.stringify(.destination.Config)); - console.log(.destination.Config.defaultSenderEmail); $.assert(!Number.isNaN(sendCampaignPayload.list_id), "list_id must be an integer"); $.validateTrackSMSCampaignPayload(sendCampaignPayload); $.context.payload = $.removeUndefinedAndNullValues(sendCampaignPayload); @@ -78,7 +76,7 @@ steps: to: {{{{$.getGenericPaths("phone")}}}}, body: .properties.body, source: .properties.source || ^.destination.Config.defaultSource, - schedule: $.deduceSchedule(.properties.schedule, ^.destination.Config), + schedule: $.deduceSchedule(.properties.schedule, {{{{$.getGenericPaths("timestamp")}}}}, ^.destination.Config), custom_string: .properties.custom_string, country: {{{{$.getGenericPaths("country")}}}}, from_email: .properties.from_email diff --git a/src/cdk/v2/destinations/clicksend/utils.js b/src/cdk/v2/destinations/clicksend/utils.js index ea7a8632e3..3855d1b3ee 100644 --- a/src/cdk/v2/destinations/clicksend/utils.js +++ b/src/cdk/v2/destinations/clicksend/utils.js @@ -1,10 +1,8 @@ -const { - isDefinedAndNotNullAndNotEmpty, - InstrumentationError, -} = require('@rudderstack/integrations-lib'); +const { InstrumentationError } = require('@rudderstack/integrations-lib'); const lodash = require('lodash'); const { BatchUtils } = require('@rudderstack/workflow-engine'); const { SMS_SEND_ENDPOINT, MAX_BATCH_SIZE, COMMON_CONTACT_DOMAIN } = require('./config'); +const { isDefinedAndNotNullAndNotEmpty } = require('../../../../v0/util'); const getEndIdentifyPoint = (contactId, contactListId) => { if (isDefinedAndNotNullAndNotEmpty(contactId) && isDefinedAndNotNullAndNotEmpty(contactListId)) { @@ -28,12 +26,7 @@ const validateIdentifyPayload = (payload) => { }; const validateTrackSMSCampaignPayload = (payload) => { - if ( - !isDefinedAndNotNullAndNotEmpty(payload.body) && - !isDefinedAndNotNullAndNotEmpty(payload.name) && - !isDefinedAndNotNullAndNotEmpty(payload.list_id) && - !isDefinedAndNotNullAndNotEmpty(payload.from) - ) { + if (!(payload.body && payload.name && payload.list_id && payload.from)) { throw new InstrumentationError( 'All of contact list Id, name, body and from are required to trigger an sms campaign', ); diff --git a/src/cdk/v2/destinations/clicksend/utils.test.js b/src/cdk/v2/destinations/clicksend/utils.test.js new file mode 100644 index 0000000000..2393da0f7b --- /dev/null +++ b/src/cdk/v2/destinations/clicksend/utils.test.js @@ -0,0 +1,38 @@ +const { validateTrackSMSCampaignPayload } = require('./utils'); + +describe('validateTrackSMSCampaignPayload', () => { + // payload with all required fields defined and non-empty does not throw an error + it('should not throw an error when all required fields are defined and non-empty', () => { + const payload = { + body: 'Test message', + name: 'Test Campaign', + list_id: '12345', + from: 'TestSender', + }; + expect(() => validateTrackSMSCampaignPayload(payload)).not.toThrow(); + }); + + // payload with body field missing throws an error + it('should throw an error when body field is missing', () => { + const payload = { + name: 'Test Campaign', + list_id: '12345', + from: 'TestSender', + }; + expect(() => validateTrackSMSCampaignPayload(payload)).toThrow( + 'All of contact list Id, name, body and from are required to trigger an sms campaign', + ); + }); + + it('should throw an error when from field is empty string', () => { + const payload = { + name: 'Test Campaign', + list_id: '12345', + from: '', + body: 'Test message', + }; + expect(() => validateTrackSMSCampaignPayload(payload)).toThrow( + 'All of contact list Id, name, body and from are required to trigger an sms campaign', + ); + }); +}); diff --git a/test/integrations/destinations/clicksend/commonConfig.ts b/test/integrations/destinations/clicksend/commonConfig.ts new file mode 100644 index 0000000000..04c51736f0 --- /dev/null +++ b/test/integrations/destinations/clicksend/commonConfig.ts @@ -0,0 +1,103 @@ +export const destination = { + ID: 'random_id', + Name: 'clicksend', + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + clicksendUsername: 'dummy', + clicksendPassword: 'dummy', + defaultCampaignScheduleUnit: 'day', + defaultCampaignSchedule: '2', + defaultSource: 'php', + defaultSenderEmail: 'abc@gmail.com', + defaultSenderPhoneNumber: '+919XXXXXXXX8', + oneTrustCookieCategories: [ + { + oneTrustCookieCategory: 'Marketing', + }, + ], + }, +}; + +export const metadata = { + destinationId: 'dummyDestId', +}; +export const commonProperties = { + name: 'new campaign', + body: 'abcd', + from: 'abc@gmail.com', + from_email: 'dummy@gmail.com', + custom_string: 'test string', +}; +export const traitsWithIdentifiers = { + firstName: 'John', + lastName: 'Doe', + phone: '+9182XXXX068', + email: 'abc@gmail.com', + address: { city: 'New York', country: 'USA', pinCode: '123456' }, +}; +export const traitsWithoutIdenfiers = { + firstName: 'John', + lastName: 'Doe', + address: { city: 'New York', country: 'USA', pinCode: '123456' }, +}; +export const contextWithoutScheduleAndWithContactId = { + externalId: [{ type: 'CLICKSEND_CONTACT_LIST_ID', id: '123345' }], + traitsWithoutIdenfiers, +}; +export const commonInput = { + anonymousId: 'anon_123', + messageId: 'dummy_msg_id', + contextWithoutScheduleAndWithContactId, + channel: 'web', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', +}; + +export const commonOutput = { + anonymousId: 'anon_123', + messageId: 'dummy_msg_id', + contextWithoutScheduleAndWithContactId, + channel: 'web', + originalTimestamp: '2021-01-25T15:32:56.409Z', +}; + +export const SMS_SEND_ENDPOINT = 'https://rest.clicksend.com/v3/sms/send'; +export const SMS_CAMPAIGN_ENDPOINT = 'https://rest.clicksend.com/v3/sms-campaigns/send'; +export const COMMON_CONTACT_DOMAIN = 'https://rest.clicksend.com/v3/lists'; +export const routerInstrumentationErrorStatTags = { + destType: 'CLICKSEND', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'router', + implementation: 'cdkV2', + module: 'destination', +}; +export const commonIdentifyOutput = { + address_line_1: '{"city":"New York","country":"USA","pinCode":"123456"}', + address_line_2: '{"city":"New York","country":"USA","pinCode":"123456"}', + city: 'New York', + email: 'abc@gmail.com', + first_name: 'John', + last_name: 'Doe', + phone_number: '+9182XXXX068', +}; +export const processInstrumentationErrorStatTags = { + destType: 'CLICKSEND', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + destinationId: 'dummyDestId', +}; + +export const commonHeader = { + Authorization: 'Basic ZHVtbXk6ZHVtbXk=', + 'Content-Type': 'application/json', +}; diff --git a/test/integrations/destinations/clicksend/processor/data.ts b/test/integrations/destinations/clicksend/processor/data.ts new file mode 100644 index 0000000000..42cb70459d --- /dev/null +++ b/test/integrations/destinations/clicksend/processor/data.ts @@ -0,0 +1,3 @@ +import { track } from './track'; +import { identify } from './identify'; +export const data = [...identify, ...track]; diff --git a/test/integrations/destinations/clicksend/processor/identify.ts b/test/integrations/destinations/clicksend/processor/identify.ts new file mode 100644 index 0000000000..231d5e6f1d --- /dev/null +++ b/test/integrations/destinations/clicksend/processor/identify.ts @@ -0,0 +1,224 @@ +import { + destination, + contextWithoutScheduleAndWithContactId, + traitsWithoutIdenfiers, + traitsWithIdentifiers, + commonInput, + metadata, + processInstrumentationErrorStatTags, + commonIdentifyOutput, + commonHeader, + COMMON_CONTACT_DOMAIN, +} from '../commonConfig'; +export const identify = [ + { + id: 'clicksend-test-identify-success-1', + name: 'clicksend', + description: 'identify call without externalId with contact list Id', + scenario: 'Framework+Buisness', + successCriteria: 'Identify call should fail as external ID is mandatory', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'identify', + ...commonInput, + userId: 'sajal12', + traits: traitsWithIdentifiers, + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'externalId does not contain contact list Id of Clicksend. Aborting.: Workflow: procWorkflow, Step: prepareIdentifyPayload, ChildStep: undefined, OriginalError: externalId does not contain contact list Id of Clicksend. Aborting.', + metadata, + statTags: processInstrumentationErrorStatTags, + statusCode: 400, + }, + ], + }, + }, + }, + { + id: 'clicksend-test-identify-success-1', + name: 'clicksend', + description: 'identify call with externalId with contact list Id', + scenario: 'Framework+Buisness', + successCriteria: 'Identify call should be successful', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'identify', + ...commonInput, + context: contextWithoutScheduleAndWithContactId, + userId: 'sajal12', + traits: traitsWithIdentifiers, + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: `${COMMON_CONTACT_DOMAIN}/123345/contacts`, + headers: commonHeader, + params: {}, + body: { + JSON: commonIdentifyOutput, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + metadata, + statusCode: 200, + }, + ], + }, + }, + }, + { + id: 'clicksend-test-identify-success-1', + name: 'clicksend', + description: 'identify call without phone, email or fax number', + scenario: 'Framework+Buisness', + successCriteria: 'Identify call should fail as one of the above identifier is mandatory', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'identify', + ...commonInput, + userId: 'sajal12', + traits: traitsWithoutIdenfiers, + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either phone number or email or fax_number is mandatory for contact creation: Workflow: procWorkflow, Step: prepareIdentifyPayload, ChildStep: undefined, OriginalError: Either phone number or email or fax_number is mandatory for contact creation', + metadata, + statTags: processInstrumentationErrorStatTags, + statusCode: 400, + }, + ], + }, + }, + }, + { + id: 'clicksend-test-identify-success-1', + name: 'clicksend', + description: 'identify call with externalId with contact Id', + scenario: 'Framework+Buisness', + successCriteria: 'Identify call to be made to contact update API', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'identify', + ...commonInput, + context: { + ...contextWithoutScheduleAndWithContactId, + externalId: [ + { type: 'CLICKSEND_CONTACT_LIST_ID', id: '123345' }, + { type: 'CLICKSEND_CONTACT_ID', id: '111' }, + ], + }, + userId: 'sajal12', + traits: traitsWithIdentifiers, + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'PUT', + endpoint: `${COMMON_CONTACT_DOMAIN}/123345/contacts/111`, + headers: commonHeader, + params: {}, + body: { + JSON: { ...commonIdentifyOutput, contact_id: '111' }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + metadata, + statusCode: 200, + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/clicksend/processor/track.ts b/test/integrations/destinations/clicksend/processor/track.ts new file mode 100644 index 0000000000..e4a8c5be97 --- /dev/null +++ b/test/integrations/destinations/clicksend/processor/track.ts @@ -0,0 +1,293 @@ +import { + destination, + commonProperties, + metadata, + contextWithoutScheduleAndWithContactId, + SMS_CAMPAIGN_ENDPOINT, + commonHeader, + processInstrumentationErrorStatTags, + traitsWithoutIdenfiers, + traitsWithIdentifiers, + SMS_SEND_ENDPOINT, +} from '../commonConfig'; +import { transformResultBuilder } from '../../../testUtils'; +export const track = [ + { + id: 'clicksend-test-track-success-1', + name: 'clicksend', + description: + 'Track call containing CLICKSEND_CONTACT_LIST_ID as externalID and all mappings available', + scenario: 'Framework+Buisness', + successCriteria: + 'It will trigger sms campaign for that entire list. Also, scheduling is updated based on configuration', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: contextWithoutScheduleAndWithContactId, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + metadata, + output: transformResultBuilder({ + method: 'POST', + endpoint: SMS_CAMPAIGN_ENDPOINT, + headers: commonHeader, + JSON: { + list_id: 123345, + body: 'abcd', + from: 'abc@gmail.com', + name: 'new campaign', + schedule: 1631201576, + }, + userId: '', + }), + statusCode: 200, + }, + ], + }, + }, + }, + { + id: 'clicksend-test-track-success-2', + name: 'clicksend', + description: + 'Track call containing CLICKSEND_CONTACT_LIST_ID as externalID and one of mandatory fields absent', + scenario: 'Framework+Buisness', + successCriteria: + 'as list Id, name, body and from fields are required ones to trigger event, hence it will fail', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: contextWithoutScheduleAndWithContactId, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: { ...commonProperties, name: '' }, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'All of contact list Id, name, body and from are required to trigger an sms campaign: Workflow: procWorkflow, Step: prepareTrackPayload, ChildStep: sendSmsCampaignPayload, OriginalError: All of contact list Id, name, body and from are required to trigger an sms campaign', + metadata, + statTags: processInstrumentationErrorStatTags, + statusCode: 400, + }, + ], + }, + }, + }, + { + id: 'clicksend-test-track-success-3', + name: 'clicksend', + description: + 'Track call containing CLICKSEND_CONTACT_LIST_ID as externalID and list ID is sent as a boolean', + scenario: 'Framework+Buisness', + successCriteria: 'It should fail, as list Id must be an integer', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: { + ...contextWithoutScheduleAndWithContactId, + externalId: [{ type: 'CLICKSEND_CONTACT_LIST_ID', id: true }], + }, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'list_id must be an integer: Workflow: procWorkflow, Step: prepareTrackPayload, ChildStep: sendSmsCampaignPayload, OriginalError: list_id must be an integer', + metadata, + statTags: processInstrumentationErrorStatTags, + statusCode: 400, + }, + ], + }, + }, + }, + { + id: 'clicksend-test-track-success-4', + name: 'clicksend', + description: + 'Track call not containing CLICKSEND_CONTACT_LIST_ID as externalID and all mappings available', + scenario: 'Framework+Buisness', + successCriteria: + 'It will trigger sms send call for that phone number. Also, scheduling is updated based on configuration', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: { + traits: traitsWithIdentifiers, + }, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + metadata, + output: transformResultBuilder({ + method: 'POST', + endpoint: SMS_SEND_ENDPOINT, + headers: commonHeader, + JSON: { + email: 'abc@gmail.com', + body: 'abcd', + from: 'abc@gmail.com', + from_email: 'dummy@gmail.com', + custom_string: 'test string', + schedule: 1631201576, + source: 'php', + to: '+9182XXXX068', + }, + userId: '', + }), + statusCode: 200, + }, + ], + }, + }, + }, + { + id: 'clicksend-test-track-success-5', + name: 'clicksend', + description: + 'Track call not containing CLICKSEND_CONTACT_LIST_ID as externalID and mandatory identifiers missing', + scenario: 'Framework+Buisness', + successCriteria: 'It will not trigger sms send call and fail with error', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: { + traits: traitsWithoutIdenfiers, + }, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'all of sender email, phone and body needs to be present for track call: Workflow: procWorkflow, Step: prepareTrackPayload, ChildStep: sendSmsCampaignPayload, OriginalError: all of sender email, phone and body needs to be present for track call', + metadata, + statTags: processInstrumentationErrorStatTags, + statusCode: 400, + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/clicksend/router/basicProperties.ts b/test/integrations/destinations/clicksend/router/basicProperties.ts new file mode 100644 index 0000000000..5725f3d445 --- /dev/null +++ b/test/integrations/destinations/clicksend/router/basicProperties.ts @@ -0,0 +1,33 @@ +export const trackProperties = { + index: 'products', + queryId: '43b15df305339e827f0ac0bdc5ebcaa7', + products: [ + { objectId: 'ecommerce-sample-data-919', position: 7 }, + { objectId: '9780439784542', position: 8 }, + ], +}; + +export const pageProperties = { + title: 'Sample Page', + url: 'https://example.com/?utm_campaign=example_campaign&utm_content=example_content', + path: '/', + hash: '', + search: '?utm_campaign=example_campaign&utm_content=example_content', + width: '1920', + height: '1080', + query: { + utm_campaign: 'example_campaign', + utm_content: 'example_content', + }, + referrer: '', +}; + +export const traits = { + email: 'test@user.com', + firstname: 'John', + lastname: 'Doe', + phone: '+1(123)456-7890', + gender: 'Male', + birthday: '1980-01-02', + city: 'San Francisco', +}; diff --git a/test/integrations/destinations/clicksend/router/data.ts b/test/integrations/destinations/clicksend/router/data.ts new file mode 100644 index 0000000000..b8b6c49b90 --- /dev/null +++ b/test/integrations/destinations/clicksend/router/data.ts @@ -0,0 +1,485 @@ +import { + commonInput, + destination, + routerInstrumentationErrorStatTags, + contextWithoutScheduleAndWithContactId, + commonProperties, + traitsWithIdentifiers, +} from '../commonConfig'; + +const commonDestination = { + ID: 'random_id', + Name: 'clicksend', + Config: { + clicksendPassword: 'dummy', + clicksendUsername: 'dummy', + defaultCampaignSchedule: '2', + defaultCampaignScheduleUnit: 'day', + defaultSenderEmail: 'abc@gmail.com', + defaultSenderPhoneNumber: '+919XXXXXXXX8', + defaultSource: 'php', + oneTrustCookieCategories: [ + { + oneTrustCookieCategory: 'Marketing', + }, + ], + }, + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, +}; + +export const data = [ + { + name: 'clicksend', + id: 'Test 0 - router', + description: 'Batch calls with all three type of calls as success', + scenario: 'FrameworkBuisness', + successCriteria: + 'All events should be transformed successfully but should not be under same batch and status code should be 200', + feature: 'router', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + input: [ + { + destination, + message: { + context: contextWithoutScheduleAndWithContactId, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata: { jobId: 1, userId: 'u1' }, + }, + { + destination, + message: { + context: { + traits: traitsWithIdentifiers, + }, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata: { jobId: 2, userId: 'u2' }, + }, + { + destination, + message: { + type: 'identify', + ...commonInput, + context: { + ...contextWithoutScheduleAndWithContactId, + externalId: [ + { type: 'CLICKSEND_CONTACT_LIST_ID', id: '123345' }, + { type: 'CLICKSEND_CONTACT_ID', id: '111' }, + ], + }, + userId: 'sajal12', + traits: traitsWithIdentifiers, + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata: { jobId: 3, userId: 'u3' }, + }, + ], + destType: 'clicksend', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + batched: false, + batchedRequest: { + body: { + FORM: {}, + JSON: { + body: 'abcd', + from: 'abc@gmail.com', + list_id: 123345, + name: 'new campaign', + schedule: 1631201576, + }, + JSON_ARRAY: {}, + XML: {}, + }, + endpoint: 'https://rest.clicksend.com/v3/sms-campaigns/send', + files: {}, + headers: { + Authorization: 'Basic ZHVtbXk6ZHVtbXk=', + 'Content-Type': 'application/json', + }, + method: 'POST', + params: {}, + type: 'REST', + version: '1', + }, + metadata: [ + { + jobId: 1, + + userId: 'u1', + }, + ], + destination: commonDestination, + statusCode: 200, + }, + { + batched: true, + batchedRequest: { + body: { + FORM: {}, + JSON: { + messages: [ + { + body: 'abcd', + custom_string: 'test string', + email: 'abc@gmail.com', + from: 'abc@gmail.com', + from_email: 'dummy@gmail.com', + schedule: 1631201576, + source: 'php', + to: '+9182XXXX068', + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + }, + endpoint: 'https://rest.clicksend.com/v3/sms/send', + files: {}, + headers: { + Authorization: 'Basic ZHVtbXk6ZHVtbXk=', + 'Content-Type': 'application/json', + }, + method: 'POST', + params: {}, + type: 'REST', + version: '1', + }, + metadata: [ + { + jobId: 2, + + userId: 'u2', + }, + ], + destination: commonDestination, + statusCode: 200, + }, + { + batched: false, + batchedRequest: { + body: { + FORM: {}, + JSON: { + address_line_1: '{"city":"New York","country":"USA","pinCode":"123456"}', + address_line_2: '{"city":"New York","country":"USA","pinCode":"123456"}', + city: 'New York', + contact_id: '111', + email: 'abc@gmail.com', + first_name: 'John', + last_name: 'Doe', + phone_number: '+9182XXXX068', + }, + JSON_ARRAY: {}, + XML: {}, + }, + endpoint: 'https://rest.clicksend.com/v3/lists/123345/contacts/111', + files: {}, + headers: { + Authorization: 'Basic ZHVtbXk6ZHVtbXk=', + 'Content-Type': 'application/json', + }, + method: 'PUT', + params: {}, + type: 'REST', + version: '1', + }, + destination: commonDestination, + metadata: [ + { + jobId: 3, + + userId: 'u3', + }, + ], + statusCode: 200, + }, + ], + }, + }, + }, + }, + { + name: 'clicksend', + id: 'Test 0 - router', + description: 'Batch calls with all five type of calls as two successful and one failure', + scenario: 'FrameworkBuisness', + successCriteria: + 'All events should be transformed successfully but should not be under same batch and status code should be 200', + feature: 'router', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + input: [ + { + destination, + message: { + context: contextWithoutScheduleAndWithContactId, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata: { jobId: 1, userId: 'u1' }, + }, + { + destination, + message: { + context: { + traits: traitsWithIdentifiers, + }, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata: { jobId: 2, userId: 'u2' }, + }, + { + destination, + message: { + type: 'identify', + ...commonInput, + context: { + ...contextWithoutScheduleAndWithContactId, + externalId: [{ type: 'CLICKSEND_CONTACT_ID', id: '111' }], + }, + userId: 'sajal12', + traits: traitsWithIdentifiers, + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata: { jobId: 3, userId: 'u3' }, + }, + { + destination, + message: { + context: { + traits: traitsWithIdentifiers, + }, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata: { jobId: 4, userId: 'u4' }, + }, + { + destination, + message: { + context: { + traits: traitsWithIdentifiers, + }, + type: 'track', + event: 'product purchased', + userId: 'sajal12', + channel: 'mobile', + messageId: 'dummy_msg_id', + properties: commonProperties, + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2021-01-25T15:32:56.409Z', + }, + metadata: { jobId: 5, userId: 'u5' }, + }, + ], + destType: 'clicksend', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + batched: false, + destination, + error: 'externalId does not contain contact list Id of Clicksend. Aborting.', + metadata: [{ jobId: 3, userId: 'u3' }], + statTags: routerInstrumentationErrorStatTags, + statusCode: 400, + }, + { + batched: false, + batchedRequest: { + body: { + FORM: {}, + JSON: { + body: 'abcd', + from: 'abc@gmail.com', + list_id: 123345, + name: 'new campaign', + schedule: 1631201576, + }, + JSON_ARRAY: {}, + XML: {}, + }, + endpoint: 'https://rest.clicksend.com/v3/sms-campaigns/send', + files: {}, + headers: { + Authorization: 'Basic ZHVtbXk6ZHVtbXk=', + 'Content-Type': 'application/json', + }, + method: 'POST', + params: {}, + type: 'REST', + version: '1', + }, + metadata: [ + { + jobId: 1, + + userId: 'u1', + }, + ], + destination: commonDestination, + statusCode: 200, + }, + { + batched: true, + batchedRequest: { + body: { + FORM: {}, + JSON: { + messages: [ + { + body: 'abcd', + custom_string: 'test string', + email: 'abc@gmail.com', + from: 'abc@gmail.com', + from_email: 'dummy@gmail.com', + schedule: 1631201576, + source: 'php', + to: '+9182XXXX068', + }, + { + body: 'abcd', + custom_string: 'test string', + email: 'abc@gmail.com', + from: 'abc@gmail.com', + from_email: 'dummy@gmail.com', + schedule: 1631201576, + source: 'php', + to: '+9182XXXX068', + }, + { + body: 'abcd', + custom_string: 'test string', + email: 'abc@gmail.com', + from: 'abc@gmail.com', + from_email: 'dummy@gmail.com', + schedule: 1631201576, + source: 'php', + to: '+9182XXXX068', + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + }, + endpoint: 'https://rest.clicksend.com/v3/sms/send', + files: {}, + headers: { + Authorization: 'Basic ZHVtbXk6ZHVtbXk=', + 'Content-Type': 'application/json', + }, + method: 'POST', + params: {}, + type: 'REST', + version: '1', + }, + metadata: [ + { + jobId: 2, + + userId: 'u2', + }, + { + jobId: 4, + + userId: 'u4', + }, + { + jobId: 5, + + userId: 'u5', + }, + ], + destination: commonDestination, + statusCode: 200, + }, + ], + }, + }, + }, + }, +];