@agenus-io/webhook-centralizer 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { ICreatePlatformDTO, IDeletePlatformDTO, IGetPlatformByIdDTO, IGetPlatformByTitleDTO, IGetPlatformDTO, IGetPlatformWebhooksDTO, IUpdatePlatformDTO, IWebhookCentralizeSDK } from './interface';
1
+ import { ICreatePlatformDTO, IDeletePlatformDTO, IGetPlatformByIdDTO, IGetPlatformByTitleDTO, IGetPlatformDTO, IGetPlatformWebhookByIdDTO, IGetPlatformWebhooksDTO, IUpdatePlatformDTO, IWebhookCentralizeSDK } from './interface';
2
2
  /**
3
3
  * Classe responsável pela centralização de webhooks de plataformas de pagamento e envio de webhooks para o microserviço de webhooks
4
4
  */
@@ -19,4 +19,5 @@ export declare class WebhookCentralizerSDK implements IWebhookCentralizeSDK {
19
19
  GetByTitle({ title, workSpaceId }: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
20
20
  GetWebhooks({ id, page, pageSize, filter, workSpaceId }: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
21
21
  GetById({ id, workSpaceId }: IGetPlatformByIdDTO.Params): Promise<IGetPlatformByIdDTO.Result>;
22
+ GetWebhookById({ id, workSpaceId }: IGetPlatformWebhookByIdDTO.Params): Promise<IGetPlatformWebhookByIdDTO.Result>;
22
23
  }
@@ -225,5 +225,31 @@ class WebhookCentralizerSDK {
225
225
  };
226
226
  }
227
227
  }
228
+ async GetWebhookById({ id, workSpaceId }) {
229
+ try {
230
+ const token = {
231
+ appId: this.appId,
232
+ secretToken: this.appToken,
233
+ workSpaceId,
234
+ };
235
+ const response = await axios_1.default.get(`${this.apiUrl}/platform/webhooks/${id}`, {
236
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
237
+ });
238
+ return { data: response.data };
239
+ }
240
+ catch (error) {
241
+ let errorMapped = error;
242
+ if (error instanceof axios_1.AxiosError) {
243
+ errorMapped = error.response?.data;
244
+ }
245
+ else {
246
+ errorMapped = error;
247
+ }
248
+ return {
249
+ isError: true,
250
+ error: errorMapped,
251
+ };
252
+ }
253
+ }
228
254
  }
229
255
  exports.WebhookCentralizerSDK = WebhookCentralizerSDK;
@@ -150,6 +150,25 @@ export declare namespace IGetPlatformByIdDTO {
150
150
  error?: any;
151
151
  };
152
152
  }
153
+ export declare namespace IGetPlatformWebhookByIdDTO {
154
+ type Params = {
155
+ id: string;
156
+ workSpaceId: string;
157
+ };
158
+ type Result = {
159
+ data?: {
160
+ data: any;
161
+ id: string;
162
+ status: webhookCentralizerOrderStatus;
163
+ code: string;
164
+ createdAt: Date;
165
+ updatedAt: Date;
166
+ platformsType: webhookCentralizerPlatform;
167
+ };
168
+ isError?: boolean;
169
+ error?: any;
170
+ };
171
+ }
153
172
  export interface IWebhookCentralizeSDK {
154
173
  Create(data: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
155
174
  Update(data: IUpdatePlatformDTO.Params): Promise<IUpdatePlatformDTO.Result>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenus-io/webhook-centralizer",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "SDK para centralização de webhooks focado atualmente em plataformas de pagamentos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",