meta-cloud-api 0.1.4 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/api/businessProfile.d.mts +6 -6
  2. package/dist/api/businessProfile.d.ts +6 -6
  3. package/dist/api/businessProfile.js +1 -1
  4. package/dist/api/businessProfile.js.map +1 -1
  5. package/dist/api/businessProfile.mjs +1 -1
  6. package/dist/api/businessProfile.mjs.map +1 -1
  7. package/dist/api/encryption.d.mts +3 -3
  8. package/dist/api/encryption.d.ts +3 -3
  9. package/dist/api/encryption.js.map +1 -1
  10. package/dist/api/encryption.mjs.map +1 -1
  11. package/dist/api/flow.d.mts +14 -25
  12. package/dist/api/flow.d.ts +14 -25
  13. package/dist/api/flow.js +1 -1
  14. package/dist/api/flow.js.map +1 -1
  15. package/dist/api/flow.mjs +1 -1
  16. package/dist/api/flow.mjs.map +1 -1
  17. package/dist/api/index.js +1 -1
  18. package/dist/api/index.js.map +1 -1
  19. package/dist/api/index.mjs +1 -1
  20. package/dist/api/index.mjs.map +1 -1
  21. package/dist/api/media.d.mts +5 -5
  22. package/dist/api/media.d.ts +5 -5
  23. package/dist/api/media.js.map +1 -1
  24. package/dist/api/media.mjs.map +1 -1
  25. package/dist/api/messages.d.mts +21 -21
  26. package/dist/api/messages.d.ts +21 -21
  27. package/dist/api/messages.js +1 -1
  28. package/dist/api/messages.js.map +1 -1
  29. package/dist/api/messages.mjs +1 -1
  30. package/dist/api/messages.mjs.map +1 -1
  31. package/dist/api/phoneNumber.d.mts +5 -5
  32. package/dist/api/phoneNumber.d.ts +5 -5
  33. package/dist/api/phoneNumber.js +1 -1
  34. package/dist/api/phoneNumber.js.map +1 -1
  35. package/dist/api/phoneNumber.mjs.map +1 -1
  36. package/dist/api/qrCode.d.mts +6 -6
  37. package/dist/api/qrCode.d.ts +6 -6
  38. package/dist/api/qrCode.js +1 -1
  39. package/dist/api/qrCode.js.map +1 -1
  40. package/dist/api/qrCode.mjs.map +1 -1
  41. package/dist/api/registration.d.mts +3 -3
  42. package/dist/api/registration.d.ts +3 -3
  43. package/dist/api/registration.js +1 -1
  44. package/dist/api/registration.js.map +1 -1
  45. package/dist/api/registration.mjs.map +1 -1
  46. package/dist/api/template.d.mts +6 -6
  47. package/dist/api/template.d.ts +6 -6
  48. package/dist/api/template.js +1 -1
  49. package/dist/api/template.js.map +1 -1
  50. package/dist/api/template.mjs +1 -1
  51. package/dist/api/template.mjs.map +1 -1
  52. package/dist/api/twoStepVerification.d.mts +3 -3
  53. package/dist/api/twoStepVerification.d.ts +3 -3
  54. package/dist/api/twoStepVerification.js +1 -1
  55. package/dist/api/twoStepVerification.js.map +1 -1
  56. package/dist/api/twoStepVerification.mjs.map +1 -1
  57. package/dist/api/waba.d.mts +5 -5
  58. package/dist/api/waba.d.ts +5 -5
  59. package/dist/api/waba.js +1 -1
  60. package/dist/api/waba.js.map +1 -1
  61. package/dist/api/waba.mjs +1 -1
  62. package/dist/api/waba.mjs.map +1 -1
  63. package/dist/index.js +1 -1
  64. package/dist/index.js.map +1 -1
  65. package/dist/index.mjs +1 -1
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/types/businessProfile.d.mts +6 -6
  68. package/dist/types/businessProfile.d.ts +6 -6
  69. package/dist/types/businessProfile.js +1 -1
  70. package/dist/types/businessProfile.js.map +1 -1
  71. package/dist/types/encryption.d.mts +3 -3
  72. package/dist/types/encryption.d.ts +3 -3
  73. package/dist/types/encryption.js +1 -1
  74. package/dist/types/encryption.js.map +1 -1
  75. package/dist/types/flow.d.mts +12 -12
  76. package/dist/types/flow.d.ts +12 -12
  77. package/dist/types/flow.js +1 -1
  78. package/dist/types/flow.js.map +1 -1
  79. package/dist/types/flow.mjs +1 -1
  80. package/dist/types/flow.mjs.map +1 -1
  81. package/dist/types/index.js +1 -1
  82. package/dist/types/index.js.map +1 -1
  83. package/dist/types/index.mjs +1 -1
  84. package/dist/types/index.mjs.map +1 -1
  85. package/dist/types/media.d.mts +5 -5
  86. package/dist/types/media.d.ts +5 -5
  87. package/dist/types/media.js +1 -1
  88. package/dist/types/media.js.map +1 -1
  89. package/dist/types/messages.d.mts +21 -21
  90. package/dist/types/messages.d.ts +21 -21
  91. package/dist/types/messages.js.map +1 -1
  92. package/dist/types/phoneNumber.d.mts +5 -5
  93. package/dist/types/phoneNumber.d.ts +5 -5
  94. package/dist/types/phoneNumber.js +1 -1
  95. package/dist/types/phoneNumber.js.map +1 -1
  96. package/dist/types/qrCode.d.mts +6 -6
  97. package/dist/types/qrCode.d.ts +6 -6
  98. package/dist/types/qrCode.js +1 -1
  99. package/dist/types/qrCode.js.map +1 -1
  100. package/dist/types/registration.d.mts +3 -3
  101. package/dist/types/registration.d.ts +3 -3
  102. package/dist/types/registration.js +1 -1
  103. package/dist/types/registration.js.map +1 -1
  104. package/dist/types/template.d.mts +6 -6
  105. package/dist/types/template.d.ts +6 -6
  106. package/dist/types/template.js +1 -1
  107. package/dist/types/template.js.map +1 -1
  108. package/dist/types/twoStepVerification.d.mts +2 -2
  109. package/dist/types/twoStepVerification.d.ts +2 -2
  110. package/dist/types/twoStepVerification.js +1 -1
  111. package/dist/types/twoStepVerification.js.map +1 -1
  112. package/dist/types/waba.d.mts +6 -6
  113. package/dist/types/waba.d.ts +6 -6
  114. package/dist/types/waba.js +1 -1
  115. package/dist/types/waba.js.map +1 -1
  116. package/dist/types/waba.mjs +1 -1
  117. package/dist/types/waba.mjs.map +1 -1
  118. package/dist/whatsapp.js +1 -1
  119. package/dist/whatsapp.js.map +1 -1
  120. package/dist/whatsapp.mjs +1 -1
  121. package/dist/whatsapp.mjs.map +1 -1
  122. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { BusinessProfileClass, BusinessProfileResponse, UpdateBusinessProfileRequest, UploadSessionResponse, UploadBusinessProfileResponse, UploadHandle } from '../types/businessProfile.mjs';
