@agenus-io/webhook-centralizer 1.0.7 → 1.0.10

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, IGetPlatformByTitleDTO, IGetPlatformDTO, IGetPlatformWebhooksDTO, IUpdatePlatformDTO, IWebhookCentralizeSDK } from './interface';
1
+ import { ICreatePlatformDTO, IDeletePlatformDTO, IGetPlatformByIdDTO, IGetPlatformByTitleDTO, IGetPlatformDTO, 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
  */
@@ -18,4 +18,5 @@ export declare class WebhookCentralizerSDK implements IWebhookCentralizeSDK {
18
18
  Get({ page, pageSize, filter, workSpaceId }: IGetPlatformDTO.Params): Promise<IGetPlatformDTO.Result>;
19
19
  GetByTitle({ title, workSpaceId }: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
20
20
  GetWebhooks({ id, page, pageSize, filter, workSpaceId }: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
21
+ GetById({ id, workSpaceId }: IGetPlatformByIdDTO.Params): Promise<IGetPlatformByIdDTO.Result>;
21
22
  }
@@ -199,5 +199,31 @@ class WebhookCentralizerSDK {
199
199
  throw "Erro ao listar webhooks";
200
200
  }
201
201
  }
202
+ async GetById({ id, workSpaceId }) {
203
+ try {
204
+ const token = {
205
+ appId: this.appId,
206
+ secretToken: this.appToken,
207
+ workSpaceId,
208
+ };
209
+ const response = await axios_1.default.get(`${this.apiUrl}/platform/${id}`, {
210
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
211
+ });
212
+ return { data: response.data };
213
+ }
214
+ catch (error) {
215
+ let errorMapped = error;
216
+ if (error instanceof axios_1.AxiosError) {
217
+ errorMapped = error.response?.data;
218
+ }
219
+ else {
220
+ errorMapped = error;
221
+ }
222
+ return {
223
+ isError: true,
224
+ error: errorMapped,
225
+ };
226
+ }
227
+ }
202
228
  }
203
229
  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,12 +117,39 @@ 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;
125
124
  };
126
125
  }
126
+ export declare namespace IGetPlatformByIdDTO {
127
+ type Params = {
128
+ id: string;
129
+ workSpaceId: string;
130
+ };
131
+ type Result = {
132
+ data?: {
133
+ id: string;
134
+ title: string;
135
+ status: boolean;
136
+ dispatchType: webhookCentralizerDispatchType;
137
+ type: webhookCentralizerPlatform;
138
+ apiToken: string | null;
139
+ slug: string | null;
140
+ url: string;
141
+ platformSettingId: string;
142
+ appId: string;
143
+ workSpaceId: string;
144
+ meta: Record<string, any> | null;
145
+ createdAt: Date;
146
+ updatedAt: Date;
147
+ isDeleted: boolean;
148
+ };
149
+ isError?: boolean;
150
+ error?: any;
151
+ };
152
+ }
127
153
  export interface IWebhookCentralizeSDK {
128
154
  Create(data: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
129
155
  Update(data: IUpdatePlatformDTO.Params): Promise<IUpdatePlatformDTO.Result>;
@@ -131,5 +157,6 @@ export interface IWebhookCentralizeSDK {
131
157
  Get(data: IGetPlatformDTO.Params): Promise<IGetPlatformDTO.Result>;
132
158
  GetWebhooks(data: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
133
159
  GetByTitle(data: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
160
+ GetById(data: IGetPlatformByIdDTO.Params): Promise<IGetPlatformByIdDTO.Result>;
134
161
  }
135
162
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenus-io/webhook-centralizer",
3
- "version": "1.0.7",
3
+ "version": "1.0.10",
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",