@capillarytech/creatives-library 7.14.30 → 7.14.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.14.30",
4
+ "version": "7.14.31",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -477,10 +477,10 @@ export const checkBulkDuplicates = (data) => {
477
477
  return request(url, getAPICallObject('POST', data));
478
478
  };
479
479
 
480
- export const createWhatsappTemplate = ({gupshupMediaFile, payload }) => {
480
+ export const createWhatsappTemplate = ({payload, gupshupMediaFile }) => {
481
481
  const data = new FormData();
482
- data.append('gupshupMediaFile', gupshupMediaFile);
483
482
  data.append('payload', JSON.stringify(payload));
483
+ data.append('gupshupMediaFile', gupshupMediaFile);
484
484
  const url = `${API_ENDPOINT}/templates/WHATSAPP`;
485
485
  return request(url, getAPICallObject('POST', data, true));
486
486
  };
@@ -4,6 +4,7 @@ import {
4
4
  getCdnTransformationConfig,
5
5
  createWhatsappTemplate
6
6
  } from '../api';
7
+ import { mockData } from './mockData';
7
8
  const sampleFile = require('../../assets/line.png');
8
9
 
9
10
  describe('getSenderDetails -- Test with valid responses', () => {
@@ -40,49 +41,6 @@ describe('uploadFile -- whatsapp image upload', () => {
40
41
  describe('createWhatsappTemplate -- Test with valid responses', () => {
41
42
  it('Should return correct response', () =>
42
43
  expect(
43
- createWhatsappTemplate(sampleFile, {
44
- name: 'mar_15_10_9',
45
- versions: {
46
- base: {
47
- content: {
48
- whatsapp: {
49
- category: 'TRANSACTIONAL',
50
- languages: [
51
- {
52
- language: 'en',
53
- content:
54
- 'Hey {{1}}, your appointment for {{2}} is confirmed.\nClick {{3}} to unsubscribe',
55
- },
56
- ],
57
- buttonType: 'CTA',
58
- buttons: [
59
- {
60
- index: 0,
61
- type: 'PHONE_NUMBER',
62
- text: 'call',
63
- phone_number: '+919738751234',
64
- },
65
- {
66
- index: 1,
67
- type: 'DYNAMIC_URL',
68
- text: 'info',
69
- url: 'https://github.com/Capillary/{{1}}',
70
- },
71
- ],
72
- mediaType: 'IMAGE',
73
- imageUrl:
74
- 'https://storage.crm.n.content-cdn.io/cdn-cgi/image/quality=70,/intouch_creative_assets/7e167b76-7276-4de3-a767-3d1ae9ae.jpg',
75
- karixFileHandle: '',
76
- varMapped: {},
77
- templateEditor: false,
78
- accountId: '2000222347',
79
- accessToken: 'DTpZEh4VK',
80
- hostName: 'gupshupwhatsappbulk',
81
- },
82
- },
83
- },
84
- },
85
- type: 'WHATSAPP',
86
- }),
44
+ createWhatsappTemplate(sampleFile, mockData.createWhatsappPayload),
87
45
  ).toEqual(Promise.resolve()));
88
46
  });
@@ -0,0 +1,46 @@
1
+ export const mockData = {
2
+ createWhatsappPayload: {
3
+ name: 'mar_15_10_9',
4
+ versions: {
5
+ base: {
6
+ content: {
7
+ whatsapp: {
8
+ category: 'TRANSACTIONAL',
9
+ languages: [
10
+ {
11
+ language: 'en',
12
+ content:
13
+ 'Hey {{1}}, your appointment for {{2}} is confirmed.\nClick {{3}} to unsubscribe',
14
+ },
15
+ ],
16
+ buttonType: 'CTA',
17
+ buttons: [
18
+ {
19
+ index: 0,
20
+ type: 'PHONE_NUMBER',
21
+ text: 'call',
22
+ phone_number: '+919738751234',
23
+ },
24
+ {
25
+ index: 1,
26
+ type: 'DYNAMIC_URL',
27
+ text: 'info',
28
+ url: 'https://github.com/Capillary/{{1}}',
29
+ },
30
+ ],
31
+ mediaType: 'IMAGE',
32
+ imageUrl:
33
+ 'https://storage.crm.n.content-cdn.io/cdn-cgi/image/quality=70,/intouch_creative_assets/7e167b76-7276-4de3-a767-3d1ae9ae.jpg',
34
+ karixFileHandle: '',
35
+ varMapped: {},
36
+ templateEditor: false,
37
+ accountId: '2000222347',
38
+ accessToken: 'DTpZEh4VK',
39
+ hostName: 'gupshupwhatsappbulk',
40
+ },
41
+ },
42
+ },
43
+ },
44
+ type: 'WHATSAPP',
45
+ },
46
+ };
@@ -8,12 +8,12 @@ import {
8
8
  CLEAR_WHATSAPP_ASSET,
9
9
  } from './constants';
10
10
 
11
- export function createWhatsappTemplate(gupshupMediaFile, payload, callback) {
11
+ export function createWhatsappTemplate(payload, callback, gupshupMediaFile) {
12
12
  return {
13
13
  type: TEMPLATE_CREATE_REQUEST,
14
- gupshupMediaFile,
15
14
  payload,
16
15
  callback,
16
+ gupshupMediaFile,
17
17
  };
18
18
  }
19
19
  export function clearCreateResponse() {
@@ -60,6 +60,7 @@ import {
60
60
  WHATSAPP_IMG_SIZE,
61
61
  HOST_TWILIO,
62
62
  HOST_KARIX,
63
+ HOST_GUPSHUP,
63
64
  ALLOWED_EXTENSIONS_VIDEO_REGEX,
64
65
  ALLOWED_EXTENSIONS_DOCUMENT_REGEX,
65
66
  WHATSAPP_DOCUMENT_SIZE,
@@ -715,7 +716,7 @@ export const Whatsapp = (props) => {
715
716
  accessToken,
716
717
  hostName: host,
717
718
  };
718
- if (isFullMode && !isEditFlow && host !== HOST_KARIX) {
719
+ if (isFullMode && !isEditFlow && host === HOST_GUPSHUP) {
719
720
  setGupshupMediaFile(file);
720
721
  }
721
722
  actions.uploadWhatsappAsset(file, type, fileParams, 0, whatsappParams);
@@ -1035,14 +1036,14 @@ export const Whatsapp = (props) => {
1035
1036
 
1036
1037
  const createApprovalHandler = () => {
1037
1038
  setSpin(true);
1038
- actions.createWhatsappTemplate(gupshupMediaFile, createPayload(), (resp, errorMessage) => {
1039
+ actions.createWhatsappTemplate(createPayload(), (resp, errorMessage) => {
1039
1040
  actionCallback({ resp, errorMessage });
1040
1041
  if (!errorMessage) {
1041
1042
  onCreateComplete();
1042
1043
  } else {
1043
1044
  setSpin(false);
1044
1045
  }
1045
- });
1046
+ }, gupshupMediaFile);
1046
1047
  };
1047
1048
 
1048
1049
  const onDoneCallback = () => {
@@ -36,10 +36,10 @@ function* watchUploadWhatsappAsset() {
36
36
  yield cancel(watcher);
37
37
  }
38
38
 
39
- export function* sendForApprovalCreate({ gupshupMediaFile, payload, callback }) {
39
+ export function* sendForApprovalCreate({ payload, callback, gupshupMediaFile }) {
40
40
  let errorMsg;
41
41
  try {
42
- const result = yield call(Api.createWhatsappTemplate, { gupshupMediaFile, payload });
42
+ const result = yield call(Api.createWhatsappTemplate, { payload, gupshupMediaFile });
43
43
  if (result?.status?.code && result.status.code >= 400) {
44
44
  errorMsg = result?.message || result.status.code;
45
45
  throw errorMsg;
@@ -411621,7 +411621,6 @@ exports[`Creatives Whatsapp test2/> set all valid values and send for approval 2
411621
411621
  "createWhatsappTemplate": [MockFunction] {
411622
411622
  "calls": Array [
411623
411623
  Array [
411624
- undefined,
411625
411624
  Object {
411626
411625
  "name": "template_name",
411627
411626
  "type": "WHATSAPP",
@@ -411658,6 +411657,7 @@ undefined",
411658
411657
  },
411659
411658
  },
411660
411659
  [Function],
411660
+ undefined,
411661
411661
  ],
411662
411662
  ],
411663
411663
  "results": Array [
@@ -431197,7 +431197,6 @@ exports[`Creatives Whatsapp test2/> set all valid values and send for approval 3
431197
431197
  "createWhatsappTemplate": [MockFunction] {
431198
431198
  "calls": Array [
431199
431199
  Array [
431200
- undefined,
431201
431200
  Object {
431202
431201
  "name": "template_name",
431203
431202
  "type": "WHATSAPP",
@@ -431240,6 +431239,7 @@ undefined",
431240
431239
  },
431241
431240
  },
431242
431241
  [Function],
431242
+ undefined,
431243
431243
  ],
431244
431244
  ],
431245
431245
  "results": Array [
@@ -30,12 +30,12 @@ describe('Test whatsapp actions', () => {
30
30
  };
31
31
  const expected = {
32
32
  type: types.TEMPLATE_CREATE_REQUEST,
33
- gupshupMediaFile: undefined,
34
33
  payload,
35
34
  callback: undefined,
35
+ gupshupMediaFile: undefined,
36
36
  };
37
37
  expect(
38
- actions.createWhatsappTemplate(undefined, payload, undefined),
38
+ actions.createWhatsappTemplate(payload, undefined, undefined),
39
39
  ).toStrictEqual(expected);
40
40
  });
41
41
  });
@@ -309,7 +309,7 @@ describe('Creatives Whatsapp test2/>', () => {
309
309
  constants.INITIAL_CTA_DATA = [];
310
310
  renderHelper({});
311
311
  let event = { target: { value: 'template_name' } };
312
- createWhatsappTemplate.mockImplementation((undefined, obj, callback) => {
312
+ createWhatsappTemplate.mockImplementation((obj, callback, undefined) => {
313
313
  callback();
314
314
  });
315
315
 
@@ -359,7 +359,7 @@ describe('Creatives Whatsapp test2/>', () => {
359
359
  ];
360
360
  renderHelper({});
361
361
  let event = { target: { value: 'template_name' } };
362
- createWhatsappTemplate.mockImplementation((undefined, obj, callback) => {
362
+ createWhatsappTemplate.mockImplementation((obj, callback, undefined) => {
363
363
  callback();
364
364
  });
365
365
 
@@ -419,7 +419,7 @@ describe('Creatives Whatsapp test2/>', () => {
419
419
  ];
420
420
  renderHelper({});
421
421
  let event = { target: { value: 'template_name' } };
422
- createWhatsappTemplate.mockImplementation((undefined, obj, callback) => {
422
+ createWhatsappTemplate.mockImplementation((obj, callback, undefined) => {
423
423
  callback();
424
424
  });
425
425