@agenus-io/webhook-centralizer 1.0.6 → 1.0.8

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
  }
@@ -62,15 +62,16 @@ class WebhookCentralizerSDK {
62
62
  return response.data;
63
63
  }
64
64
  catch (error) {
65
+ let errorMapped = error;
65
66
  if (error instanceof axios_1.AxiosError) {
66
- console.log(error.response?.data);
67
+ errorMapped = error.response?.data;
67
68
  }
68
69
  else {
69
- console.log(error);
70
+ errorMapped = error;
70
71
  }
71
72
  return {
72
73
  isError: true,
73
- error: error,
74
+ error: errorMapped,
74
75
  };
75
76
  }
76
77
  }
@@ -88,15 +89,16 @@ class WebhookCentralizerSDK {
88
89
  return result;
89
90
  }
90
91
  catch (error) {
92
+ let errorMapped = error;
91
93
  if (error instanceof axios_1.AxiosError) {
92
- console.log(error.response?.data);
94
+ errorMapped = error.response?.data;
93
95
  }
94
96
  else {
95
- console.log(error);
97
+ errorMapped = error;
96
98
  }
97
99
  return {
98
100
  isError: true,
99
- error: error,
101
+ error: errorMapped,
100
102
  };
101
103
  }
102
104
  }
@@ -115,15 +117,16 @@ class WebhookCentralizerSDK {
115
117
  };
116
118
  }
117
119
  catch (error) {
120
+ let errorMapped = error;
118
121
  if (error instanceof axios_1.AxiosError) {
119
- console.log(error.response?.data);
122
+ errorMapped = error.response?.data;
120
123
  }
121
124
  else {
122
- console.log(error);
125
+ errorMapped = error;
123
126
  }
124
127
  return {
125
128
  isError: true,
126
- error: error,
129
+ error: errorMapped,
127
130
  };
128
131
  }
129
132
  }
@@ -196,5 +199,31 @@ class WebhookCentralizerSDK {
196
199
  throw "Erro ao listar webhooks";
197
200
  }
198
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
+ }
199
228
  }
200
229
  exports.WebhookCentralizerSDK = WebhookCentralizerSDK;
@@ -124,6 +124,33 @@ export declare namespace IGetPlatformByTitleDTO {
124
124
  isDeleted: boolean;
125
125
  };
126
126
  }
127
+ export declare namespace IGetPlatformByIdDTO {
128
+ type Params = {
129
+ id: string;
130
+ workSpaceId: string;
131
+ };
132
+ type Result = {
133
+ data?: {
134
+ id: string;
135
+ title: string;
136
+ status: boolean;
137
+ dispatchType: webhookCentralizerDispatchType;
138
+ type: webhookCentralizerPlatform;
139
+ apiToken: string | null;
140
+ slug: string | null;
141
+ url: string;
142
+ platformSettingId: string;
143
+ appId: string;
144
+ workSpaceId: string;
145
+ meta: JsonValue | null;
146
+ createdAt: Date;
147
+ updatedAt: Date;
148
+ isDeleted: boolean;
149
+ };
150
+ isError?: boolean;
151
+ error?: any;
152
+ };
153
+ }
127
154
  export interface IWebhookCentralizeSDK {
128
155
  Create(data: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
129
156
  Update(data: IUpdatePlatformDTO.Params): Promise<IUpdatePlatformDTO.Result>;
@@ -131,5 +158,6 @@ export interface IWebhookCentralizeSDK {
131
158
  Get(data: IGetPlatformDTO.Params): Promise<IGetPlatformDTO.Result>;
132
159
  GetWebhooks(data: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
133
160
  GetByTitle(data: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
161
+ GetById(data: IGetPlatformByIdDTO.Params): Promise<IGetPlatformByIdDTO.Result>;
134
162
  }
135
163
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenus-io/webhook-centralizer",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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",