@suprsend/node-sdk 1.4.0 → 1.5.0

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.
@@ -333,7 +333,7 @@ var BulkSubscribers = /*#__PURE__*/function () {
333
333
  }, {
334
334
  key: "trigger",
335
335
  value: function trigger() {
336
- this.save();
336
+ return this.save();
337
337
  }
338
338
  }, {
339
339
  key: "save",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suprsend/node-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Suprsend Node SDK to trigger workflow from backend",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -22,6 +22,7 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
+ "types": "types/index.d.ts",
25
26
  "dependencies": {
26
27
  "@babel/runtime": "^7.16.3",
27
28
  "axios": "^0.27.2",
@@ -204,7 +204,7 @@ class BulkSubscribers {
204
204
  }
205
205
 
206
206
  trigger() {
207
- this.save();
207
+ return this.save();
208
208
  }
209
209
 
210
210
  async save() {
@@ -0,0 +1,194 @@
1
+ declare namespace suprsend {
2
+ interface Dictionary {
3
+ [key: string]: any;
4
+ }
5
+
6
+ interface SResponse {
7
+ success: boolean;
8
+ status: string;
9
+ status_code: number;
10
+ message: string;
11
+ }
12
+
13
+ interface SBulkResponse {
14
+ status: string;
15
+ failed_records: Dictionary[];
16
+ total: number;
17
+ success: number;
18
+ failure: number;
19
+ warnings: string[];
20
+ }
21
+
22
+ interface Workflow {
23
+ new (
24
+ body: Dictionary,
25
+ kwargs?: { idempotency_key?: string; brand_id?: string }
26
+ ): Workflow;
27
+
28
+ add_attachment(
29
+ file_path: string,
30
+ kwargs?: { file_name?: string; ignore_if_error?: boolean }
31
+ ): void;
32
+ }
33
+
34
+ interface BulkWorkflows {
35
+ append(...workflows: Workflow[]): void;
36
+
37
+ trigger(): Promise<SBulkResponse>;
38
+ }
39
+
40
+ interface BulkWorkflowsFactory {
41
+ new_instance(): BulkWorkflows;
42
+ }
43
+
44
+ // Events
45
+ interface Event {
46
+ new (
47
+ distinct_id: any,
48
+ event_name: string,
49
+ properties?: Dictionary,
50
+ kwargs?: { idempotency_key?: string; brand_id?: string }
51
+ ): Event;
52
+
53
+ add_attachment(
54
+ file_path: string,
55
+ kwargs?: { file_name?: string; ignore_if_error?: boolean }
56
+ ): void;
57
+ }
58
+
59
+ interface BulkEvents {
60
+ append(...events: Event[]): void;
61
+
62
+ trigger(): Promise<SBulkResponse>;
63
+ }
64
+
65
+ interface BulkEventsFactory {
66
+ new_instance(): BulkEvents;
67
+ }
68
+
69
+ // subscribers
70
+ interface Subscriber {
71
+ save(): Promise<SResponse>;
72
+
73
+ append(key: string | Dictionary, value?: any): void;
74
+ remove(key: string | Dictionary, value?: any): void;
75
+ unset(keys: string | string[]): void;
76
+
77
+ set_preferred_language(lang_code: string): void;
78
+
79
+ add_email(email: string): void;
80
+ remove_email(email: string): void;
81
+
82
+ add_sms(mobile_no: string): void;
83
+ remove_sms(mobile_no: string): void;
84
+
85
+ add_whatsapp(mobile_no: string): void;
86
+ remove_whatsapp(mobile_no: string): void;
87
+
88
+ add_androidpush(push_token: string, provider?: string): void;
89
+ remove_androidpush(push_token: string, provider?: string): void;
90
+
91
+ add_iospush(push_token: string, provider?: string): void;
92
+ remove_iospush(push_token: string, provider?: string): void;
93
+
94
+ add_webpush(push_token: Dictionary, provider?: string): void;
95
+ remove_webpush(push_token: Dictionary, provider?: string): void;
96
+
97
+ add_slack_email(email: string): void;
98
+ remove_slack_email(email: string): void;
99
+
100
+ add_slack_userid(user_id: any): void;
101
+ remove_slack_userid(user_id: any): void;
102
+ }
103
+
104
+ interface SubscriberFactory {
105
+ new_user(distinct_id: any): Subscriber;
106
+
107
+ get_instance(distinct_id: any): Subscriber;
108
+ }
109
+
110
+ interface BulkSubscribersFactory {
111
+ new_instance(): BulkSubscribers;
112
+ }
113
+
114
+ interface BulkSubscribers {
115
+ append(...subscribers: Subscriber[]): void;
116
+
117
+ trigger(): Promise<SBulkResponse>;
118
+
119
+ save(): Promise<SBulkResponse>;
120
+ }
121
+
122
+ // brands
123
+ interface BrandsApi {
124
+ list(options?: { limit?: number; offset?: number }): Promise<Dictionary>;
125
+
126
+ get(brand_id: any): Promise<Dictionary>;
127
+
128
+ upsert(brand_id: any, brand_payload?: Dictionary): Promise<Dictionary>;
129
+ }
130
+
131
+ // lists
132
+ interface SubscriberListBroadcast {
133
+ new (
134
+ body: Dictionary,
135
+ kwargs?: { idempotency_key?: string; brand_id?: string }
136
+ ): SubscriberListBroadcast;
137
+ }
138
+
139
+ interface SubscriberListsApi {
140
+ create(payload: Dictionary): Promise<Dictionary>;
141
+
142
+ get_all(options?: { limit?: number; offset?: number }): Promise<Dictionary>;
143
+
144
+ get(list_id: string): Promise<Dictionary>;
145
+
146
+ add(list_id: string, distinct_ids: string[]): Promise<Dictionary>;
147
+
148
+ remove(list_id: string, distinct_ids: string[]): Promise<Dictionary>;
149
+
150
+ broadcast(broadcast_instance: SubscriberListBroadcast): Promise<SResponse>;
151
+ }
152
+
153
+ interface Suprsend {
154
+ new (
155
+ workspace_env: string,
156
+ workspace_secret: string,
157
+ config: { is_staging: boolean }
158
+ ): Suprsend;
159
+
160
+ get bulk_workflows(): BulkWorkflowsFactory;
161
+
162
+ get bulk_events(): BulkEventsFactory;
163
+
164
+ get user(): SubscriberFactory;
165
+
166
+ get bulk_users(): BulkSubscribersFactory;
167
+
168
+ brands: BrandsApi;
169
+
170
+ subscriber_lists: SubscriberListsApi;
171
+
172
+ add_attachment(
173
+ body: Dictionary,
174
+ file_path: string,
175
+ kwargs?: { file_name?: string; ignore_if_error?: boolean }
176
+ ): Dictionary;
177
+
178
+ trigger_workflow(body: Workflow | Dictionary): Promise<SResponse>;
179
+
180
+ track(
181
+ distinct_id: any,
182
+ event_name: string,
183
+ properties?: Dictionary,
184
+ kwargs?: { idempotency_key?: string; brand_id?: string }
185
+ ): Promise<SResponse>;
186
+
187
+ track_event(event: Event): Promise<SResponse>;
188
+ }
189
+ }
190
+
191
+ export const Suprsend: suprsend.Suprsend;
192
+ export const Event: suprsend.Event;
193
+ export const Workflow: suprsend.Workflow;
194
+ export const SubscriberListBroadcast: suprsend.SubscriberListBroadcast;