|
1 | 1 | import { RequestClient, PayloadValidationError } from '@segment/actions-core'
|
2 | 2 |
|
3 | 3 | import { Settings, AudienceSettings } from '../generated-types'
|
4 |
| -import { Unsubscriber, Subscriber } from '../types' |
| 4 | +import { Unsubscriber, Subscriber, IterableSubscribePayload, IterableUnsubscribePayload } from '../types' |
5 | 5 | import { Payload } from './generated-types'
|
6 | 6 |
|
7 | 7 | import { CONSTANTS } from '../constants'
|
@@ -65,30 +65,32 @@ export class IterableListsClient {
|
65 | 65 | const unSubcribeRequests = []
|
66 | 66 |
|
67 | 67 | subscribersGroup.forEach((subscribers, listId) => {
|
| 68 | + const json: IterableSubscribePayload = { |
| 69 | + listId: Number(listId), |
| 70 | + subscribers, |
| 71 | + updateExistingUsersOnly: this.updateExistingUsersOnly |
| 72 | + } |
68 | 73 | subcribeRequests.push(
|
69 | 74 | this.request(`${CONSTANTS.API_BASE_URL}/lists/subscribe`, {
|
70 | 75 | method: 'post',
|
71 | 76 | skipResponseCloning: true,
|
72 |
| - json: { |
73 |
| - listId: Number(listId), |
74 |
| - subscribers, |
75 |
| - updateExistingUsersOnly: this.updateExistingUsersOnly |
76 |
| - } |
| 77 | + json |
77 | 78 | })
|
78 | 79 | )
|
79 | 80 | })
|
80 | 81 |
|
81 | 82 | unsubscribersGroup.forEach((subscribers, listId) => {
|
| 83 | + const json: IterableUnsubscribePayload = { |
| 84 | + listId: Number(listId), |
| 85 | + subscribers, |
| 86 | + campaignId: typeof this.campaignId === 'number' ? this.campaignId : undefined, |
| 87 | + channelUnsubscribe: this.globalUnsubscribe |
| 88 | + } |
82 | 89 | unSubcribeRequests.push(
|
83 | 90 | this.request(`${CONSTANTS.API_BASE_URL}/lists/unsubscribe`, {
|
84 | 91 | method: 'post',
|
85 | 92 | skipResponseCloning: true,
|
86 |
| - json: { |
87 |
| - listId: Number(listId), |
88 |
| - subscribers, |
89 |
| - campaignId: typeof this.campaignId === 'number' ? this.campaignId : undefined, |
90 |
| - channelUnsubscribe: this.updateExistingUsersOnly |
91 |
| - } |
| 93 | + json |
92 | 94 | })
|
93 | 95 | )
|
94 | 96 | })
|
|
0 commit comments