2
2
  import { WabaConfigType } from '../types/config.mjs';
3
- import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
3
+ import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
5
  import '../enums-D7paGoTY.mjs';
6
6
  import '../types/base.mjs';
@@ -36,7 +36,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
36
36
  * // Get specific business profile fields
37
37
  * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');
38
38
  */
39
- getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>>;
39
+ getBusinessProfile(fields?: string): Promise<BusinessProfileResponse>;
40
40
  /**
41
41
  * Update your business profile.
42
42
  *
@@ -63,7 +63,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
63
63
  * vertical: BusinessVerticalEnum.RETAIL
64
64
  * });
65
65
  */
66
- updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<RequesterResponseInterface<ResponseSuccess>>;
66
+ updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
67
67
  /**
68
68
  * Create an upload session for a profile picture.
69
69
  *
@@ -83,7 +83,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
83
83
  * );
84
84
  * const uploadSessionId = session.upload_session_id;
85
85
  */
86
- createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<RequesterResponseInterface<UploadSessionResponse>>;
86
+ createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
87
87
  /**
88
88
  * Upload media file to the upload session.
89
89
  *
@@ -101,7 +101,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
101
101
  * fileBuffer
102
102
  * );
103
103
  */
104
- uploadMedia(uploadId: string, file: Buffer): Promise<RequesterResponseInterface<UploadBusinessProfileResponse>>;
104
+ uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
105
105
  /**
106
106
  * Get the upload handle information.
107
107
  *
@@ -136,7 +136,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
136
136
  * about: 'Delicious food served daily'
137
137
  * });
138
138
  */
