meta-cloud-api 0.0.21 → 0.1.1
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/dist/api/base.d.mts +2 -1
- package/dist/api/base.d.ts +2 -1
- package/dist/api/base.js +1 -1
- package/dist/api/base.js.map +1 -1
- package/dist/api/base.mjs +1 -1
- package/dist/api/base.mjs.map +1 -1
- package/dist/api/businessProfile.js +1 -1
- package/dist/api/businessProfile.js.map +1 -1
- package/dist/api/businessProfile.mjs +1 -1
- package/dist/api/businessProfile.mjs.map +1 -1
- package/dist/api/encryption.d.mts +1 -1
- package/dist/api/encryption.d.ts +1 -1
- package/dist/api/encryption.js +1 -1
- package/dist/api/encryption.js.map +1 -1
- package/dist/api/encryption.mjs +1 -1
- package/dist/api/encryption.mjs.map +1 -1
- package/dist/api/flow.d.mts +3 -3
- package/dist/api/flow.d.ts +3 -3
- package/dist/api/flow.js +1 -1
- package/dist/api/flow.js.map +1 -1
- package/dist/api/flow.mjs +1 -1
- package/dist/api/flow.mjs.map +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/media.d.mts +1 -1
- package/dist/api/media.d.ts +1 -1
- package/dist/api/media.js +1 -1
- package/dist/api/media.js.map +1 -1
- package/dist/api/media.mjs +1 -1
- package/dist/api/media.mjs.map +1 -1
- package/dist/api/messages.js +1 -1
- package/dist/api/messages.js.map +1 -1
- package/dist/api/messages.mjs +1 -1
- package/dist/api/messages.mjs.map +1 -1
- package/dist/api/phoneNumber.js +1 -1
- package/dist/api/phoneNumber.js.map +1 -1
- package/dist/api/phoneNumber.mjs +1 -1
- package/dist/api/phoneNumber.mjs.map +1 -1
- package/dist/api/qrCode.d.mts +1 -1
- package/dist/api/qrCode.d.ts +1 -1
- package/dist/api/qrCode.js +1 -1
- package/dist/api/qrCode.js.map +1 -1
- package/dist/api/qrCode.mjs +1 -1
- package/dist/api/qrCode.mjs.map +1 -1
- package/dist/api/registration.d.mts +1 -1
- package/dist/api/registration.d.ts +1 -1
- package/dist/api/registration.js +1 -1
- package/dist/api/registration.js.map +1 -1
- package/dist/api/registration.mjs +1 -1
- package/dist/api/registration.mjs.map +1 -1
- package/dist/api/template.js +1 -1
- package/dist/api/template.js.map +1 -1
- package/dist/api/template.mjs +1 -1
- package/dist/api/template.mjs.map +1 -1
- package/dist/api/twoStepVerification.js +1 -1
- package/dist/api/twoStepVerification.js.map +1 -1
- package/dist/api/twoStepVerification.mjs +1 -1
- package/dist/api/twoStepVerification.mjs.map +1 -1
- package/dist/api/waba.js +1 -1
- package/dist/api/waba.js.map +1 -1
- package/dist/api/waba.mjs +1 -1
- package/dist/api/waba.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/request.d.mts +1 -0
- package/dist/request.d.ts +1 -0
- package/dist/request.js +1 -1
- package/dist/request.js.map +1 -1
- package/dist/request.mjs +1 -1
- package/dist/request.mjs.map +1 -1
- package/dist/types/request.d.mts +1 -0
- package/dist/types/request.d.ts +1 -0
- package/dist/types/request.js +1 -1
- package/dist/types/request.js.map +1 -1
- package/dist/utils/importConfig.js +1 -1
- package/dist/utils/importConfig.js.map +1 -1
- package/dist/utils/importConfig.mjs +1 -1
- package/dist/utils/importConfig.mjs.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/whatsapp.js +1 -1
- package/dist/whatsapp.js.map +1 -1
- package/dist/whatsapp.mjs +1 -1
- package/dist/whatsapp.mjs.map +1 -1
- package/package.json +3 -2
package/dist/api/base.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { BaseClass } from '../types/base.mjs';
|
|
2
2
|
import { WabaConfigType } from '../types/config.mjs';
|
|
3
3
|
import { RequesterClass } from '../types/request.mjs';
|
|
4
|
-
import '../enums-D7paGoTY.mjs';
|
|
4
|
+
import { H as HttpMethodsEnum } from '../enums-D7paGoTY.mjs';
|
|
5
5
|
|
|
6
6
|
declare class BaseAPI implements BaseClass {
|
|
7
7
|
protected config: WabaConfigType;
|
|
8
8
|
protected client: RequesterClass;
|
|
9
9
|
constructor(config: WabaConfigType, client: RequesterClass);
|
|
10
|
+
protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export { BaseAPI as default };
|
package/dist/api/base.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { BaseClass } from '../types/base.js';
|
|
2
2
|
import { WabaConfigType } from '../types/config.js';
|
|
3
3
|
import { RequesterClass } from '../types/request.js';
|
|
4
|
-
import '../enums-D7paGoTY.js';
|
|
4
|
+
import { H as HttpMethodsEnum } from '../enums-D7paGoTY.js';
|
|
5
5
|
|
|
6
6
|
declare class BaseAPI implements BaseClass {
|
|
7
7
|
protected config: WabaConfigType;
|
|
8
8
|
protected client: RequesterClass;
|
|
9
9
|
constructor(config: WabaConfigType, client: RequesterClass);
|
|
10
|
+
protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export { BaseAPI as default };
|
package/dist/api/base.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var c=(o,e)=>{for(var t in e)a(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!m.call(o,s)&&s!==t&&a(o,s,{get:()=>e[s],enumerable:!(i=p(e,s))||i.enumerable});return o};var g=o=>f(a({},"__esModule",{value:!0}),o);var d={};c(d,{default:()=>r});module.exports=g(d);var n=class{name;debug;constructor(e,t=!1){this.name=e,this.debug=t}log(...e){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...e])}}error(...e){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...e])}warn(...e){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...e])}info(...e){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...e])}};var y="BaseAPI",h=!1,u=new n(y,process.env.DEBUG==="true"||h),r=class{config;client;constructor(e,t){this.config=e,this.client=t,u.log("Initialized with HTTPSClient")}sendJson(e,t,i,s){return this.client.getJson(e,t,i,s)}};
|
|
2
2
|
//# sourceMappingURL=base.js.map
|
package/dist/api/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/base.ts","../../src/utils/logger.ts"],"sourcesContent":["import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,
|
|
1
|
+
{"version":3,"sources":["../../src/api/base.ts","../../src/utils/logger.ts"],"sourcesContent":["import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n}\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix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ACd,KAAK,OAASC,EACdJ,EAAO,IAAI,8BAA8B,CAC7C,CAEU,SAAYK,EAAyBC,EAAkBC,EAAiBC,EAAwB,CACtG,OAAO,KAAK,OAAO,QAAWH,EAAQC,EAAUC,EAASC,CAAI,CACjE,CACJ","names":["base_exports","__export","BaseAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body"]}
|
package/dist/api/base.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o=class{name;debug;constructor(t,e=!1){this.name=t,this.debug=e}log(...t){if(this.debug){let e=`[ ${Date.now()} ]`;this.name&&(e+=` - ${this.name}`),console.log.apply(console,[e,": ",...t])}}error(...t){let e=`[ ${Date.now()} ] - ERROR`;this.name&&(e+=` - ${this.name}`),console.error.apply(console,[e,": ",...t])}warn(...t){let e=`[ ${Date.now()} ] - WARN`;this.name&&(e+=` - ${this.name}`),console.warn.apply(console,[e,": ",...t])}info(...t){let e=`[ ${Date.now()} ] - INFO`;this.name&&(e+=` - ${this.name}`),console.info.apply(console,[e,": ",...t])}};var a="BaseAPI",
|
|
1
|
+
var o=class{name;debug;constructor(t,e=!1){this.name=t,this.debug=e}log(...t){if(this.debug){let e=`[ ${Date.now()} ]`;this.name&&(e+=` - ${this.name}`),console.log.apply(console,[e,": ",...t])}}error(...t){let e=`[ ${Date.now()} ] - ERROR`;this.name&&(e+=` - ${this.name}`),console.error.apply(console,[e,": ",...t])}warn(...t){let e=`[ ${Date.now()} ] - WARN`;this.name&&(e+=` - ${this.name}`),console.warn.apply(console,[e,": ",...t])}info(...t){let e=`[ ${Date.now()} ] - INFO`;this.name&&(e+=` - ${this.name}`),console.info.apply(console,[e,": ",...t])}};var a="BaseAPI",p=!1,l=new o(a,process.env.DEBUG==="true"||p),s=class{config;client;constructor(t,e){this.config=t,this.client=e,l.log("Initialized with HTTPSClient")}sendJson(t,e,i,r){return this.client.getJson(t,e,i,r)}};export{s as default};
|
|
2
2
|
//# sourceMappingURL=base.mjs.map
|
package/dist/api/base.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n}\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,ECvCA,IAAME,EAAW,UACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EAExDG,EAArB,KAAkD,CACpC,OACA,OAEV,YAAYC,EAAwBC,EAAwB,CACxD,KAAK,OAASD,EACd,KAAK,OAASC,EACdJ,EAAO,IAAI,8BAA8B,CAC7C,CAEU,SAAYK,EAAyBC,EAAkBC,EAAiBC,EAAwB,CACtG,OAAO,KAAK,OAAO,QAAWH,EAAQC,EAAUC,EAASC,CAAI,CACjE,CACJ","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var l=(A,t)=>{for(var R in t)U(A,R,{get:t[R],enumerable:!0})},I=(A,t,R,S)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of p(t))!O.call(A,i)&&i!==R&&U(A,i,{get:()=>t[i],enumerable:!(S=G(t,i))||S.enumerable});return A};var T=A=>I(U({},"__esModule",{value:!0}),A);var f={};l(f,{default:()=>N});module.exports=T(f);var B=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[S,i]of Object.entries(A))i!==void 0&&t.append(S,String(i));let R=t.toString();return R?`?${R}`:""};var P=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var K="BaseAPI",M=!1,_=new P(K,process.env.DEBUG==="true"||M),D=class{config;client;constructor(t,R){this.config=t,this.client=R,_.log("Initialized with HTTPSClient")}sendJson(t,R,S,i){return this.client.getJson(t,R,S,i)}};var N=class extends D{endpoint="whatsapp_business_profile";constructor(t,R){super(t,R)}async getBusinessProfile(t){let R=t?B({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${R}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,R,S){let i=B({file_length:t,file_type:R,file_name:S});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,R)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};
|
|
2
2
|
//# sourceMappingURL=businessProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/businessProfile.ts","../../src/utils/objectToQueryString.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n */\n async getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(\n updateRequest: UpdateBusinessProfileRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<RequesterResponseInterface<UploadSessionResponse>> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(\n uploadId: string,\n file: Buffer,\n ): Promise<RequesterResponseInterface<UploadBusinessProfileResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n file,\n );\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n","export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCAO,IAAMI,EAAuBC,GAAwC,CACxE,GAAI,CAACA,GAAU,OAAO,KAAKA,CAAM,EAAE,SAAW,EAC1C,MAAO,GAGX,IAAMC,EAAe,IAAI,gBAEzB,OAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,QAAQH,CAAM,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A8B,CAC7C,CACJ,EHOA,IAAqBK,EAArB,cAAgDC,CAAwC,CACnE,SAAW,4BAE5B,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAmBA,MAAM,mBAAmBC,EAA+E,CACpG,IAAMC,EAAcD,EAASE,EAAoB,CAAE,OAAAF,CAAO,CAAC,EAAI,GAC/D,OAAO,KAAK,OAAO,kBAEf,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAAGC,CAAW,GAC3E,KAAK,OAAO,gBACZ,IACJ,CACJ,CA4BA,MAAM,sBACFE,EACoD,CACpD,OAAO,KAAK,OAAO,mBAEf,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,KAAK,UAAUA,CAAa,CAChC,CACJ,CAqBA,MAAM,oBACFC,EACAC,EACAC,EAC0D,CAC1D,IAAML,EAAcC,EAAoB,CACpC,YAAaE,EACb,UAAWC,EACX,UAAWC,CACf,CAAC,EAED,OAAO,KAAK,OAAO,mBAEf,eAAeL,CAAW,GAC1B,KAAK,OAAO,gBACZ,IACJ,CACJ,CAmBA,MAAM,YACFM,EACAC,EACkE,CAClE,OAAO,KAAK,OAAO,mBAEf,GAAGD,CAAQ,GACX,KAAK,OAAO,gBACZC,CACJ,CACJ,CAoCA,MAAM,gBAAgBD,EAAqE,CACvF,OAAO,KAAK,OAAO,kBAEf,GAAGA,CAAQ,GACX,KAAK,OAAO,gBACZ,IACJ,CACJ,CACJ","names":["businessProfile_exports","__export","BusinessProfileAPI","__toCommonJS","objectToQueryString","params","searchParams","key","value","queryString","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file"]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/businessProfile.ts","../../src/utils/objectToQueryString.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n */\n async getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(\n updateRequest: UpdateBusinessProfileRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<RequesterResponseInterface<UploadSessionResponse>> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(\n uploadId: string,\n file: Buffer,\n ): Promise<RequesterResponseInterface<UploadBusinessProfileResponse>> {\n return this.sendJson(HttpMethodsEnum.Post, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], file);\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n","export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCAO,IAAMI,EAAuBC,GAAwC,CACxE,GAAI,CAACA,GAAU,OAAO,KAAKA,CAAM,EAAE,SAAW,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CACpC,OACA,OAEV,YAAYC,EAAwBC,EAAwB,CACxD,KAAK,OAASD,EACd,KAAK,OAASC,EACdJ,EAAO,IAAI,8BAA8B,CAC7C,CAEU,SAAYK,EAAyBC,EAAkBC,EAAiBC,EAAwB,CACtG,OAAO,KAAK,OAAO,QAAWH,EAAQC,EAAUC,EAASC,CAAI,CACjE,CACJ,EHEA,IAAqBC,EAArB,cAAgDC,CAAwC,CACnE,SAAW,4BAE5B,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAmBA,MAAM,mBAAmBC,EAA+E,CACpG,IAAMC,EAAcD,EAASE,EAAoB,CAAE,OAAAF,CAAO,CAAC,EAAI,GAC/D,OAAO,KAAK,eAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAAGC,CAAW,GAC3E,KAAK,OAAO,gBACZ,IACJ,CACJ,CA4BA,MAAM,sBACFE,EACoD,CACpD,OAAO,KAAK,gBAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,KAAK,UAAUA,CAAa,CAChC,CACJ,CAqBA,MAAM,oBACFC,EACAC,EACAC,EAC0D,CAC1D,IAAML,EAAcC,EAAoB,CACpC,YAAaE,EACb,UAAWC,EACX,UAAWC,CACf,CAAC,EAED,OAAO,KAAK,gBAER,eAAeL,CAAW,GAC1B,KAAK,OAAO,gBACZ,IACJ,CACJ,CAmBA,MAAM,YACFM,EACAC,EACkE,CAClE,OAAO,KAAK,gBAA+B,GAAGD,CAAQ,GAAI,KAAK,OAAO,gBAAgCC,CAAI,CAC9G,CAoCA,MAAM,gBAAgBD,EAAqE,CACvF,OAAO,KAAK,eAA8B,GAAGA,CAAQ,GAAI,KAAK,OAAO,gBAAgC,IAAI,CAC7G,CACJ","names":["businessProfile_exports","__export","BusinessProfileAPI","__toCommonJS","objectToQueryString","params","searchParams","key","value","queryString","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var N=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[
|
|
1
|
+
var N=A=>{if(!A||Object.keys(A).length===0)return"";let t=new URLSearchParams;for(let[S,i]of Object.entries(A))i!==void 0&&t.append(S,String(i));let R=t.toString();return R?`?${R}`:""};var P=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var B="BaseAPI",G=!1,p=new P(B,process.env.DEBUG==="true"||G),D=class{config;client;constructor(t,R){this.config=t,this.client=R,p.log("Initialized with HTTPSClient")}sendJson(t,R,S,i){return this.client.getJson(t,R,S,i)}};var U=class extends D{endpoint="whatsapp_business_profile";constructor(t,R){super(t,R)}async getBusinessProfile(t){let R=t?N({fields:t}):"";return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}${R}`,this.config.REQUEST_TIMEOUT,null)}async updateBusinessProfile(t){return this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,JSON.stringify(t))}async createUploadSession(t,R,S){let i=N({file_length:t,file_type:R,file_name:S});return this.sendJson("POST",`app/uploads/${i}`,this.config.REQUEST_TIMEOUT,null)}async uploadMedia(t,R){return this.sendJson("POST",`${t}`,this.config.REQUEST_TIMEOUT,R)}async getUploadHandle(t){return this.sendJson("GET",`${t}`,this.config.REQUEST_TIMEOUT,null)}};export{U as default};
|
|
2
2
|
//# sourceMappingURL=businessProfile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/objectToQueryString.ts","../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/businessProfile.ts"],"sourcesContent":["export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n","import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n */\n async getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(\n updateRequest: UpdateBusinessProfileRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<RequesterResponseInterface<UploadSessionResponse>> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(\n uploadId: string,\n file: Buffer,\n ): Promise<RequesterResponseInterface<UploadBusinessProfileResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n file,\n );\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `${uploadId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n}\n"],"mappings":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GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EAExDG,EAArB,KAAkD,CACpC,OACA,OAEV,YAAYC,EAAwBC,EAAwB,CACxD,KAAK,OAASD,EACd,KAAK,OAASC,EACdJ,EAAO,IAAI,8BAA8B,CAC7C,CACJ,ECOA,IAAqBK,EAArB,cAAgDC,CAAwC,CACnE,SAAW,4BAE5B,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAmBA,MAAM,mBAAmBC,EAA+E,CACpG,IAAMC,EAAcD,EAASE,EAAoB,CAAE,OAAAF,CAAO,CAAC,EAAI,GAC/D,OAAO,KAAK,OAAO,kBAEf,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAAGC,CAAW,GAC3E,KAAK,OAAO,gBACZ,IACJ,CACJ,CA4BA,MAAM,sBACFE,EACoD,CACpD,OAAO,KAAK,OAAO,mBAEf,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,KAAK,UAAUA,CAAa,CAChC,CACJ,CAqBA,MAAM,oBACFC,EACAC,EACAC,EAC0D,CAC1D,IAAML,EAAcC,EAAoB,CACpC,YAAaE,EACb,UAAWC,EACX,UAAWC,CACf,CAAC,EAED,OAAO,KAAK,OAAO,mBAEf,eAAeL,CAAW,GAC1B,KAAK,OAAO,gBACZ,IACJ,CACJ,CAmBA,MAAM,YACFM,EACAC,EACkE,CAClE,OAAO,KAAK,OAAO,mBAEf,GAAGD,CAAQ,GACX,KAAK,OAAO,gBACZC,CACJ,CACJ,CAoCA,MAAM,gBAAgBD,EAAqE,CACvF,OAAO,KAAK,OAAO,kBAEf,GAAGA,CAAQ,GACX,KAAK,OAAO,gBACZ,IACJ,CACJ,CACJ","names":["objectToQueryString","params","searchParams","key","value","queryString","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/objectToQueryString.ts","../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/businessProfile.ts"],"sourcesContent":["export const objectToQueryString = (params: Record<string, any>): string => {\n if (!params || Object.keys(params).length === 0) {\n return '';\n }\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString ? `?${queryString}` : '';\n};\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n}\n","import {\n BusinessProfileClass,\n BusinessProfileResponse,\n UpdateBusinessProfileRequest,\n UploadBusinessProfileResponse,\n UploadHandle,\n UploadSessionResponse,\n} from '../types/businessProfile';\nimport type { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport { objectToQueryString } from '../utils/objectToQueryString';\nimport BaseAPI from './base';\n\n/**\n * API for managing WhatsApp Business Profiles and profile pictures.\n *\n * This API allows you to:\n * - Get business profile information\n * - Update business profile details\n * - Upload profile pictures using a three-step process:\n * 1. Create an upload session\n * 2. Upload the image binary data\n * 3. Get the upload handle to use when updating the profile\n */\nexport default class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass {\n private readonly endpoint = 'whatsapp_business_profile';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n /**\n * Get your business profile information.\n *\n * Use this method to retrieve details about your WhatsApp business profile, including\n * about text, address, description, email, profile picture URL, websites, and vertical.\n *\n * @param fields Fields to be returned in the response. If not specified, all fields will be returned.\n * Possible values: about, address, description, email, profile_picture_url, websites, vertical\n * @returns The business profile information.\n *\n * @example\n * // Get all business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile();\n *\n * // Get specific business profile fields\n * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');\n */\n async getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>> {\n const queryParams = fields ? objectToQueryString({ fields }) : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update your business profile.\n *\n * Use this method to update one or more fields of your WhatsApp business profile.\n *\n * @param updateRequest The request object containing the fields to update.\n * - messaging_product: Required. Always set to \"whatsapp\".\n * - about: Optional. Business's About text (1-139 characters).\n * - address: Optional. Business address (max 256 characters).\n * - description: Optional. Business description (max 512 characters).\n * - vertical: Optional. Business category (use BusinessVerticalEnum for type safety).\n * - email: Optional. Contact email (valid format, max 128 characters).\n * - websites: Optional. Up to 2 URLs (max 256 characters each).\n * - profile_picture_handle: Optional. Handle from upload process.\n * @returns Response indicating success or failure.\n *\n * @example\n * // Update business profile with multiple fields including vertical using enum\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * about: 'We provide excellent service',\n * email: 'contact@example.com',\n * websites: ['https://example.com'],\n * vertical: BusinessVerticalEnum.RETAIL\n * });\n */\n async updateBusinessProfile(\n updateRequest: UpdateBusinessProfileRequest,\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify(updateRequest),\n );\n }\n\n /**\n * Create an upload session for a profile picture.\n *\n * This is the first step in the profile picture upload process.\n *\n * @param fileLength Length of the file to be uploaded in bytes.\n * @param fileType MIME type of the file (e.g., 'image/jpeg').\n * @param fileName Name of the file with extension.\n * @returns Response containing the upload session ID needed for the next step.\n *\n * @example\n * // Create upload session for profile picture\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length,\n * 'image/jpeg',\n * 'profile.jpg'\n * );\n * const uploadSessionId = session.upload_session_id;\n */\n async createUploadSession(\n fileLength: number,\n fileType: string,\n fileName: string,\n ): Promise<RequesterResponseInterface<UploadSessionResponse>> {\n const queryParams = objectToQueryString({\n file_length: fileLength,\n file_type: fileType,\n file_name: fileName,\n });\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `app/uploads/${queryParams}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Upload media file to the upload session.\n *\n * This is the second step in the profile picture upload process.\n * Upload the binary content of the file to the previously created upload session.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @param file The binary data of the file (Buffer).\n * @returns Response indicating success or failure.\n *\n * @example\n * // Upload the actual file content\n * await whatsappClient.businessProfile.uploadMedia(\n * uploadSessionId,\n * fileBuffer\n * );\n */\n async uploadMedia(\n uploadId: string,\n file: Buffer,\n ): Promise<RequesterResponseInterface<UploadBusinessProfileResponse>> {\n return this.sendJson(HttpMethodsEnum.Post, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], file);\n }\n\n /**\n * Get the upload handle information.\n *\n * This is the third step in the profile picture upload process.\n * After uploading the file, get the handle to use when updating the profile.\n *\n * @param uploadId The upload session ID from createUploadSession response.\n * @returns Response containing the upload handle information.\n *\n * @example\n * // Complete profile picture update process\n * // 1. Create upload session\n * const session = await whatsappClient.businessProfile.createUploadSession(\n * fileBuffer.length, 'image/jpeg', 'profile.jpg'\n * );\n *\n * // 2. Upload the image data\n * await whatsappClient.businessProfile.uploadMedia(\n * session.upload_session_id, fileBuffer\n * );\n *\n * // 3. Get the handle for the uploaded file\n * const handleInfo = await whatsappClient.businessProfile.getUploadHandle(\n * session.upload_session_id\n * );\n *\n * // 4. Update profile with new picture and business information\n * await whatsappClient.businessProfile.updateBusinessProfile({\n * messaging_product: 'whatsapp',\n * profile_picture_handle: handleInfo.handle,\n * vertical: BusinessVerticalEnum.RESTAURANT,\n * about: 'Delicious food served daily'\n * });\n */\n async getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n"],"mappings":"AAAO,I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String","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","BusinessProfileAPI","BaseAPI","config","client","fields","queryParams","objectToQueryString","updateRequest","fileLength","fileType","fileName","uploadId","file"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WabaConfigType } from '../types/config.mjs';
|
|
2
|
+
import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.mjs';
|
|
2
3
|
import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
|
|
3
4
|
import BaseAPI from './base.mjs';
|
|
4
|
-
import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.mjs';
|
|
5
5
|
import '../enums-D7paGoTY.mjs';
|
|
6
6
|
import '../types/base.mjs';
|
|
7
7
|
|
package/dist/api/encryption.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WabaConfigType } from '../types/config.js';
|
|
2
|
+
import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.js';
|
|
2
3
|
import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
|
|
3
4
|
import BaseAPI from './base.js';
|
|
4
|
-
import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.js';
|
|
5
5
|
import '../enums-D7paGoTY.js';
|
|
6
6
|
import '../types/base.js';
|
|
7
7
|
|
package/dist/api/encryption.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var I=(A,R)=>{for(var t in R)U(A,t,{get:R[t],enumerable:!0})},K=(A,R,t,N)=>{if(R&&typeof R=="object"||typeof R=="function")for(let S of B(R))!O.call(A,S)&&S!==t&&U(A,S,{get:()=>R[S],enumerable:!(N=G(R,S))||N.enumerable});return A};var p=A=>K(U({},"__esModule",{value:!0}),A);var _={};I(_,{default:()=>i});module.exports=p(_);var D=class{name;debug;constructor(R,t=!1){this.name=R,this.debug=t}log(...R){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...R])}}error(...R){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...R])}warn(...R){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...R])}info(...R){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...R])}};var T="BaseAPI",M=!1,l=new D(T,process.env.DEBUG==="true"||M),P=class{config;client;constructor(R,t){this.config=R,this.client=t,l.log("Initialized with HTTPSClient")}sendJson(R,t,N,S){return this.client.getJson(R,t,N,S)}};var i=class extends P{endpoint="whatsapp_business_encryption";constructor(R,t){super(R,t)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(R){let t=new FormData;return t.append("business_public_key",R),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,t)}};
|
|
2
2
|
//# sourceMappingURL=encryption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/encryption.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/api/encryption.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import type { WabaConfigType } from '../types/config';\nimport type { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class EncryptionAPI extends BaseAPI implements EncryptionClass {\n private readonly endpoint = 'whatsapp_business_encryption';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getEncryptionPublicKey(): Promise<RequesterResponseInterface<EncryptionPublicKeyResponse>> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async setEncryptionPublicKey(businessPublicKey: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const formData = new FormData();\n formData.append('business_public_key', businessPublicKey);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,ECvCA,IAAME,EAAW,UACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EAExDG,EAArB,KAAkD,CACpC,OACA,OAEV,YAAYC,EAAwBC,EAAwB,CACxD,KAAK,OAASD,EACd,KAAK,OAASC,EACdJ,EAAO,IAAI,8BAA8B,CAC7C,CAEU,SAAYK,EAAyBC,EAAkBC,EAAiBC,EAAwB,CACtG,OAAO,KAAK,OAAO,QAAWH,EAAQC,EAAUC,EAASC,CAAI,CACjE,CACJ,EFjBA,IAAqBC,EAArB,cAA2CC,CAAmC,CACzD,SAAW,+BAE5B,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAEA,MAAM,wBAA2F,CAC7F,OAAO,KAAK,eAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,IACJ,CACJ,CAEA,MAAM,uBAAuBC,EAAiF,CAC1G,IAAMC,EAAW,IAAI,SACrB,OAAAA,EAAS,OAAO,sBAAuBD,CAAiB,EAEjD,KAAK,gBAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZC,CACJ,CACJ,CACJ","names":["encryption_exports","__export","EncryptionAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","EncryptionAPI","BaseAPI","config","client","businessPublicKey","formData"]}
|
package/dist/api/encryption.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var A=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var
|
|
1
|
+
var A=class{name;debug;constructor(t,R=!1){this.name=t,this.debug=R}log(...t){if(this.debug){let R=`[ ${Date.now()} ]`;this.name&&(R+=` - ${this.name}`),console.log.apply(console,[R,": ",...t])}}error(...t){let R=`[ ${Date.now()} ] - ERROR`;this.name&&(R+=` - ${this.name}`),console.error.apply(console,[R,": ",...t])}warn(...t){let R=`[ ${Date.now()} ] - WARN`;this.name&&(R+=` - ${this.name}`),console.warn.apply(console,[R,": ",...t])}info(...t){let R=`[ ${Date.now()} ] - INFO`;this.name&&(R+=` - ${this.name}`),console.info.apply(console,[R,": ",...t])}};var U="BaseAPI",G=!1,B=new A(U,process.env.DEBUG==="true"||G),S=class{config;client;constructor(t,R){this.config=t,this.client=R,B.log("Initialized with HTTPSClient")}sendJson(t,R,N,i){return this.client.getJson(t,R,N,i)}};var D=class extends S{endpoint="whatsapp_business_encryption";constructor(t,R){super(t,R)}async getEncryptionPublicKey(){return this.sendJson("GET",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,null)}async setEncryptionPublicKey(t){let R=new FormData;return R.append("business_public_key",t),this.sendJson("POST",`${this.config.WA_PHONE_NUMBER_ID}/${this.endpoint}`,this.config.REQUEST_TIMEOUT,R)}};export{D as default};
|
|
2
2
|
//# sourceMappingURL=encryption.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/encryption.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logger.ts","../../src/api/base.ts","../../src/api/encryption.ts"],"sourcesContent":["// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n}\n","import type { WabaConfigType } from '../types/config';\nimport type { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport type { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport BaseAPI from './base';\n\nexport default class EncryptionAPI extends BaseAPI implements EncryptionClass {\n private readonly endpoint = 'whatsapp_business_encryption';\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n }\n\n async getEncryptionPublicKey(): Promise<RequesterResponseInterface<EncryptionPublicKeyResponse>> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n async setEncryptionPublicKey(businessPublicKey: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const formData = new FormData();\n formData.append('business_public_key', businessPublicKey);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `${this.config[WabaConfigEnum.PhoneNumberId]}/${this.endpoint}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n"],"mappings":"AAGA,IAAqBA,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,KAAK,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACvD,CACJ,ECvCA,IAAME,EAAW,UACXC,EAAY,GACZC,EAAS,IAAIC,EAAOH,EAAU,QAAQ,IAAI,QAAU,QAAUC,CAAS,EAExDG,EAArB,KAAkD,CACpC,OACA,OAEV,YAAYC,EAAwBC,EAAwB,CACxD,KAAK,OAASD,EACd,KAAK,OAASC,EACdJ,EAAO,IAAI,8BAA8B,CAC7C,CAEU,SAAYK,EAAyBC,EAAkBC,EAAiBC,EAAwB,CACtG,OAAO,KAAK,OAAO,QAAWH,EAAQC,EAAUC,EAASC,CAAI,CACjE,CACJ,ECjBA,IAAqBC,EAArB,cAA2CC,CAAmC,CACzD,SAAW,+BAE5B,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAEA,MAAM,wBAA2F,CAC7F,OAAO,KAAK,eAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,IACJ,CACJ,CAEA,MAAM,uBAAuBC,EAAiF,CAC1G,IAAMC,EAAW,IAAI,SACrB,OAAAA,EAAS,OAAO,sBAAuBD,CAAiB,EAEjD,KAAK,gBAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZC,CACJ,CACJ,CACJ","names":["Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","EncryptionAPI","BaseAPI","config","client","businessPublicKey","formData"]}
|
package/dist/api/flow.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import BaseAPI from './base.mjs';
|
|
2
1
|
import { WabaConfigType } from '../types/config.mjs';
|
|
3
|
-
import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
|
|
4
2
|
import { FlowClass, FlowsListResponse, FlowCategoryEnum, FlowValidationError, Flow, FlowPreviewResponse, FlowAssetsResponse, FlowMigrationResponse } from '../types/flow.mjs';
|
|
5
|
-
import '../types/
|
|
3
|
+
import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
|
|
4
|
+
import BaseAPI from './base.mjs';
|
|
6
5
|
import '../enums-D7paGoTY.mjs';
|
|
6
|
+
import '../types/base.mjs';
|
|
7
7
|
|
|
8
8
|
declare class FlowAPI extends BaseAPI implements FlowClass {
|
|
9
9
|
constructor(config: WabaConfigType, client: RequesterClass);
|
package/dist/api/flow.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import BaseAPI from './base.js';
|
|
2
1
|
import { WabaConfigType } from '../types/config.js';
|
|
3
|
-
import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
|
|
4
2
|
import { FlowClass, FlowsListResponse, FlowCategoryEnum, FlowValidationError, Flow, FlowPreviewResponse, FlowAssetsResponse, FlowMigrationResponse } from '../types/flow.js';
|
|
5
|
-
import '../types/
|
|
3
|
+
import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
|
|
4
|
+
import BaseAPI from './base.js';
|
|
6
5
|
import '../enums-D7paGoTY.js';
|
|
6
|
+
import '../types/base.js';
|
|
7
7
|
|
|
8
8
|
declare class FlowAPI extends BaseAPI implements FlowClass {
|
|
9
9
|
constructor(config: WabaConfigType, client: RequesterClass);
|
package/dist/api/flow.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var O=(
|
|
1
|
+
"use strict";var p=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var O=(S,i)=>{for(var t in i)p(S,t,{get:i[t],enumerable:!0})},B=(S,i,t,R)=>{if(i&&typeof i=="object"||typeof i=="function")for(let A of G(i))!U.call(S,A)&&A!==t&&p(S,A,{get:()=>i[A],enumerable:!(R=_(i,A))||R.enumerable});return S};var f=S=>B(p({},"__esModule",{value:!0}),S);var h={};O(h,{default:()=>D});module.exports=f(h);var P=class{name;debug;constructor(i,t=!1){this.name=i,this.debug=t}log(...i){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...i])}}error(...i){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...i])}warn(...i){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...i])}info(...i){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...i])}};var I="BaseAPI",F=!1,T=new P(I,process.env.DEBUG==="true"||F),l=class{config;client;constructor(i,t){this.config=i,this.client=t,T.log("Initialized with HTTPSClient")}sendJson(i,t,R,A){return this.client.getJson(i,t,R,A)}};var K="FlowAPI",M=!1,w=new P(K,process.env.DEBUG==="true"||M),D=class extends l{constructor(i,t){super(i,t),w.log("FlowAPI initialized")}async listFlows(i){return this.sendJson("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&R.append("clone_flow_id",t.clone_flow_id),t.flow_json&&R.append("flow_json",t.flow_json),t.publish!==void 0&&R.append("publish",String(t.publish)),this.sendJson("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,R)}async getFlow(i,t,R){let A=new URLSearchParams;t&&A.append("fields",t),R&&A.append("date_format",R);let N=A.toString()?`?${A.toString()}`:"";return this.sendJson("GET",`/${i}${N}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.application_id&&R.append("application_id",t.application_id),this.sendJson("POST",`/${i}`,this.config.REQUEST_TIMEOUT,R)}async deleteFlow(i){return this.sendJson("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.sendJson("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let R=new FormData;return R.append("asset_type",t.asset_type),R.append("file",t.file),R.append("name",t.name),this.sendJson("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,R)}async publishFlow(i){return this.sendJson("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.sendJson("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let R=new FormData;return R.append("source_waba_id",t.source_waba_id),t.source_flow_names&&R.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.sendJson("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,R)}};
|
|
2
2
|
//# sourceMappingURL=flow.js.map
|
package/dist/api/flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/flow.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import BaseAPI from './base';\nimport { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport {\n FlowClass,\n FlowsListResponse,\n FlowCategoryEnum,\n Flow,\n FlowPreviewResponse,\n FlowAssetsResponse,\n FlowValidationError,\n FlowMigrationResponse,\n} from '../types/flow';\nimport Logger from '../utils/logger';\n\nconst LIB_NAME = 'FlowAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class FlowAPI extends BaseAPI implements FlowClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n LOGGER.log('FlowAPI initialized');\n }\n\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n async listFlows(wabaId: string): Promise<RequesterResponseInterface<FlowsListResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n async createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<\n RequesterResponseInterface<{ id: string; success: boolean; validation_errors?: FlowValidationError[] }>\n > {\n const formData = new FormData();\n\n if (data.name) formData.append('name', data.name);\n if (data.categories) formData.append('categories', JSON.stringify(data.categories));\n if (data.endpoint_uri) formData.append('endpoint_uri', data.endpoint_uri);\n if (data.clone_flow_id) formData.append('clone_flow_id', data.clone_flow_id);\n if (data.flow_json) formData.append('flow_json', data.flow_json);\n if (data.publish !== undefined) formData.append('publish', String(data.publish));\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n async getFlow(\n flowId: string,\n fields?: string,\n dateFormat?: string,\n ): Promise<RequesterResponseInterface<Flow | FlowPreviewResponse>> {\n const params = new URLSearchParams();\n if (fields) params.append('fields', fields);\n if (dateFormat) params.append('date_format', dateFormat);\n\n const queryString = params.toString() ? `?${params.toString()}` : '';\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${flowId}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n async updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const formData = new FormData();\n\n if (data.name) formData.append('name', data.name);\n if (data.categories) formData.append('categories', JSON.stringify(data.categories));\n if (data.endpoint_uri) formData.append('endpoint_uri', data.endpoint_uri);\n if (data.application_id) formData.append('application_id', data.application_id);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deleteFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Delete,\n `/${flowId}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n async listAssets(flowId: string): Promise<RequesterResponseInterface<FlowAssetsResponse>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Get,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n async updateFlowJson(\n flowId: string,\n data: {\n asset_type: 'FLOW_JSON';\n file: Blob;\n name: string;\n },\n ): Promise<RequesterResponseInterface<{ success: boolean; validation_errors?: FlowValidationError[] }>> {\n const formData = new FormData();\n\n formData.append('asset_type', data.asset_type);\n formData.append('file', data.file);\n formData.append('name', data.name);\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async publishFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/publish`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}),\n );\n }\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deprecateFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${flowId}/deprecate`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}),\n );\n }\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n async migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<RequesterResponseInterface<FlowMigrationResponse>> {\n const formData = new FormData();\n\n formData.append('source_waba_id', data.source_waba_id);\n if (data.source_flow_names) {\n formData.append('source_flow_names', JSON.stringify(data.source_flow_names));\n }\n\n return this.client.sendRequest(\n HttpMethodsEnum.Post,\n `/${wabaId}/migrate_flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,YACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,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EAAsE,CACpF,OAAO,KAAK,OAAO,mBAEf,IAAIA,CAAM,WACV,KAAK,OAAO,gBACZ,KAAK,UAAU,CAAC,CAAC,CACrB,CACJ,CAQA,MAAM,cAAcA,EAAsE,CACtF,OAAO,KAAK,OAAO,mBAEf,IAAIA,CAAM,aACV,KAAK,OAAO,gBACZ,KAAK,UAAU,CAAC,CAAC,CACrB,CACJ,CASA,MAAM,aACFH,EACAC,EAI0D,CAC1D,IAAMC,EAAW,IAAI,SAErB,OAAAA,EAAS,OAAO,iBAAkBD,EAAK,cAAc,EACjDA,EAAK,mBACLC,EAAS,OAAO,oBAAqB,KAAK,UAAUD,EAAK,iBAAiB,CAAC,EAGxE,KAAK,OAAO,mBAEf,IAAID,CAAM,iBACV,KAAK,OAAO,gBACZE,CACJ,CACJ,CACJ","names":["flow_exports","__export","FlowAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","LIB_NAME","LOG_LOCAL","LOGGER","Logger","FlowAPI","BaseAPI","config","client","wabaId","data","formData","flowId","fields","dateFormat","params","queryString"]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/flow.ts","../../src/utils/logger.ts","../../src/api/base.ts"],"sourcesContent":["import { WabaConfigType } from '../types/config';\nimport { HttpMethodsEnum, WabaConfigEnum } from '../types/enums';\nimport {\n Flow,\n FlowAssetsResponse,\n FlowCategoryEnum,\n FlowClass,\n FlowMigrationResponse,\n FlowPreviewResponse,\n FlowsListResponse,\n FlowValidationError,\n} from '../types/flow';\nimport { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request';\nimport Logger from '../utils/logger';\nimport BaseAPI from './base';\n\nconst LIB_NAME = 'FlowAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class FlowAPI extends BaseAPI implements FlowClass {\n constructor(config: WabaConfigType, client: RequesterClass) {\n super(config, client);\n LOGGER.log('FlowAPI initialized');\n }\n\n /**\n * List Flows\n *\n * @param wabaId - The WABA ID\n * @returns Promise with the list of flows\n */\n async listFlows(wabaId: string): Promise<RequesterResponseInterface<FlowsListResponse>> {\n return this.sendJson(HttpMethodsEnum.Get, `/${wabaId}/flows`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * Create Flow\n *\n * @param wabaId - The WABA ID\n * @param data - The flow data including name, categories, endpoint_uri, and optional clone_flow_id\n * @returns Promise with the created flow ID\n */\n async createFlow(\n wabaId: string,\n data: {\n name: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n clone_flow_id?: string;\n flow_json?: string;\n publish?: boolean;\n },\n ): Promise<\n RequesterResponseInterface<{ id: string; success: boolean; validation_errors?: FlowValidationError[] }>\n > {\n const formData = new FormData();\n\n if (data.name) formData.append('name', data.name);\n if (data.categories) formData.append('categories', JSON.stringify(data.categories));\n if (data.endpoint_uri) formData.append('endpoint_uri', data.endpoint_uri);\n if (data.clone_flow_id) formData.append('clone_flow_id', data.clone_flow_id);\n if (data.flow_json) formData.append('flow_json', data.flow_json);\n if (data.publish !== undefined) formData.append('publish', String(data.publish));\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${wabaId}/flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Get Flow\n *\n * @param flowId - The flow ID\n * @param fields - Optional fields to return\n * @param dateFormat - Optional date format\n * @returns Promise with the flow details\n */\n async getFlow(\n flowId: string,\n fields?: string,\n dateFormat?: string,\n ): Promise<RequesterResponseInterface<Flow | FlowPreviewResponse>> {\n const params = new URLSearchParams();\n if (fields) params.append('fields', fields);\n if (dateFormat) params.append('date_format', dateFormat);\n\n const queryString = params.toString() ? `?${params.toString()}` : '';\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}${queryString}`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow Metadata\n *\n * @param flowId - The flow ID\n * @param data - The flow metadata to update\n * @returns Promise with the success status\n */\n async updateFlowMetadata(\n flowId: string,\n data: {\n name?: string;\n categories?: FlowCategoryEnum[];\n endpoint_uri?: string;\n application_id?: string;\n },\n ): Promise<RequesterResponseInterface<ResponseSuccess>> {\n const formData = new FormData();\n\n if (data.name) formData.append('name', data.name);\n if (data.categories) formData.append('categories', JSON.stringify(data.categories));\n if (data.endpoint_uri) formData.append('endpoint_uri', data.endpoint_uri);\n if (data.application_id) formData.append('application_id', data.application_id);\n\n return this.sendJson(HttpMethodsEnum.Post, `/${flowId}`, this.config[WabaConfigEnum.RequestTimeout], formData);\n }\n\n /**\n * Delete Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deleteFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.sendJson(HttpMethodsEnum.Delete, `/${flowId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n\n /**\n * List Assets (Get Flow JSON URL)\n *\n * @param flowId - The flow ID\n * @returns Promise with the list of assets\n */\n async listAssets(flowId: string): Promise<RequesterResponseInterface<FlowAssetsResponse>> {\n return this.sendJson(\n HttpMethodsEnum.Get,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n null,\n );\n }\n\n /**\n * Update Flow JSON\n *\n * @param flowId - The flow ID\n * @param data - The asset data including asset_type, file, and name\n * @returns Promise with the success status and validation errors\n */\n async updateFlowJson(\n flowId: string,\n data: {\n asset_type: 'FLOW_JSON';\n file: Blob;\n name: string;\n },\n ): Promise<RequesterResponseInterface<{ success: boolean; validation_errors?: FlowValidationError[] }>> {\n const formData = new FormData();\n\n formData.append('asset_type', data.asset_type);\n formData.append('file', data.file);\n formData.append('name', data.name);\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/assets`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n\n /**\n * Publish Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async publishFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/publish`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}),\n );\n }\n\n /**\n * Deprecate Flow\n *\n * @param flowId - The flow ID\n * @returns Promise with the success status\n */\n async deprecateFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>> {\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${flowId}/deprecate`,\n this.config[WabaConfigEnum.RequestTimeout],\n JSON.stringify({}),\n );\n }\n\n /**\n * Migrate Flows\n *\n * @param wabaId - The destination WABA ID\n * @param data - The migration data including source_waba_id and optional source_flow_names\n * @returns Promise with migration results\n */\n async migrateFlows(\n wabaId: string,\n data: {\n source_waba_id: string;\n source_flow_names?: string[];\n },\n ): Promise<RequesterResponseInterface<FlowMigrationResponse>> {\n const formData = new FormData();\n\n formData.append('source_waba_id', data.source_waba_id);\n if (data.source_flow_names) {\n formData.append('source_flow_names', JSON.stringify(data.source_flow_names));\n }\n\n return this.sendJson(\n HttpMethodsEnum.Post,\n `/${wabaId}/migrate_flows`,\n this.config[WabaConfigEnum.RequestTimeout],\n formData,\n );\n }\n}\n","// @ts-nocheck\nimport type { LoggerInterface } from '../types/logger';\n\nexport default class Logger implements LoggerInterface {\n private name: string;\n private debug: boolean;\n\n constructor(name: string, debug: boolean = false) {\n this.name = name;\n this.debug = debug;\n }\n\n log(...data: any[]) {\n if (this.debug) {\n let prefix = `[ ${Date.now()} ]`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.log.apply(console, [prefix, ': ', ...data]);\n }\n }\n\n error(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - ERROR`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.error.apply(console, [prefix, ': ', ...data]);\n }\n\n warn(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - WARN`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.warn.apply(console, [prefix, ': ', ...data]);\n }\n\n info(...data: any[]) {\n let prefix = `[ ${Date.now()} ] - INFO`;\n if (this.name) {\n prefix += ` - ${this.name}`;\n }\n console.info.apply(console, [prefix, ': ', ...data]);\n }\n}\n","import Logger from '../utils/logger';\nimport type { BaseClass } from '../types/base';\nimport type { WabaConfigType } from '../types/config';\nimport type { RequesterClass } from '../types/request';\nimport { HttpMethodsEnum } from 'src/types/enums';\n\nconst LIB_NAME = 'BaseAPI';\nconst LOG_LOCAL = false;\nconst LOGGER = new Logger(LIB_NAME, process.env.DEBUG === 'true' || LOG_LOCAL);\n\nexport default class BaseAPI implements BaseClass {\n protected config: WabaConfigType;\n protected client: RequesterClass;\n\n constructor(config: WabaConfigType, client: RequesterClass) {\n this.config = config;\n this.client = client;\n LOGGER.log('Initialized with HTTPSClient');\n }\n\n protected sendJson<T>(method: HttpMethodsEnum, endpoint: string, timeout: number, body?: any): Promise<T> {\n return this.client.getJson<T>(method, endpoint, timeout, body);\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCGA,IAAqBI,EAArB,KAAuD,CAC3C,KACA,MAER,YAAYC,EAAcC,EAAiB,GAAO,CAC9C,KAAK,KAAOD,EACZ,KAAK,MAAQC,CACjB,CAEA,OAAOC,EAAa,CAChB,GAAI,KAAK,MAAO,CACZ,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,KACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,IAAI,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACtD,CACJ,CAEA,SAASA,EAAa,CAClB,IAAIC,EAAS,KAAK,KAAK,IAAI,CAAC,aACxB,KAAK,OACLA,GAAU,MAAM,KAAK,IAAI,IAE7B,QAAQ,MAAM,MAAM,QAAS,CAACA,EAAQ,KAAM,GAAGD,CAAI,CAAC,CACxD,CAEA,QAAQA,EAAa,CACjB,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C,EAAS,OAAO,OAAQD,EAAK,IAAI,EACjCC,EAAS,OAAO,OAAQD,EAAK,IAAI,EAE1B,KAAK,gBAER,IAAIE,CAAM,UACV,KAAK,OAAO,gBACZD,CACJ,CACJ,CAQA,MAAM,YAAYC,EAAsE,CACpF,OAAO,KAAK,gBAER,IAAIA,CAAM,WACV,KAAK,OAAO,gBACZ,KAAK,UAAU,CAAC,CAAC,CACrB,CACJ,CAQA,MAAM,cAAcA,EAAsE,CACtF,OAAO,KAAK,gBAER,IAAIA,CAAM,aACV,KAAK,OAAO,gBACZ,KAAK,UAAU,CAAC,CAAC,CACrB,CACJ,CASA,MAAM,aACFH,EACAC,EAI0D,CAC1D,IAAMC,EAAW,IAAI,SAErB,OAAAA,EAAS,OAAO,iBAAkBD,EAAK,cAAc,EACjDA,EAAK,mBACLC,EAAS,OAAO,oBAAqB,KAAK,UAAUD,EAAK,iBAAiB,CAAC,EAGxE,KAAK,gBAER,IAAID,CAAM,iBACV,KAAK,OAAO,gBACZE,CACJ,CACJ,CACJ","names":["flow_exports","__export","FlowAPI","__toCommonJS","Logger","name","debug","data","prefix","LIB_NAME","LOG_LOCAL","LOGGER","Logger","BaseAPI","config","client","method","endpoint","timeout","body","LIB_NAME","LOG_LOCAL","LOGGER","Logger","FlowAPI","BaseAPI","config","client","wabaId","data","formData","flowId","fields","dateFormat","params","queryString"]}
|
package/dist/api/flow.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var A=class{name;debug;constructor(i,t=!1){this.name=i,this.debug=t}log(...i){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...i])}}error(...i){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...i])}warn(...i){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...i])}info(...i){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...i])}};var N="BaseAPI",_=!1,G=new A(N,process.env.DEBUG==="true"||_),
|
|
1
|
+
var A=class{name;debug;constructor(i,t=!1){this.name=i,this.debug=t}log(...i){if(this.debug){let t=`[ ${Date.now()} ]`;this.name&&(t+=` - ${this.name}`),console.log.apply(console,[t,": ",...i])}}error(...i){let t=`[ ${Date.now()} ] - ERROR`;this.name&&(t+=` - ${this.name}`),console.error.apply(console,[t,": ",...i])}warn(...i){let t=`[ ${Date.now()} ] - WARN`;this.name&&(t+=` - ${this.name}`),console.warn.apply(console,[t,": ",...i])}info(...i){let t=`[ ${Date.now()} ] - INFO`;this.name&&(t+=` - ${this.name}`),console.info.apply(console,[t,": ",...i])}};var N="BaseAPI",_=!1,G=new A(N,process.env.DEBUG==="true"||_),P=class{config;client;constructor(i,t){this.config=i,this.client=t,G.log("Initialized with HTTPSClient")}sendJson(i,t,R,S){return this.client.getJson(i,t,R,S)}};var U="FlowAPI",O=!1,B=new A(U,process.env.DEBUG==="true"||O),l=class extends P{constructor(i,t){super(i,t),B.log("FlowAPI initialized")}async listFlows(i){return this.sendJson("GET",`/${i}/flows`,this.config.REQUEST_TIMEOUT,null)}async createFlow(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.clone_flow_id&&R.append("clone_flow_id",t.clone_flow_id),t.flow_json&&R.append("flow_json",t.flow_json),t.publish!==void 0&&R.append("publish",String(t.publish)),this.sendJson("POST",`/${i}/flows`,this.config.REQUEST_TIMEOUT,R)}async getFlow(i,t,R){let S=new URLSearchParams;t&&S.append("fields",t),R&&S.append("date_format",R);let p=S.toString()?`?${S.toString()}`:"";return this.sendJson("GET",`/${i}${p}`,this.config.REQUEST_TIMEOUT,null)}async updateFlowMetadata(i,t){let R=new FormData;return t.name&&R.append("name",t.name),t.categories&&R.append("categories",JSON.stringify(t.categories)),t.endpoint_uri&&R.append("endpoint_uri",t.endpoint_uri),t.application_id&&R.append("application_id",t.application_id),this.sendJson("POST",`/${i}`,this.config.REQUEST_TIMEOUT,R)}async deleteFlow(i){return this.sendJson("DELETE",`/${i}`,this.config.REQUEST_TIMEOUT,null)}async listAssets(i){return this.sendJson("GET",`/${i}/assets`,this.config.REQUEST_TIMEOUT,null)}async updateFlowJson(i,t){let R=new FormData;return R.append("asset_type",t.asset_type),R.append("file",t.file),R.append("name",t.name),this.sendJson("POST",`/${i}/assets`,this.config.REQUEST_TIMEOUT,R)}async publishFlow(i){return this.sendJson("POST",`/${i}/publish`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async deprecateFlow(i){return this.sendJson("POST",`/${i}/deprecate`,this.config.REQUEST_TIMEOUT,JSON.stringify({}))}async migrateFlows(i,t){let R=new FormData;return R.append("source_waba_id",t.source_waba_id),t.source_flow_names&&R.append("source_flow_names",JSON.stringify(t.source_flow_names)),this.sendJson("POST",`/${i}/migrate_flows`,this.config.REQUEST_TIMEOUT,R)}};export{l as default};
|
|
2
2
|
//# sourceMappingURL=flow.mjs.map
|