@agenus-io/webhook-centralizer 1.0.20 → 1.0.21

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, IGetPlatformSettingsDTO, IGetPlatformWebhookByIdDTO, IGetPlatformWebhooksDTO, IUpdatePlatformDTO, IWebhookCentralizeSDK } from './interface';
1
+ import { ICreatePlatformDTO, IDeletePlatformDTO, IGetPlatformByIdDTO, IGetPlatformByTitleDTO, IGetPlatformDTO, IGetPlatformSettingsDTO, IGetPlatformWebhookByIdDTO, IGetPlatformWebhooksDTO, IKpiDTO, 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
  */
@@ -21,4 +21,5 @@ export declare class WebhookCentralizerSDK implements IWebhookCentralizeSDK {
21
21
  GetById({ id, workSpaceId }: IGetPlatformByIdDTO.Params): Promise<IGetPlatformByIdDTO.Result>;
22
22
  GetWebhookById({ id, workSpaceId }: IGetPlatformWebhookByIdDTO.Params): Promise<IGetPlatformWebhookByIdDTO.Result>;
23
23
  GetPlatformSettings(): Promise<IGetPlatformSettingsDTO.Result>;
24
+ Kpi({ id, status, event, workSpaceId }: IKpiDTO.Params): Promise<IKpiDTO.Result>;
24
25
  }
@@ -275,5 +275,33 @@ class WebhookCentralizerSDK {
275
275
  };
276
276
  }
277
277
  }
278
+ async Kpi({ id, status, event, workSpaceId }) {
279
+ try {
280
+ const token = {
281
+ appId: this.appId,
282
+ secretToken: this.appToken,
283
+ workSpaceId,
284
+ };
285
+ const response = await axios_1.default.get(`${this.apiUrl}/platform/kpi`, {
286
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
287
+ params: { id, status, event },
288
+ });
289
+ return response.data;
290
+ }
291
+ catch (error) {
292
+ let errorMapped = error;
293
+ if (error instanceof axios_1.AxiosError) {
294
+ errorMapped = error.response?.data;
295
+ }
296
+ else {
297
+ errorMapped = error;
298
+ }
299
+ return {
300
+ total: 0,
301
+ amountAccepted: 0,
302
+ amountRejected: 0,
303
+ };
304
+ }
305
+ }
278
306
  }
279
307
  exports.WebhookCentralizerSDK = WebhookCentralizerSDK;
@@ -196,6 +196,19 @@ export declare namespace IGetPlatformSettingsDTO {
196
196
  }[];
197
197
  };
198
198
  }
199
+ export declare namespace IKpiDTO {
200
+ type Params = {
201
+ id: string;
202
+ status: webhookCentralizerOrderStatus[];
203
+ event: webhookCentralizerEvent[];
204
+ workSpaceId: string;
205
+ };
206
+ type Result = {
207
+ total: number;
208
+ amountAccepted: number;
209
+ amountRejected: number;
210
+ };
211
+ }
199
212
  export interface IWebhookCentralizeSDK {
200
213
  Create(data: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
201
214
  Update(data: IUpdatePlatformDTO.Params): Promise<IUpdatePlatformDTO.Result>;
@@ -204,5 +217,6 @@ export interface IWebhookCentralizeSDK {
204
217
  GetWebhooks(data: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
205
218
  GetByTitle(data: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
206
219
  GetById(data: IGetPlatformByIdDTO.Params): Promise<IGetPlatformByIdDTO.Result>;
220
+ Kpi(data: IKpiDTO.Params): Promise<IKpiDTO.Result>;
207
221
  }
208
222
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenus-io/webhook-centralizer",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
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",