139
- getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>>;
139
+ getUploadHandle(uploadId: string): Promise<UploadHandle>;
140
140
  }
141
141
 
142
142
  export { BusinessProfileAPI as default };
@@ -1,6 +1,6 @@
1
1
  import { BusinessProfileClass, BusinessProfileResponse, UpdateBusinessProfileRequest, UploadSessionResponse, UploadBusinessProfileResponse, UploadHandle } from '../types/businessProfile.js';
2
2
  import { WabaConfigType } from '../types/config.js';
3
- import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
3
+ import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
5
  import '../enums-D7paGoTY.js';
6
6
  import '../types/base.js';
@@ -36,7 +36,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
36
36
  * // Get specific business profile fields
37
37
  * const profile = await whatsappClient.businessProfile.getBusinessProfile('about,address,email');
38
38
  */
39
- getBusinessProfile(fields?: string): Promise<RequesterResponseInterface<BusinessProfileResponse>>;
39
+ getBusinessProfile(fields?: string): Promise<BusinessProfileResponse>;
40
40
  /**
41
41
  * Update your business profile.
42
42
  *
@@ -63,7 +63,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
63
63
  * vertical: BusinessVerticalEnum.RETAIL
64
64
  * });
65
65
  */
66
- updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<RequesterResponseInterface<ResponseSuccess>>;
66
+ updateBusinessProfile(updateRequest: UpdateBusinessProfileRequest): Promise<ResponseSuccess>;
67
67
  /**
68
68
  * Create an upload session for a profile picture.
69
69
  *
@@ -83,7 +83,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
83
83
  * );
84
84
  * const uploadSessionId = session.upload_session_id;
85
85
  */
86
- createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<RequesterResponseInterface<UploadSessionResponse>>;
86
+ createUploadSession(fileLength: number, fileType: string, fileName: string): Promise<UploadSessionResponse>;
87
87
  /**
88
88
  * Upload media file to the upload session.
89
89
  *
@@ -101,7 +101,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
101
101
  * fileBuffer
102
102
  * );
103
103
  */
104
- uploadMedia(uploadId: string, file: Buffer): Promise<RequesterResponseInterface<UploadBusinessProfileResponse>>;
104
+ uploadMedia(uploadId: string, file: Buffer): Promise<UploadBusinessProfileResponse>;
105
105
  /**
106
106
  * Get the upload handle information.
107
107
  *
@@ -136,7 +136,7 @@ declare class BusinessProfileAPI extends BaseAPI implements BusinessProfileClass
136
136
  * about: 'Delicious food served daily'
137
137
  * });
138
138
  */
139
- getUploadHandle(uploadId: string): Promise<RequesterResponseInterface<UploadHandle>>;
139
+ getUploadHandle(uploadId: string): Promise<UploadHandle>;
140
140
  }
141
141
 
142
142
  export { BusinessProfileAPI as default };
