@agenus-io/webhook-centralizer 1.0.8 → 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;
@@ -1,6 +1,5 @@
1
1
  import { webhookCentralizerOrderStatus, webhookCentralizerPlatform } from './../types';
2
2
  import { webhookCentralizerDispatchType } from '../types';
3
- import { JsonValue } from 'aws-sdk/clients/appmesh';
4
3
  interface ICreatePlatformDTO {
5
4
  title: string;
6
5
  platformToken?: string;
@@ -118,7 +117,7 @@ export declare namespace IGetPlatformByTitleDTO {
118
117
  platformSettingId: string;
119
118
  appId: string;
120
119
  workSpaceId: string;
121
- meta: JsonValue | null;
120
+ meta: Record<string, any> | null;
122
121
  createdAt: Date;
123
122
  updatedAt: Date;
124
123
  isDeleted: boolean;
@@ -142,7 +141,7 @@ export declare namespace IGetPlatformByIdDTO {
142
141
  platformSettingId: string;
143
142
  appId: string;
144
143
  workSpaceId: string;
145
- meta: JsonValue | null;
144
+ meta: Record<string, any> | null;
146
145
  createdAt: Date;
147
146
  updatedAt: Date;
148
147
  isDeleted: boolean;
@@ -151,6 +150,25 @@ export declare namespace IGetPlatformByIdDTO {
151
150
  error?: any;
152
151
  };
153
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
+ }
154
172
  export interface IWebhookCentralizeSDK {
155
173
  Create(data: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
156
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.8",
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",