@rempays/shared-core 1.0.2-beta.6 → 1.0.2-beta.7
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SendTextParams, SendTemplateParams, SendInteractiveParams, SendInteractiveListParams, SendImageParams, SendDocumentParams, SendLocationParams, SetTypingParams, MarkAsReadParams, ExchangeTokenParams, ExchangeTokenResponse
|
|
1
|
+
import type { SendTextParams, SendTemplateParams, SendInteractiveParams, SendInteractiveListParams, SendImageParams, SendDocumentParams, SendLocationParams, SetTypingParams, MarkAsReadParams, ExchangeTokenParams, ExchangeTokenResponse } from './types';
|
|
2
2
|
export declare class FacebookApi {
|
|
3
3
|
private static token;
|
|
4
4
|
private static phoneNumberId;
|
|
@@ -19,15 +19,6 @@ export declare class FacebookApi {
|
|
|
19
19
|
* Used after user completes WhatsApp Business signup flow
|
|
20
20
|
*/
|
|
21
21
|
static exchangeToken(params: ExchangeTokenParams): Promise<ExchangeTokenResponse>;
|
|
22
|
-
/**
|
|
23
|
-
* Register phone number for WhatsApp Business API
|
|
24
|
-
* Requires a 6-digit PIN for verification
|
|
25
|
-
*/
|
|
26
|
-
static registerPhone(params: RegisterPhoneParams): Promise<any>;
|
|
27
|
-
/**
|
|
28
|
-
* Verify phone number with code sent via SMS
|
|
29
|
-
*/
|
|
30
|
-
static verifyCode(params: VerifyPhoneCodeParams): Promise<any>;
|
|
31
22
|
/**
|
|
32
23
|
* Get WhatsApp Business Account info
|
|
33
24
|
*/
|
|
@@ -193,48 +193,6 @@ class FacebookApi {
|
|
|
193
193
|
throw new Error(msg);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Register phone number for WhatsApp Business API
|
|
198
|
-
* Requires a 6-digit PIN for verification
|
|
199
|
-
*/
|
|
200
|
-
static async registerPhone(params) {
|
|
201
|
-
await this.init();
|
|
202
|
-
const url = `https://graph.facebook.com/${this.apiVersion}/${params.phoneNumberId}/register`;
|
|
203
|
-
try {
|
|
204
|
-
const http = (0, http_1.getHttpClient)(this.token);
|
|
205
|
-
const { data } = await http.post(url, {
|
|
206
|
-
messaging_product: "whatsapp",
|
|
207
|
-
pin: params.pin,
|
|
208
|
-
});
|
|
209
|
-
return data;
|
|
210
|
-
}
|
|
211
|
-
catch (err) {
|
|
212
|
-
const status = err?.response?.status;
|
|
213
|
-
const data = err?.response?.data;
|
|
214
|
-
const msg = `Facebook phone registration error${status ? " " + status : ""}: ${typeof data === "string" ? data : JSON.stringify(data)}`;
|
|
215
|
-
throw new Error(msg);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Verify phone number with code sent via SMS
|
|
220
|
-
*/
|
|
221
|
-
static async verifyCode(params) {
|
|
222
|
-
await this.init();
|
|
223
|
-
const url = `https://graph.facebook.com/${this.apiVersion}/${this.phoneNumberId}/verify_code`;
|
|
224
|
-
try {
|
|
225
|
-
const http = (0, http_1.getHttpClient)(this.token);
|
|
226
|
-
const { data } = await http.post(url, {
|
|
227
|
-
code: params.code,
|
|
228
|
-
});
|
|
229
|
-
return data;
|
|
230
|
-
}
|
|
231
|
-
catch (err) {
|
|
232
|
-
const status = err?.response?.status;
|
|
233
|
-
const data = err?.response?.data;
|
|
234
|
-
const msg = `Facebook code verification error${status ? " " + status : ""}: ${typeof data === "string" ? data : JSON.stringify(data)}`;
|
|
235
|
-
throw new Error(msg);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
196
|
/**
|
|
239
197
|
* Get WhatsApp Business Account info
|
|
240
198
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rempays/shared-core",
|
|
3
|
-
"version": "1.0.2-beta.
|
|
3
|
+
"version": "1.0.2-beta.7",
|
|
4
4
|
"description": "Core utilities layer for RemPays platform with AWS services integration (Cognito, S3, Secrets Manager, Textract, Facebook API, DynamoDB)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|