@unboundcx/sdk 2.6.10 → 2.6.12
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 +1 -1
- package/services/messaging.js +302 -10
- package/services/objects.js +168 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.12",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
package/services/messaging.js
CHANGED
|
@@ -13,6 +13,18 @@ export class SmsService {
|
|
|
13
13
|
this.templates = new SmsTemplatesService(sdk);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Send an SMS/MMS message
|
|
18
|
+
* @param {Object} params - Message parameters
|
|
19
|
+
* @param {string} params.to - Recipient phone number (required)
|
|
20
|
+
* @param {string} [params.from] - Sender phone number
|
|
21
|
+
* @param {string} [params.message] - Message text
|
|
22
|
+
* @param {string} [params.templateId] - Template ID to use
|
|
23
|
+
* @param {Object} [params.variables] - Template variables
|
|
24
|
+
* @param {Array<string>} [params.mediaUrls] - Media URLs for MMS
|
|
25
|
+
* @param {string} [params.webhookUrl] - Webhook URL for delivery status
|
|
26
|
+
* @returns {Promise<Object>} Message details
|
|
27
|
+
*/
|
|
16
28
|
async send({
|
|
17
29
|
from,
|
|
18
30
|
to,
|
|
@@ -51,6 +63,11 @@ export class SmsService {
|
|
|
51
63
|
return result;
|
|
52
64
|
}
|
|
53
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Get SMS/MMS message by ID
|
|
68
|
+
* @param {string} id - Message ID
|
|
69
|
+
* @returns {Promise<Object>} Message details
|
|
70
|
+
*/
|
|
54
71
|
async get(id) {
|
|
55
72
|
this.sdk.validateParams(
|
|
56
73
|
{ id },
|
|
@@ -69,6 +86,14 @@ export class SmsTemplatesService {
|
|
|
69
86
|
this.sdk = sdk;
|
|
70
87
|
}
|
|
71
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Create SMS template
|
|
91
|
+
* @param {Object} params - Template parameters
|
|
92
|
+
* @param {string} params.name - Template name (required)
|
|
93
|
+
* @param {string} params.message - Template message (required)
|
|
94
|
+
* @param {Object} [params.variables] - Template variables
|
|
95
|
+
* @returns {Promise<Object>} Created template details
|
|
96
|
+
*/
|
|
72
97
|
async create({ name, message, variables }) {
|
|
73
98
|
this.sdk.validateParams(
|
|
74
99
|
{ name, message },
|
|
@@ -94,6 +119,15 @@ export class SmsTemplatesService {
|
|
|
94
119
|
return result;
|
|
95
120
|
}
|
|
96
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Update SMS template
|
|
124
|
+
* @param {string} id - Template ID
|
|
125
|
+
* @param {Object} params - Update parameters
|
|
126
|
+
* @param {string} [params.name] - Template name
|
|
127
|
+
* @param {string} [params.message] - Template message
|
|
128
|
+
* @param {Object} [params.variables] - Template variables
|
|
129
|
+
* @returns {Promise<Object>} Updated template details
|
|
130
|
+
*/
|
|
97
131
|
async update(id, { name, message, variables }) {
|
|
98
132
|
this.sdk.validateParams(
|
|
99
133
|
{ id },
|
|
@@ -122,6 +156,11 @@ export class SmsTemplatesService {
|
|
|
122
156
|
return result;
|
|
123
157
|
}
|
|
124
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Delete SMS template
|
|
161
|
+
* @param {string} id - Template ID
|
|
162
|
+
* @returns {Promise<Object>} Deletion result
|
|
163
|
+
*/
|
|
125
164
|
async delete(id) {
|
|
126
165
|
this.sdk.validateParams(
|
|
127
166
|
{ id },
|
|
@@ -137,6 +176,11 @@ export class SmsTemplatesService {
|
|
|
137
176
|
return result;
|
|
138
177
|
}
|
|
139
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Get SMS template by ID
|
|
181
|
+
* @param {string} id - Template ID
|
|
182
|
+
* @returns {Promise<Object>} Template details
|
|
183
|
+
*/
|
|
140
184
|
async get(id) {
|
|
141
185
|
this.sdk.validateParams(
|
|
142
186
|
{ id },
|
|
@@ -152,6 +196,10 @@ export class SmsTemplatesService {
|
|
|
152
196
|
return result;
|
|
153
197
|
}
|
|
154
198
|
|
|
199
|
+
/**
|
|
200
|
+
* List all SMS templates
|
|
201
|
+
* @returns {Promise<Array>} List of templates
|
|
202
|
+
*/
|
|
155
203
|
async list() {
|
|
156
204
|
const result = await this.sdk._fetch('/messaging/sms/templates', 'GET');
|
|
157
205
|
return result;
|
|
@@ -542,6 +590,19 @@ export class TollFreeCampaignsService {
|
|
|
542
590
|
this.sdk = sdk;
|
|
543
591
|
}
|
|
544
592
|
|
|
593
|
+
/**
|
|
594
|
+
* Create toll-free campaign
|
|
595
|
+
* @param {Object} params - Campaign parameters
|
|
596
|
+
* @param {string} params.companyName - Company name (required)
|
|
597
|
+
* @param {string} params.phoneNumber - Phone number (required)
|
|
598
|
+
* @param {string} params.description - Campaign description (required)
|
|
599
|
+
* @param {string} params.messageFlow - Message flow description (required)
|
|
600
|
+
* @param {string} [params.helpMessage] - Help message
|
|
601
|
+
* @param {Array<string>} [params.optInKeywords] - Opt-in keywords
|
|
602
|
+
* @param {Array<string>} [params.optOutKeywords] - Opt-out keywords
|
|
603
|
+
* @param {string} [params.website] - Business website
|
|
604
|
+
* @returns {Promise<Object>} Created campaign details
|
|
605
|
+
*/
|
|
545
606
|
async create({
|
|
546
607
|
companyName,
|
|
547
608
|
phoneNumber,
|
|
@@ -590,15 +651,127 @@ export class TollFreeCampaignsService {
|
|
|
590
651
|
return result;
|
|
591
652
|
}
|
|
592
653
|
|
|
593
|
-
|
|
654
|
+
/**
|
|
655
|
+
* Get toll-free campaign by ID
|
|
656
|
+
* @param {string} campaignId - Campaign ID
|
|
657
|
+
* @returns {Promise<Object>} Campaign details
|
|
658
|
+
*/
|
|
659
|
+
async get(campaignId) {
|
|
594
660
|
this.sdk.validateParams(
|
|
595
|
-
{ campaignId
|
|
661
|
+
{ campaignId },
|
|
596
662
|
{
|
|
597
663
|
campaignId: { type: 'string', required: true },
|
|
598
|
-
updateData: { type: 'object', required: true },
|
|
599
664
|
},
|
|
600
665
|
);
|
|
601
666
|
|
|
667
|
+
const result = await this.sdk._fetch(
|
|
668
|
+
`/messaging/campaigns/tollfree/${campaignId}`,
|
|
669
|
+
'GET',
|
|
670
|
+
);
|
|
671
|
+
return result;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Update toll-free campaign
|
|
676
|
+
* @param {string} campaignId - Campaign ID to update
|
|
677
|
+
* @param {Object} params - Update parameters
|
|
678
|
+
* @param {string} [params.name] - Campaign name
|
|
679
|
+
* @param {string} [params.campaignDescription] - Campaign description
|
|
680
|
+
* @param {string} [params.address1] - Business address line 1
|
|
681
|
+
* @param {string} [params.address2] - Business address line 2
|
|
682
|
+
* @param {string} [params.city] - Business city
|
|
683
|
+
* @param {string} [params.state] - Business state
|
|
684
|
+
* @param {string} [params.zip] - Business zip code
|
|
685
|
+
* @param {string} [params.pocFirstName] - Point of contact first name
|
|
686
|
+
* @param {string} [params.pocLastName] - Point of contact last name
|
|
687
|
+
* @param {string} [params.pocPhoneNumber] - Point of contact phone
|
|
688
|
+
* @param {string} [params.pocEmail] - Point of contact email
|
|
689
|
+
* @param {string} [params.businessName] - Business name
|
|
690
|
+
* @param {string} [params.website] - Business website
|
|
691
|
+
* @param {string} [params.messageVolume] - Expected message volume
|
|
692
|
+
* @param {string} [params.optInWorkflow] - Opt-in workflow description
|
|
693
|
+
* @param {Array<string>} [params.optInWorkflowUrls] - Opt-in workflow image URLs
|
|
694
|
+
* @param {Array<string>} [params.phoneNumbers] - Phone numbers for campaign
|
|
695
|
+
* @param {string} [params.productionMessageExample] - Production message example
|
|
696
|
+
* @param {string} [params.useCase] - Use case category
|
|
697
|
+
* @param {string} [params.useCaseDescription] - Use case description
|
|
698
|
+
* @param {string} [params.webhookUrl] - Webhook URL
|
|
699
|
+
* @returns {Promise<Object>} Updated campaign information
|
|
700
|
+
*/
|
|
701
|
+
async update(campaignId, {
|
|
702
|
+
name,
|
|
703
|
+
campaignDescription,
|
|
704
|
+
address1,
|
|
705
|
+
address2,
|
|
706
|
+
city,
|
|
707
|
+
state,
|
|
708
|
+
zip,
|
|
709
|
+
pocFirstName,
|
|
710
|
+
pocLastName,
|
|
711
|
+
pocPhoneNumber,
|
|
712
|
+
pocEmail,
|
|
713
|
+
businessName,
|
|
714
|
+
website,
|
|
715
|
+
messageVolume,
|
|
716
|
+
optInWorkflow,
|
|
717
|
+
optInWorkflowUrls,
|
|
718
|
+
phoneNumbers,
|
|
719
|
+
productionMessageExample,
|
|
720
|
+
useCase,
|
|
721
|
+
useCaseDescription,
|
|
722
|
+
webhookUrl,
|
|
723
|
+
} = {}) {
|
|
724
|
+
this.sdk.validateParams(
|
|
725
|
+
{ campaignId, name, campaignDescription, address1, address2, city, state, zip, pocFirstName, pocLastName, pocPhoneNumber, pocEmail, businessName, website, messageVolume, optInWorkflow, optInWorkflowUrls, phoneNumbers, productionMessageExample, useCase, useCaseDescription, webhookUrl },
|
|
726
|
+
{
|
|
727
|
+
campaignId: { type: 'string', required: true },
|
|
728
|
+
name: { type: 'string', required: false },
|
|
729
|
+
campaignDescription: { type: 'string', required: false },
|
|
730
|
+
address1: { type: 'string', required: false },
|
|
731
|
+
address2: { type: 'string', required: false },
|
|
732
|
+
city: { type: 'string', required: false },
|
|
733
|
+
state: { type: 'string', required: false },
|
|
734
|
+
zip: { type: 'string', required: false },
|
|
735
|
+
pocFirstName: { type: 'string', required: false },
|
|
736
|
+
pocLastName: { type: 'string', required: false },
|
|
737
|
+
pocPhoneNumber: { type: 'string', required: false },
|
|
738
|
+
pocEmail: { type: 'string', required: false },
|
|
739
|
+
businessName: { type: 'string', required: false },
|
|
740
|
+
website: { type: 'string', required: false },
|
|
741
|
+
messageVolume: { type: 'string', required: false },
|
|
742
|
+
optInWorkflow: { type: 'string', required: false },
|
|
743
|
+
optInWorkflowUrls: { type: 'array', required: false },
|
|
744
|
+
phoneNumbers: { type: 'array', required: false },
|
|
745
|
+
productionMessageExample: { type: 'string', required: false },
|
|
746
|
+
useCase: { type: 'string', required: false },
|
|
747
|
+
useCaseDescription: { type: 'string', required: false },
|
|
748
|
+
webhookUrl: { type: 'string', required: false },
|
|
749
|
+
},
|
|
750
|
+
);
|
|
751
|
+
|
|
752
|
+
const updateData = {};
|
|
753
|
+
if (name !== undefined) updateData.name = name;
|
|
754
|
+
if (campaignDescription !== undefined) updateData.campaignDescription = campaignDescription;
|
|
755
|
+
if (address1 !== undefined) updateData.address1 = address1;
|
|
756
|
+
if (address2 !== undefined) updateData.address2 = address2;
|
|
757
|
+
if (city !== undefined) updateData.city = city;
|
|
758
|
+
if (state !== undefined) updateData.state = state;
|
|
759
|
+
if (zip !== undefined) updateData.zip = zip;
|
|
760
|
+
if (pocFirstName !== undefined) updateData.pocFirstName = pocFirstName;
|
|
761
|
+
if (pocLastName !== undefined) updateData.pocLastName = pocLastName;
|
|
762
|
+
if (pocPhoneNumber !== undefined) updateData.pocPhoneNumber = pocPhoneNumber;
|
|
763
|
+
if (pocEmail !== undefined) updateData.pocEmail = pocEmail;
|
|
764
|
+
if (businessName !== undefined) updateData.businessName = businessName;
|
|
765
|
+
if (website !== undefined) updateData.website = website;
|
|
766
|
+
if (messageVolume !== undefined) updateData.messageVolume = messageVolume;
|
|
767
|
+
if (optInWorkflow !== undefined) updateData.optInWorkflow = optInWorkflow;
|
|
768
|
+
if (optInWorkflowUrls !== undefined) updateData.optInWorkflowUrls = optInWorkflowUrls;
|
|
769
|
+
if (phoneNumbers !== undefined) updateData.phoneNumbers = phoneNumbers;
|
|
770
|
+
if (productionMessageExample !== undefined) updateData.productionMessageExample = productionMessageExample;
|
|
771
|
+
if (useCase !== undefined) updateData.useCase = useCase;
|
|
772
|
+
if (useCaseDescription !== undefined) updateData.useCaseDescription = useCaseDescription;
|
|
773
|
+
if (webhookUrl !== undefined) updateData.webhookUrl = webhookUrl;
|
|
774
|
+
|
|
602
775
|
const options = {
|
|
603
776
|
body: updateData,
|
|
604
777
|
};
|
|
@@ -626,7 +799,6 @@ export class TollFreeCampaignsService {
|
|
|
626
799
|
return result;
|
|
627
800
|
}
|
|
628
801
|
|
|
629
|
-
|
|
630
802
|
async list() {
|
|
631
803
|
const result = await this.sdk._fetch(
|
|
632
804
|
'/messaging/campaigns/tollfree',
|
|
@@ -659,7 +831,9 @@ export class TollFreeCampaignsService {
|
|
|
659
831
|
);
|
|
660
832
|
|
|
661
833
|
const result = await this.sdk._fetch(
|
|
662
|
-
`/messaging/campaigns/tollfree/phoneNumber/${encodeURIComponent(
|
|
834
|
+
`/messaging/campaigns/tollfree/phoneNumber/${encodeURIComponent(
|
|
835
|
+
phoneNumber,
|
|
836
|
+
)}/campaignStatus`,
|
|
663
837
|
'GET',
|
|
664
838
|
);
|
|
665
839
|
return result;
|
|
@@ -687,7 +861,9 @@ export class TenDlcCampaignsService {
|
|
|
687
861
|
);
|
|
688
862
|
|
|
689
863
|
const result = await this.sdk._fetch(
|
|
690
|
-
`/messaging/campaigns/10dlc/phoneNumber/${encodeURIComponent(
|
|
864
|
+
`/messaging/campaigns/10dlc/phoneNumber/${encodeURIComponent(
|
|
865
|
+
phoneNumber,
|
|
866
|
+
)}/campaignStatus`,
|
|
691
867
|
'GET',
|
|
692
868
|
);
|
|
693
869
|
return result;
|
|
@@ -932,10 +1108,29 @@ export class TenDlcCampaignManagementService {
|
|
|
932
1108
|
|
|
933
1109
|
/**
|
|
934
1110
|
* Create a new 10DLC campaign
|
|
1111
|
+
* @param {Object} params - Campaign parameters
|
|
1112
|
+
* @param {string} params.brandId - Brand ID (required)
|
|
1113
|
+
* @param {string} params.description - Campaign description (required)
|
|
1114
|
+
* @param {string} params.messageFlow - Message flow description (required)
|
|
1115
|
+
* @param {string} [params.helpMessage] - Help message
|
|
1116
|
+
* @param {string} [params.optInMessage] - Opt-in message
|
|
1117
|
+
* @param {string} [params.optOutMessage] - Opt-out message
|
|
1118
|
+
* @param {string} [params.useCase] - Use case category
|
|
1119
|
+
* @param {string} [params.vertical] - Vertical category
|
|
1120
|
+
* @returns {Promise<Object>} Created campaign details
|
|
935
1121
|
*/
|
|
936
|
-
async create(
|
|
1122
|
+
async create({
|
|
1123
|
+
brandId,
|
|
1124
|
+
description,
|
|
1125
|
+
messageFlow,
|
|
1126
|
+
helpMessage,
|
|
1127
|
+
optInMessage,
|
|
1128
|
+
optOutMessage,
|
|
1129
|
+
useCase,
|
|
1130
|
+
vertical,
|
|
1131
|
+
}) {
|
|
937
1132
|
this.sdk.validateParams(
|
|
938
|
-
|
|
1133
|
+
{ brandId, description, messageFlow, helpMessage, optInMessage, optOutMessage, useCase, vertical },
|
|
939
1134
|
{
|
|
940
1135
|
brandId: { type: 'string', required: true },
|
|
941
1136
|
description: { type: 'string', required: true },
|
|
@@ -948,6 +1143,18 @@ export class TenDlcCampaignManagementService {
|
|
|
948
1143
|
},
|
|
949
1144
|
);
|
|
950
1145
|
|
|
1146
|
+
const campaignData = {
|
|
1147
|
+
brandId,
|
|
1148
|
+
description,
|
|
1149
|
+
messageFlow,
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
if (helpMessage !== undefined) campaignData.helpMessage = helpMessage;
|
|
1153
|
+
if (optInMessage !== undefined) campaignData.optInMessage = optInMessage;
|
|
1154
|
+
if (optOutMessage !== undefined) campaignData.optOutMessage = optOutMessage;
|
|
1155
|
+
if (useCase !== undefined) campaignData.useCase = useCase;
|
|
1156
|
+
if (vertical !== undefined) campaignData.vertical = vertical;
|
|
1157
|
+
|
|
951
1158
|
const options = {
|
|
952
1159
|
body: campaignData,
|
|
953
1160
|
};
|
|
@@ -980,20 +1187,105 @@ export class TenDlcCampaignManagementService {
|
|
|
980
1187
|
|
|
981
1188
|
/**
|
|
982
1189
|
* Update a 10DLC campaign
|
|
1190
|
+
* @param {string} campaignId - Campaign ID to update
|
|
1191
|
+
* @param {Object} params - Update parameters
|
|
1192
|
+
* @param {string} [params.name] - Campaign name
|
|
1193
|
+
* @param {string} [params.description] - Campaign description
|
|
1194
|
+
* @param {string} [params.messageFlow] - Message flow description
|
|
1195
|
+
* @param {Array<string>} [params.samples] - Sample messages (up to 4)
|
|
1196
|
+
* @param {string} [params.webhookUrl] - Webhook URL
|
|
1197
|
+
* @param {string} [params.helpMessage] - Help message
|
|
1198
|
+
* @param {string} [params.optInMessage] - Opt-in message
|
|
1199
|
+
* @param {string} [params.optOutMessage] - Opt-out message
|
|
1200
|
+
* @param {string} [params.helpKeywords] - Help keywords (comma-separated)
|
|
1201
|
+
* @param {string} [params.optinKeywords] - Opt-in keywords (comma-separated)
|
|
1202
|
+
* @param {string} [params.optoutKeywords] - Opt-out keywords (comma-separated)
|
|
1203
|
+
* @param {boolean} [params.affiliateMarketing] - Affiliate marketing flag
|
|
1204
|
+
* @param {boolean} [params.ageGated] - Age gated content flag
|
|
1205
|
+
* @param {boolean} [params.directLending] - Direct lending flag
|
|
1206
|
+
* @param {boolean} [params.embeddedLink] - Embedded links flag
|
|
1207
|
+
* @param {boolean} [params.embeddedPhone] - Embedded phone numbers flag
|
|
1208
|
+
* @param {boolean} [params.numberPool] - Number pool usage flag
|
|
1209
|
+
* @param {boolean} [params.autoRenewal] - Auto-renewal flag
|
|
1210
|
+
* @param {boolean} [params.subscriberHelp] - Subscriber help support flag
|
|
1211
|
+
* @param {boolean} [params.subscriberOptin] - Subscriber opt-in requirement flag
|
|
1212
|
+
* @param {boolean} [params.subscriberOptout] - Subscriber opt-out support flag
|
|
1213
|
+
* @returns {Promise<Object>} Updated campaign information
|
|
983
1214
|
*/
|
|
984
|
-
async update(campaignId,
|
|
1215
|
+
async update(campaignId, {
|
|
1216
|
+
name,
|
|
1217
|
+
description,
|
|
1218
|
+
messageFlow,
|
|
1219
|
+
samples,
|
|
1220
|
+
webhookUrl,
|
|
1221
|
+
helpMessage,
|
|
1222
|
+
optInMessage,
|
|
1223
|
+
optOutMessage,
|
|
1224
|
+
helpKeywords,
|
|
1225
|
+
optinKeywords,
|
|
1226
|
+
optoutKeywords,
|
|
1227
|
+
affiliateMarketing,
|
|
1228
|
+
ageGated,
|
|
1229
|
+
directLending,
|
|
1230
|
+
embeddedLink,
|
|
1231
|
+
embeddedPhone,
|
|
1232
|
+
numberPool,
|
|
1233
|
+
autoRenewal,
|
|
1234
|
+
subscriberHelp,
|
|
1235
|
+
subscriberOptin,
|
|
1236
|
+
subscriberOptout,
|
|
1237
|
+
} = {}) {
|
|
985
1238
|
this.sdk.validateParams(
|
|
986
|
-
{ campaignId },
|
|
1239
|
+
{ campaignId, name, description, messageFlow, samples, webhookUrl, helpMessage, optInMessage, optOutMessage, helpKeywords, optinKeywords, optoutKeywords, affiliateMarketing, ageGated, directLending, embeddedLink, embeddedPhone, numberPool, autoRenewal, subscriberHelp, subscriberOptin, subscriberOptout },
|
|
987
1240
|
{
|
|
988
1241
|
campaignId: { type: 'string', required: true },
|
|
1242
|
+
name: { type: 'string', required: false },
|
|
989
1243
|
description: { type: 'string', required: false },
|
|
990
1244
|
messageFlow: { type: 'string', required: false },
|
|
1245
|
+
samples: { type: 'array', required: false },
|
|
1246
|
+
webhookUrl: { type: 'string', required: false },
|
|
991
1247
|
helpMessage: { type: 'string', required: false },
|
|
992
1248
|
optInMessage: { type: 'string', required: false },
|
|
993
1249
|
optOutMessage: { type: 'string', required: false },
|
|
1250
|
+
helpKeywords: { type: 'string', required: false },
|
|
1251
|
+
optinKeywords: { type: 'string', required: false },
|
|
1252
|
+
optoutKeywords: { type: 'string', required: false },
|
|
1253
|
+
affiliateMarketing: { type: 'boolean', required: false },
|
|
1254
|
+
ageGated: { type: 'boolean', required: false },
|
|
1255
|
+
directLending: { type: 'boolean', required: false },
|
|
1256
|
+
embeddedLink: { type: 'boolean', required: false },
|
|
1257
|
+
embeddedPhone: { type: 'boolean', required: false },
|
|
1258
|
+
numberPool: { type: 'boolean', required: false },
|
|
1259
|
+
autoRenewal: { type: 'boolean', required: false },
|
|
1260
|
+
subscriberHelp: { type: 'boolean', required: false },
|
|
1261
|
+
subscriberOptin: { type: 'boolean', required: false },
|
|
1262
|
+
subscriberOptout: { type: 'boolean', required: false },
|
|
994
1263
|
},
|
|
995
1264
|
);
|
|
996
1265
|
|
|
1266
|
+
const updateData = {};
|
|
1267
|
+
if (name !== undefined) updateData.name = name;
|
|
1268
|
+
if (description !== undefined) updateData.description = description;
|
|
1269
|
+
if (messageFlow !== undefined) updateData.messageFlow = messageFlow;
|
|
1270
|
+
if (samples !== undefined) updateData.samples = samples;
|
|
1271
|
+
if (webhookUrl !== undefined) updateData.webhookUrl = webhookUrl;
|
|
1272
|
+
if (helpMessage !== undefined) updateData.helpMessage = helpMessage;
|
|
1273
|
+
if (optInMessage !== undefined) updateData.optInMessage = optInMessage;
|
|
1274
|
+
if (optOutMessage !== undefined) updateData.optOutMessage = optOutMessage;
|
|
1275
|
+
if (helpKeywords !== undefined) updateData.helpKeywords = helpKeywords;
|
|
1276
|
+
if (optinKeywords !== undefined) updateData.optinKeywords = optinKeywords;
|
|
1277
|
+
if (optoutKeywords !== undefined) updateData.optoutKeywords = optoutKeywords;
|
|
1278
|
+
if (affiliateMarketing !== undefined) updateData.affiliateMarketing = affiliateMarketing;
|
|
1279
|
+
if (ageGated !== undefined) updateData.ageGated = ageGated;
|
|
1280
|
+
if (directLending !== undefined) updateData.directLending = directLending;
|
|
1281
|
+
if (embeddedLink !== undefined) updateData.embeddedLink = embeddedLink;
|
|
1282
|
+
if (embeddedPhone !== undefined) updateData.embeddedPhone = embeddedPhone;
|
|
1283
|
+
if (numberPool !== undefined) updateData.numberPool = numberPool;
|
|
1284
|
+
if (autoRenewal !== undefined) updateData.autoRenewal = autoRenewal;
|
|
1285
|
+
if (subscriberHelp !== undefined) updateData.subscriberHelp = subscriberHelp;
|
|
1286
|
+
if (subscriberOptin !== undefined) updateData.subscriberOptin = subscriberOptin;
|
|
1287
|
+
if (subscriberOptout !== undefined) updateData.subscriberOptout = subscriberOptout;
|
|
1288
|
+
|
|
997
1289
|
const options = {
|
|
998
1290
|
body: updateData,
|
|
999
1291
|
};
|
package/services/objects.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Objects Service - Manage data objects in the Unbound platform
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This service supports both new object-based signatures and legacy positional arguments
|
|
5
5
|
* for backward compatibility. New projects should use the object-based signatures.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* @example
|
|
8
8
|
* // Preferred (new) usage:
|
|
9
9
|
* const result = await sdk.objects.query({
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* where: { status: 'active' },
|
|
13
13
|
* limit: 100
|
|
14
14
|
* });
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
17
|
* // Legacy (deprecated) usage still supported:
|
|
18
18
|
* const result = await sdk.objects.query('users', { status: 'active' });
|
|
19
19
|
*/
|
|
@@ -24,21 +24,25 @@ export class ObjectsService {
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Retrieve an object by ID
|
|
27
|
-
*
|
|
27
|
+
*
|
|
28
28
|
* Preferred usage (new signature):
|
|
29
29
|
* sdk.objects.byId({ id: 'someId', expandDetails: true })
|
|
30
|
-
*
|
|
30
|
+
*
|
|
31
31
|
* Legacy usage (deprecated, but supported):
|
|
32
32
|
* sdk.objects.byId('someId', { 'select[]': ['field1', 'field2'] })
|
|
33
|
-
*
|
|
33
|
+
*
|
|
34
34
|
* @param {string|object} args - Either ID string or options object
|
|
35
35
|
* @returns {Promise} Object data
|
|
36
36
|
*/
|
|
37
37
|
async byId(...args) {
|
|
38
38
|
// New signature: byId({ id, expandDetails })
|
|
39
|
-
if (
|
|
39
|
+
if (
|
|
40
|
+
args.length === 1 &&
|
|
41
|
+
typeof args[0] === 'object' &&
|
|
42
|
+
!Array.isArray(args[0])
|
|
43
|
+
) {
|
|
40
44
|
const { id, expandDetails = false } = args[0];
|
|
41
|
-
|
|
45
|
+
|
|
42
46
|
this.sdk.validateParams(
|
|
43
47
|
{ id, expandDetails },
|
|
44
48
|
{
|
|
@@ -53,11 +57,11 @@ export class ObjectsService {
|
|
|
53
57
|
const params = { query };
|
|
54
58
|
return await this.sdk._fetch(`/object/${id}`, 'GET', params);
|
|
55
59
|
}
|
|
56
|
-
|
|
57
|
-
// Old signature: byId(id, queryParams)
|
|
60
|
+
|
|
61
|
+
// Old signature: byId(id, queryParams)
|
|
58
62
|
if (args.length >= 1 && typeof args[0] === 'string') {
|
|
59
63
|
const [id, queryParams = {}] = args;
|
|
60
|
-
|
|
64
|
+
|
|
61
65
|
this.sdk.validateParams(
|
|
62
66
|
{ id },
|
|
63
67
|
{
|
|
@@ -75,19 +79,19 @@ export class ObjectsService {
|
|
|
75
79
|
|
|
76
80
|
/**
|
|
77
81
|
* Query objects with filters
|
|
78
|
-
*
|
|
82
|
+
*
|
|
79
83
|
* Preferred usage (new signature):
|
|
80
|
-
* sdk.objects.query({
|
|
81
|
-
* object: 'users',
|
|
82
|
-
* select: ['id', 'name'],
|
|
84
|
+
* sdk.objects.query({
|
|
85
|
+
* object: 'users',
|
|
86
|
+
* select: ['id', 'name'],
|
|
83
87
|
* where: { status: 'active' },
|
|
84
88
|
* limit: 50,
|
|
85
89
|
* expandDetails: true
|
|
86
90
|
* })
|
|
87
|
-
*
|
|
91
|
+
*
|
|
88
92
|
* Legacy usage (deprecated, but supported):
|
|
89
93
|
* sdk.objects.query('users', { 'select[]': ['id', 'name'], status: 'active' })
|
|
90
|
-
*
|
|
94
|
+
*
|
|
91
95
|
* @param {object} args - Query parameters
|
|
92
96
|
* @returns {Promise} Query results
|
|
93
97
|
*/
|
|
@@ -106,7 +110,16 @@ export class ObjectsService {
|
|
|
106
110
|
} = args[0];
|
|
107
111
|
|
|
108
112
|
this.sdk.validateParams(
|
|
109
|
-
{
|
|
113
|
+
{
|
|
114
|
+
object,
|
|
115
|
+
select,
|
|
116
|
+
where,
|
|
117
|
+
limit,
|
|
118
|
+
nextId,
|
|
119
|
+
previousId,
|
|
120
|
+
orderByDirection,
|
|
121
|
+
expandDetails,
|
|
122
|
+
},
|
|
110
123
|
{
|
|
111
124
|
object: { type: 'string', required: true },
|
|
112
125
|
select: { type: 'object', required: false }, // array or string
|
|
@@ -124,7 +137,8 @@ export class ObjectsService {
|
|
|
124
137
|
if (limit !== 100) query.limit = limit;
|
|
125
138
|
if (nextId !== null) query.nextId = nextId;
|
|
126
139
|
if (previousId !== null) query.previousId = previousId;
|
|
127
|
-
if (orderByDirection !== 'DESC')
|
|
140
|
+
if (orderByDirection !== 'DESC')
|
|
141
|
+
query.orderByDirection = orderByDirection;
|
|
128
142
|
if (expandDetails) query.expandDetails = expandDetails;
|
|
129
143
|
|
|
130
144
|
const params = { query };
|
|
@@ -143,7 +157,11 @@ export class ObjectsService {
|
|
|
143
157
|
);
|
|
144
158
|
|
|
145
159
|
const params = { query: queryParams };
|
|
146
|
-
return await this.sdk._fetch(
|
|
160
|
+
return await this.sdk._fetch(
|
|
161
|
+
`/object/query/${objectName}`,
|
|
162
|
+
'GET',
|
|
163
|
+
params,
|
|
164
|
+
);
|
|
147
165
|
}
|
|
148
166
|
|
|
149
167
|
throw new Error('Invalid arguments for query method');
|
|
@@ -151,13 +169,13 @@ export class ObjectsService {
|
|
|
151
169
|
|
|
152
170
|
/**
|
|
153
171
|
* Update an object record by ID
|
|
154
|
-
*
|
|
172
|
+
*
|
|
155
173
|
* Preferred usage (new signature):
|
|
156
174
|
* sdk.objects.updateById({ object: 'users', id: 'userId', update: { name: 'Jane' } })
|
|
157
|
-
*
|
|
175
|
+
*
|
|
158
176
|
* Legacy usage (deprecated, but supported):
|
|
159
177
|
* sdk.objects.updateById('users', 'userId', { name: 'Jane' })
|
|
160
|
-
*
|
|
178
|
+
*
|
|
161
179
|
* @param {object} args - Update parameters
|
|
162
180
|
* @returns {Promise} Updated object data
|
|
163
181
|
*/
|
|
@@ -234,13 +252,13 @@ export class ObjectsService {
|
|
|
234
252
|
|
|
235
253
|
/**
|
|
236
254
|
* Create a new object record
|
|
237
|
-
*
|
|
255
|
+
*
|
|
238
256
|
* Preferred usage (new signature):
|
|
239
257
|
* sdk.objects.create({ object: 'users', body: { name: 'John', email: 'john@example.com' } })
|
|
240
|
-
*
|
|
258
|
+
*
|
|
241
259
|
* Legacy usage (deprecated, but supported):
|
|
242
260
|
* sdk.objects.create('users', { name: 'John', email: 'john@example.com' })
|
|
243
|
-
*
|
|
261
|
+
*
|
|
244
262
|
* @param {object} args - Creation parameters
|
|
245
263
|
* @returns {Promise} Created object data
|
|
246
264
|
*/
|
|
@@ -357,7 +375,16 @@ export class ObjectsService {
|
|
|
357
375
|
isSystem = 0,
|
|
358
376
|
}) {
|
|
359
377
|
this.sdk.validateParams(
|
|
360
|
-
{
|
|
378
|
+
{
|
|
379
|
+
objectName,
|
|
380
|
+
fieldName,
|
|
381
|
+
targetObject,
|
|
382
|
+
lookupColumn,
|
|
383
|
+
expandFields,
|
|
384
|
+
keyField,
|
|
385
|
+
isActive,
|
|
386
|
+
isSystem,
|
|
387
|
+
},
|
|
361
388
|
{
|
|
362
389
|
objectName: { type: 'string', required: true },
|
|
363
390
|
fieldName: { type: 'string', required: true },
|
|
@@ -382,7 +409,11 @@ export class ObjectsService {
|
|
|
382
409
|
};
|
|
383
410
|
const params = { body };
|
|
384
411
|
|
|
385
|
-
const result = await this.sdk._fetch(
|
|
412
|
+
const result = await this.sdk._fetch(
|
|
413
|
+
`/object/expandDetails`,
|
|
414
|
+
'POST',
|
|
415
|
+
params,
|
|
416
|
+
);
|
|
386
417
|
return result;
|
|
387
418
|
}
|
|
388
419
|
|
|
@@ -396,7 +427,15 @@ export class ObjectsService {
|
|
|
396
427
|
offset = 0,
|
|
397
428
|
} = {}) {
|
|
398
429
|
this.sdk.validateParams(
|
|
399
|
-
{
|
|
430
|
+
{
|
|
431
|
+
objectName,
|
|
432
|
+
fieldName,
|
|
433
|
+
targetObject,
|
|
434
|
+
isActive,
|
|
435
|
+
isSystem,
|
|
436
|
+
limit,
|
|
437
|
+
offset,
|
|
438
|
+
},
|
|
400
439
|
{
|
|
401
440
|
objectName: { type: 'string', required: false },
|
|
402
441
|
fieldName: { type: 'string', required: false },
|
|
@@ -416,10 +455,14 @@ export class ObjectsService {
|
|
|
416
455
|
if (isSystem !== null) query.isSystem = isSystem;
|
|
417
456
|
if (limit !== 100) query.limit = limit;
|
|
418
457
|
if (offset !== 0) query.offset = offset;
|
|
419
|
-
|
|
458
|
+
|
|
420
459
|
const params = { query };
|
|
421
460
|
|
|
422
|
-
const result = await this.sdk._fetch(
|
|
461
|
+
const result = await this.sdk._fetch(
|
|
462
|
+
`/object/expandDetails`,
|
|
463
|
+
'GET',
|
|
464
|
+
params,
|
|
465
|
+
);
|
|
423
466
|
return result;
|
|
424
467
|
}
|
|
425
468
|
|
|
@@ -446,7 +489,16 @@ export class ObjectsService {
|
|
|
446
489
|
isActive = null,
|
|
447
490
|
}) {
|
|
448
491
|
this.sdk.validateParams(
|
|
449
|
-
{
|
|
492
|
+
{
|
|
493
|
+
id,
|
|
494
|
+
objectName,
|
|
495
|
+
fieldName,
|
|
496
|
+
targetObject,
|
|
497
|
+
lookupColumn,
|
|
498
|
+
expandFields,
|
|
499
|
+
keyField,
|
|
500
|
+
isActive,
|
|
501
|
+
},
|
|
450
502
|
{
|
|
451
503
|
id: { type: 'string', required: true },
|
|
452
504
|
objectName: { type: 'string', required: false },
|
|
@@ -467,10 +519,14 @@ export class ObjectsService {
|
|
|
467
519
|
if (expandFields !== null) body.expandFields = expandFields;
|
|
468
520
|
if (keyField !== null) body.keyField = keyField;
|
|
469
521
|
if (isActive !== null) body.isActive = isActive;
|
|
470
|
-
|
|
522
|
+
|
|
471
523
|
const params = { body };
|
|
472
524
|
|
|
473
|
-
const result = await this.sdk._fetch(
|
|
525
|
+
const result = await this.sdk._fetch(
|
|
526
|
+
`/object/expandDetails/${id}`,
|
|
527
|
+
'PUT',
|
|
528
|
+
params,
|
|
529
|
+
);
|
|
474
530
|
return result;
|
|
475
531
|
}
|
|
476
532
|
|
|
@@ -482,7 +538,10 @@ export class ObjectsService {
|
|
|
482
538
|
},
|
|
483
539
|
);
|
|
484
540
|
|
|
485
|
-
const result = await this.sdk._fetch(
|
|
541
|
+
const result = await this.sdk._fetch(
|
|
542
|
+
`/object/expandDetails/${id}`,
|
|
543
|
+
'DELETE',
|
|
544
|
+
);
|
|
486
545
|
return result;
|
|
487
546
|
}
|
|
488
547
|
|
|
@@ -498,7 +557,16 @@ export class ObjectsService {
|
|
|
498
557
|
isSystem = 0,
|
|
499
558
|
}) {
|
|
500
559
|
this.sdk.validateParams(
|
|
501
|
-
{
|
|
560
|
+
{
|
|
561
|
+
objectName,
|
|
562
|
+
columnName,
|
|
563
|
+
value,
|
|
564
|
+
type,
|
|
565
|
+
columnType,
|
|
566
|
+
length,
|
|
567
|
+
isActive,
|
|
568
|
+
isSystem,
|
|
569
|
+
},
|
|
502
570
|
{
|
|
503
571
|
objectName: { type: 'string', required: true },
|
|
504
572
|
columnName: { type: 'string', required: true },
|
|
@@ -523,7 +591,11 @@ export class ObjectsService {
|
|
|
523
591
|
};
|
|
524
592
|
const params = { body };
|
|
525
593
|
|
|
526
|
-
const result = await this.sdk._fetch(
|
|
594
|
+
const result = await this.sdk._fetch(
|
|
595
|
+
`/object/generatedColumns`,
|
|
596
|
+
'POST',
|
|
597
|
+
params,
|
|
598
|
+
);
|
|
527
599
|
return result;
|
|
528
600
|
}
|
|
529
601
|
|
|
@@ -554,10 +626,14 @@ export class ObjectsService {
|
|
|
554
626
|
if (isSystem !== null) query.isSystem = isSystem;
|
|
555
627
|
if (limit !== 100) query.limit = limit;
|
|
556
628
|
if (offset !== 0) query.offset = offset;
|
|
557
|
-
|
|
629
|
+
|
|
558
630
|
const params = { query };
|
|
559
631
|
|
|
560
|
-
const result = await this.sdk._fetch(
|
|
632
|
+
const result = await this.sdk._fetch(
|
|
633
|
+
`/object/generatedColumns`,
|
|
634
|
+
'GET',
|
|
635
|
+
params,
|
|
636
|
+
);
|
|
561
637
|
return result;
|
|
562
638
|
}
|
|
563
639
|
|
|
@@ -569,7 +645,10 @@ export class ObjectsService {
|
|
|
569
645
|
},
|
|
570
646
|
);
|
|
571
647
|
|
|
572
|
-
const result = await this.sdk._fetch(
|
|
648
|
+
const result = await this.sdk._fetch(
|
|
649
|
+
`/object/generatedColumns/${id}`,
|
|
650
|
+
'GET',
|
|
651
|
+
);
|
|
573
652
|
return result;
|
|
574
653
|
}
|
|
575
654
|
|
|
@@ -605,10 +684,14 @@ export class ObjectsService {
|
|
|
605
684
|
if (columnType !== null) body.columnType = columnType;
|
|
606
685
|
if (length !== null) body.length = length;
|
|
607
686
|
if (isActive !== null) body.isActive = isActive;
|
|
608
|
-
|
|
687
|
+
|
|
609
688
|
const params = { body };
|
|
610
689
|
|
|
611
|
-
const result = await this.sdk._fetch(
|
|
690
|
+
const result = await this.sdk._fetch(
|
|
691
|
+
`/object/generatedColumns/${id}`,
|
|
692
|
+
'PUT',
|
|
693
|
+
params,
|
|
694
|
+
);
|
|
612
695
|
return result;
|
|
613
696
|
}
|
|
614
697
|
|
|
@@ -620,7 +703,10 @@ export class ObjectsService {
|
|
|
620
703
|
},
|
|
621
704
|
);
|
|
622
705
|
|
|
623
|
-
const result = await this.sdk._fetch(
|
|
706
|
+
const result = await this.sdk._fetch(
|
|
707
|
+
`/object/generatedColumns/${id}`,
|
|
708
|
+
'DELETE',
|
|
709
|
+
);
|
|
624
710
|
return result;
|
|
625
711
|
}
|
|
626
712
|
|
|
@@ -651,7 +737,16 @@ export class ObjectsService {
|
|
|
651
737
|
isRequired = false,
|
|
652
738
|
}) {
|
|
653
739
|
this.sdk.validateParams(
|
|
654
|
-
{
|
|
740
|
+
{
|
|
741
|
+
objectName,
|
|
742
|
+
columns,
|
|
743
|
+
name,
|
|
744
|
+
type,
|
|
745
|
+
length,
|
|
746
|
+
defaultValue,
|
|
747
|
+
isEncrypted,
|
|
748
|
+
isRequired,
|
|
749
|
+
},
|
|
655
750
|
{
|
|
656
751
|
objectName: { type: 'string', required: true },
|
|
657
752
|
columns: { type: 'object', required: false }, // array
|
|
@@ -675,12 +770,18 @@ export class ObjectsService {
|
|
|
675
770
|
body.isEncrypted = isEncrypted;
|
|
676
771
|
body.isRequired = isRequired;
|
|
677
772
|
} else {
|
|
678
|
-
throw new Error(
|
|
773
|
+
throw new Error(
|
|
774
|
+
'Either columns array or individual column properties (name, type) must be provided',
|
|
775
|
+
);
|
|
679
776
|
}
|
|
680
|
-
|
|
777
|
+
|
|
681
778
|
const params = { body };
|
|
682
779
|
|
|
683
|
-
const result = await this.sdk._fetch(
|
|
780
|
+
const result = await this.sdk._fetch(
|
|
781
|
+
`/object/manage/${objectName}`,
|
|
782
|
+
'POST',
|
|
783
|
+
params,
|
|
784
|
+
);
|
|
684
785
|
return result;
|
|
685
786
|
}
|
|
686
787
|
|
|
@@ -694,7 +795,15 @@ export class ObjectsService {
|
|
|
694
795
|
isRequired = null,
|
|
695
796
|
}) {
|
|
696
797
|
this.sdk.validateParams(
|
|
697
|
-
{
|
|
798
|
+
{
|
|
799
|
+
objectName,
|
|
800
|
+
columnName,
|
|
801
|
+
columnType,
|
|
802
|
+
length,
|
|
803
|
+
defaultValue,
|
|
804
|
+
isEncrypted,
|
|
805
|
+
isRequired,
|
|
806
|
+
},
|
|
698
807
|
{
|
|
699
808
|
objectName: { type: 'string', required: true },
|
|
700
809
|
columnName: { type: 'string', required: true },
|
|
@@ -712,10 +821,14 @@ export class ObjectsService {
|
|
|
712
821
|
if (defaultValue !== null) body.defaultValue = defaultValue;
|
|
713
822
|
if (isEncrypted !== null) body.isEncrypted = isEncrypted;
|
|
714
823
|
if (isRequired !== null) body.isRequired = isRequired;
|
|
715
|
-
|
|
824
|
+
|
|
716
825
|
const params = { body };
|
|
717
826
|
|
|
718
|
-
const result = await this.sdk._fetch(
|
|
827
|
+
const result = await this.sdk._fetch(
|
|
828
|
+
`/object/manage/${objectName}/${columnName}`,
|
|
829
|
+
'PUT',
|
|
830
|
+
params,
|
|
831
|
+
);
|
|
719
832
|
return result;
|
|
720
833
|
}
|
|
721
834
|
|
|
@@ -728,7 +841,10 @@ export class ObjectsService {
|
|
|
728
841
|
},
|
|
729
842
|
);
|
|
730
843
|
|
|
731
|
-
const result = await this.sdk._fetch(
|
|
844
|
+
const result = await this.sdk._fetch(
|
|
845
|
+
`/object/manage/${objectName}/${columnName}`,
|
|
846
|
+
'DELETE',
|
|
847
|
+
);
|
|
732
848
|
return result;
|
|
733
849
|
}
|
|
734
850
|
}
|