@@ -1,2 +1,2 @@
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)}};
1
+ "use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(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 O(t))!l.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 H={};p(H,{default:()=>N});module.exports=T(H);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.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,EAC1C,MAAO,GAGX,IAAMC,EAAe,IAAI,gBAEzB,OAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,QAAQH,CAAM,EAC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B,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
+ {"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, 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<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(updateRequest: UpdateBusinessProfileRequest): Promise<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(fileLength: number, fileType: string, fileName: string): Promise<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(uploadId: string, file: Buffer): Promise<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<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,EAC1C,MAAO,GAGX,IAAM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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,EAAmD,CACxE,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,sBAAsBE,EAAuE,CAC/F,OAAO,KAAK,gBAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,KAAK,UAAUA,CAAa,CAChC,CACJ,CAqBA,MAAM,oBAAoBC,EAAoBC,EAAkBC,EAAkD,CAC9G,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,YAAYM,EAAkBC,EAAsD,CACtF,OAAO,KAAK,gBAA+B,GAAGD,CAAQ,GAAI,KAAK,OAAO,gBAAgCC,CAAI,CAC9G,CAoCA,MAAM,gBAAgBD,EAAyC,CAC3D,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[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};
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,O=new P(B,process.env.DEBUG==="true"||G),D=class{config;client;constructor(t,R){this.config=t,this.client=R,O.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';\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,IAAMA,EAAuBC,GAAwC,CACxE,GAAI,CAACA,GAAU,OAAO,KAAKA,CAAM,EAAE,SAAW,EAC1C,MAAO,GAGX,IAAMC,EAAe,IAAI,gBAEzB,OAAW,CA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D,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,ECEA,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":["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
+ {"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, 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<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(updateRequest: UpdateBusinessProfileRequest): Promise<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(fileLength: number, fileType: string, fileName: string): Promise<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(uploadId: string, file: Buffer): Promise<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<UploadHandle> {\n return this.sendJson(HttpMethodsEnum.Get, `${uploadId}`, this.config[WabaConfigEnum.RequestTimeout], null);\n }\n}\n"],"mappings":"AAAO,IAAMA,EAAuBC,GAAwC,CACxE,GAAI,CAACA,GAAU,OAAO,KAAKA,CAAM,EAAE,SAAW,EAC1C,MAAO,GAGX,IAAMC,EAAe,IAAI,gBAEzB,OAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,Q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O,IAAI,8BAA8B,CAC7C,CAEU,SAAYK,EAAyBC,EAAkBC,EAAiBC,EAAwB,CACtG,OAAO,KAAK,OAAO,QAAWH,EAAQC,EAAUC,EAASC,CAAI,CACjE,CACJ,ECEA,IAAqBC,EAArB,cAAgDC,CAAwC,CACnE,SAAW,4BAE5B,YAAYC,EAAwBC,EAAwB,CACxD,MAAMD,EAAQC,CAAM,CACxB,CAmBA,MAAM,mBAAmBC,EAAmD,CACxE,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,sBAAsBE,EAAuE,CAC/F,OAAO,KAAK,gBAER,GAAG,KAAK,OAAO,kBAA6B,IAAI,KAAK,QAAQ,GAC7D,KAAK,OAAO,gBACZ,KAAK,UAAUA,CAAa,CAChC,CACJ,CAqBA,MAAM,oBAAoBC,EAAoBC,EAAkBC,EAAkD,CAC9G,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,YAAYM,EAAkBC,EAAsD,CACtF,OAAO,KAAK,gBAA+B,GAAGD,CAAQ,GAAI,KAAK,OAAO,gBAAgCC,CAAI,CAC9G,CAoCA,MAAM,gBAAgBD,EAAyC,CAC3D,OAAO,KAAK,eAA8B,GAAGA,CAAQ,GAAI,KAAK,OAAO,gBAAgC,IAAI,CAC7G,CACJ","names":["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,6 +1,6 @@
1
1
  import { WabaConfigType } from '../types/config.mjs';
2
2
  import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.mjs';
3
- import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
3
+ import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
5
  import '../enums-D7paGoTY.mjs';
6
6
  import '../types/base.mjs';
@@ -8,8 +8,8 @@ import '../types/base.mjs';
8
8
  declare class EncryptionAPI extends BaseAPI implements EncryptionClass {
9
9
  private readonly endpoint;
10
10
  constructor(config: WabaConfigType, client: RequesterClass);
11
- getEncryptionPublicKey(): Promise<RequesterResponseInterface<EncryptionPublicKeyResponse>>;
12
- setEncryptionPublicKey(businessPublicKey: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
11
+ getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
12
+ setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
13
13
  }
14
14
 
15
15
  export { EncryptionAPI as default };
@@ -1,6 +1,6 @@
1
1
  import { WabaConfigType } from '../types/config.js';
2
2
  import { EncryptionClass, EncryptionPublicKeyResponse } from '../types/encryption.js';
3
- import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
3
+ import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
5
  import '../enums-D7paGoTY.js';
6
6
  import '../types/base.js';
@@ -8,8 +8,8 @@ import '../types/base.js';
8
8
  declare class EncryptionAPI extends BaseAPI implements EncryptionClass {
9
9
  private readonly endpoint;
10
10
  constructor(config: WabaConfigType, client: RequesterClass);
11
- getEncryptionPublicKey(): Promise<RequesterResponseInterface<EncryptionPublicKeyResponse>>;
12
- setEncryptionPublicKey(businessPublicKey: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
11
+ getEncryptionPublicKey(): Promise<EncryptionPublicKeyResponse>;
12
+ setEncryptionPublicKey(businessPublicKey: string): Promise<ResponseSuccess>;
13
13
  }
14
14
 
15
15
  export { EncryptionAPI as default };
@@ -1 +1 @@
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,MAA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,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"]}
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<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<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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BAA6B,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"]}
@@ -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';\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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,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"]}
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<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<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,CAA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Q,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"]}
@@ -1,6 +1,6 @@
1
1
  import { WabaConfigType } from '../types/config.mjs';
2
- import { FlowClass, FlowsListResponse, FlowCategoryEnum, FlowValidationError, Flow, FlowPreviewResponse, FlowAssetsResponse, FlowMigrationResponse } from '../types/flow.mjs';
3
- import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.mjs';
2
+ import { FlowClass, FlowsListResponse, FlowCategoryEnum, CreateFlowResponse, Flow, FlowPreviewResponse, FlowAssetsResponse, UpdateFlowResponse, ValidateFlowJsonResponse, FlowMigrationResponse } from '../types/flow.mjs';
3
+ import { RequesterClass, ResponseSuccess } from '../types/request.mjs';
4
4
  import BaseAPI from './base.mjs';
5
5
  import '../enums-D7paGoTY.mjs';
6
6
  import '../types/base.mjs';
@@ -13,7 +13,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
13
13
  * @param wabaId - The WABA ID
14
14
  * @returns Promise with the list of flows
15
15
  */
16
- listFlows(wabaId: string): Promise<RequesterResponseInterface<FlowsListResponse>>;
16
+ listFlows(wabaId: string): Promise<FlowsListResponse>;
17
17
  /**
18
18
  * Create Flow
19
19
  *
@@ -28,11 +28,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
28
28
  clone_flow_id?: string;
29
29
  flow_json?: string;
30
30
  publish?: boolean;
31
- }): Promise<RequesterResponseInterface<{
32
- id: string;
33
- success: boolean;
34
- validation_errors?: FlowValidationError[];
35
- }>>;
31
+ }): Promise<CreateFlowResponse>;
36
32
  /**
37
33
  * Get Flow details
38
34
  *
@@ -41,7 +37,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
41
37
  * @param dateFormat - Optional date format
42
38
  * @returns Promise with the flow details or preview response
43
39
  */
44
- getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<RequesterResponseInterface<Flow | FlowPreviewResponse>>;
40
+ getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
45
41
  /**
46
42
  * Get Flow Preview URL
47
43
  *
@@ -49,7 +45,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
49
45
  * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.
50
46
  * @returns Promise with the flow preview details
51
47
  */
52
- getFlowPreview(flowId: string, invalidate?: boolean): Promise<RequesterResponseInterface<FlowPreviewResponse>>;
48
+ getFlowPreview(flowId: string, invalidate?: boolean): Promise<FlowPreviewResponse>;
53
49
  /**
54
50
  * Update Flow Metadata
55
51
  *
@@ -62,21 +58,21 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
62
58
  categories?: FlowCategoryEnum[];
63
59
  endpoint_uri?: string;
64
60
  application_id?: string;
65
- }): Promise<RequesterResponseInterface<ResponseSuccess>>;
61
+ }): Promise<ResponseSuccess>;
66
62
  /**
67
63
  * Delete Flow (only works if the Flow is in DRAFT status)
68
64
  *
69
65
  * @param flowId - The flow ID
70
66
  * @returns Promise with the success status
71
67
  */
72
- deleteFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
68
+ deleteFlow(flowId: string): Promise<ResponseSuccess>;
73
69
  /**
74
70
  * List Assets (e.g., get Flow JSON download URL)
75
71
  *
76
72
  * @param flowId - The flow ID
77
73
  * @returns Promise with the list of assets
78
74
  */
79
- listAssets(flowId: string): Promise<RequesterResponseInterface<FlowAssetsResponse>>;
75
+ listAssets(flowId: string): Promise<FlowAssetsResponse>;
80
76
  /**
81
77
  * Update Flow JSON by uploading a file, buffer, JSON object, or Blob.
82
78
  *
@@ -89,10 +85,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
89
85
  updateFlowJson(flowId: string, data: {
90
86
  file: Blob | Buffer | object;
91
87
  name?: string;
92
- }): Promise<RequesterResponseInterface<{
93
- success: boolean;
94
- validation_errors?: FlowValidationError[];
95
- }>>;
88
+ }): Promise<UpdateFlowResponse>;
96
89
  /**
97
90
  * Validate Flow JSON by attempting an update without publishing.
98
91
  * This is a convenience method; the API doesn't have a dedicated validation endpoint.
@@ -101,25 +94,21 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
101
94
  * @param flowJsonData - The Flow JSON content as a file path (string), Buffer, JSON object, or Blob.
102
95
  * @returns Promise indicating if the JSON is valid and includes validation errors if any.
103
96
  */
104
- validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<RequesterResponseInterface<{
105
- valid: boolean;
106
- success: boolean;
107
- validation_errors?: FlowValidationError[];
108
- }>>;
97
+ validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
109
98
  /**
110
99
  * Publish Flow
111
100
  *
112
101
  * @param flowId - The flow ID
113
102
  * @returns Promise with the success status
114
103
  */
115
- publishFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
104
+ publishFlow(flowId: string): Promise<ResponseSuccess>;
116
105
  /**
117
106
  * Deprecate Flow
118
107
  *
119
108
  * @param flowId - The flow ID
120
109
  * @returns Promise with the success status
121
110
  */
122
- deprecateFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
111
+ deprecateFlow(flowId: string): Promise<ResponseSuccess>;
123
112
  /**
124
113
  * Migrate Flows between WABAs
125
114
  *
@@ -130,7 +119,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
130
119
  migrateFlows(destinationWabaId: string, data: {
131
120
  source_waba_id: string;
132
121
  source_flow_names?: string[];
133
- }): Promise<RequesterResponseInterface<FlowMigrationResponse>>;
122
+ }): Promise<FlowMigrationResponse>;
134
123
  }
135
124
 
136
125
  export { FlowAPI as default };
@@ -1,6 +1,6 @@
1
1
  import { WabaConfigType } from '../types/config.js';
2
- import { FlowClass, FlowsListResponse, FlowCategoryEnum, FlowValidationError, Flow, FlowPreviewResponse, FlowAssetsResponse, FlowMigrationResponse } from '../types/flow.js';
3
- import { RequesterClass, RequesterResponseInterface, ResponseSuccess } from '../types/request.js';
2
+ import { FlowClass, FlowsListResponse, FlowCategoryEnum, CreateFlowResponse, Flow, FlowPreviewResponse, FlowAssetsResponse, UpdateFlowResponse, ValidateFlowJsonResponse, FlowMigrationResponse } from '../types/flow.js';
3
+ import { RequesterClass, ResponseSuccess } from '../types/request.js';
4
4
  import BaseAPI from './base.js';
5
5
  import '../enums-D7paGoTY.js';
6
6
  import '../types/base.js';
@@ -13,7 +13,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
13
13
  * @param wabaId - The WABA ID
14
14
  * @returns Promise with the list of flows
15
15
  */
16
- listFlows(wabaId: string): Promise<RequesterResponseInterface<FlowsListResponse>>;
16
+ listFlows(wabaId: string): Promise<FlowsListResponse>;
17
17
  /**
18
18
  * Create Flow
19
19
  *
@@ -28,11 +28,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
28
28
  clone_flow_id?: string;
29
29
  flow_json?: string;
30
30
  publish?: boolean;
31
- }): Promise<RequesterResponseInterface<{
32
- id: string;
33
- success: boolean;
34
- validation_errors?: FlowValidationError[];
35
- }>>;
31
+ }): Promise<CreateFlowResponse>;
36
32
  /**
37
33
  * Get Flow details
38
34
  *
@@ -41,7 +37,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
41
37
  * @param dateFormat - Optional date format
42
38
  * @returns Promise with the flow details or preview response
43
39
  */
44
- getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<RequesterResponseInterface<Flow | FlowPreviewResponse>>;
40
+ getFlow(flowId: string, fields?: string, dateFormat?: string): Promise<Flow | FlowPreviewResponse>;
45
41
  /**
46
42
  * Get Flow Preview URL
47
43
  *
@@ -49,7 +45,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
49
45
  * @param invalidate - Optional. If true, invalidates existing preview and generates a new one. Defaults to false.
50
46
  * @returns Promise with the flow preview details
51
47
  */
52
- getFlowPreview(flowId: string, invalidate?: boolean): Promise<RequesterResponseInterface<FlowPreviewResponse>>;
48
+ getFlowPreview(flowId: string, invalidate?: boolean): Promise<FlowPreviewResponse>;
53
49
  /**
54
50
  * Update Flow Metadata
55
51
  *
@@ -62,21 +58,21 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
62
58
  categories?: FlowCategoryEnum[];
63
59
  endpoint_uri?: string;
64
60
  application_id?: string;
65
- }): Promise<RequesterResponseInterface<ResponseSuccess>>;
61
+ }): Promise<ResponseSuccess>;
66
62
  /**
67
63
  * Delete Flow (only works if the Flow is in DRAFT status)
68
64
  *
69
65
  * @param flowId - The flow ID
70
66
  * @returns Promise with the success status
71
67
  */
72
- deleteFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
68
+ deleteFlow(flowId: string): Promise<ResponseSuccess>;
73
69
  /**
74
70
  * List Assets (e.g., get Flow JSON download URL)
75
71
  *
76
72
  * @param flowId - The flow ID
77
73
  * @returns Promise with the list of assets
78
74
  */
79
- listAssets(flowId: string): Promise<RequesterResponseInterface<FlowAssetsResponse>>;
75
+ listAssets(flowId: string): Promise<FlowAssetsResponse>;
80
76
  /**
81
77
  * Update Flow JSON by uploading a file, buffer, JSON object, or Blob.
82
78
  *
@@ -89,10 +85,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
89
85
  updateFlowJson(flowId: string, data: {
90
86
  file: Blob | Buffer | object;
91
87
  name?: string;
92
- }): Promise<RequesterResponseInterface<{
93
- success: boolean;
94
- validation_errors?: FlowValidationError[];
95
- }>>;
88
+ }): Promise<UpdateFlowResponse>;
96
89
  /**
97
90
  * Validate Flow JSON by attempting an update without publishing.
98
91
  * This is a convenience method; the API doesn't have a dedicated validation endpoint.
@@ -101,25 +94,21 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
101
94
  * @param flowJsonData - The Flow JSON content as a file path (string), Buffer, JSON object, or Blob.
102
95
  * @returns Promise indicating if the JSON is valid and includes validation errors if any.
103
96
  */
104
- validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<RequesterResponseInterface<{
105
- valid: boolean;
106
- success: boolean;
107
- validation_errors?: FlowValidationError[];
108
- }>>;
97
+ validateFlowJson(flowId: string, flowJsonData: Blob | Buffer | object): Promise<ValidateFlowJsonResponse>;
109
98
  /**
110
99
  * Publish Flow
111
100
  *
112
101
  * @param flowId - The flow ID
113
102
  * @returns Promise with the success status
114
103
  */
115
- publishFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
104
+ publishFlow(flowId: string): Promise<ResponseSuccess>;
116
105
  /**
117
106
  * Deprecate Flow
118
107
  *
119
108
  * @param flowId - The flow ID
120
109
  * @returns Promise with the success status
121
110
  */
122
- deprecateFlow(flowId: string): Promise<RequesterResponseInterface<ResponseSuccess>>;
111
+ deprecateFlow(flowId: string): Promise<ResponseSuccess>;
123
112
  /**
124
113
  * Migrate Flows between WABAs
125
114
  *
@@ -130,7 +119,7 @@ declare class FlowAPI extends BaseAPI implements FlowClass {
130
119
  migrateFlows(destinationWabaId: string, data: {
131
120
  source_waba_id: string;
132
121
  source_flow_names?: string[];
133
- }): Promise<RequesterResponseInterface<FlowMigrationResponse>>;
122
+ }): Promise<FlowMigrationResponse>;
134
123
  }
135
124
 
136
125
  export { FlowAPI as default };