@agenus-io/webhook-centralizer 1.0.4 → 1.0.6
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.
- package/dist/Class/index.d.ts +4 -3
- package/dist/Class/index.js +46 -5
- package/dist/Class/interface.d.ts +42 -7
- package/package.json +1 -1
package/dist/Class/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICreatePlatformDTO, IDeletePlatformDTO, IGetPlatformDTO, IGetPlatformWebhooksDTO, IUpdatePlatformDTO, IWebhookCentralizeSDK } from './interface';
|
|
1
|
+
import { ICreatePlatformDTO, IDeletePlatformDTO, 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
|
*/
|
|
@@ -13,8 +13,9 @@ export declare class WebhookCentralizerSDK implements IWebhookCentralizeSDK {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(appId: string, appToken: string, environment?: "production" | "develop");
|
|
15
15
|
Create({ workSpaceId, ...data }: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
|
|
16
|
-
Update({ id, workSpaceId, ...data }: IUpdatePlatformDTO.Params): Promise<
|
|
17
|
-
Delete({ id, workSpaceId }: IDeletePlatformDTO.Params): Promise<
|
|
16
|
+
Update({ id, workSpaceId, ...data }: IUpdatePlatformDTO.Params): Promise<IUpdatePlatformDTO.Result>;
|
|
17
|
+
Delete({ id, workSpaceId }: IDeletePlatformDTO.Params): Promise<IDeletePlatformDTO.Result>;
|
|
18
18
|
Get({ page, pageSize, filter, workSpaceId }: IGetPlatformDTO.Params): Promise<IGetPlatformDTO.Result>;
|
|
19
|
+
GetByTitle({ title, workSpaceId }: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
|
|
19
20
|
GetWebhooks({ id, page, pageSize, filter, workSpaceId }: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
|
|
20
21
|
}
|
package/dist/Class/index.js
CHANGED
|
@@ -56,7 +56,9 @@ class WebhookCentralizerSDK {
|
|
|
56
56
|
secretToken: this.appToken,
|
|
57
57
|
workSpaceId,
|
|
58
58
|
};
|
|
59
|
-
const response = await axios_1.default.post(`${this.apiUrl}/platform`, {
|
|
59
|
+
const response = await axios_1.default.post(`${this.apiUrl}/platform`, { ...data }, {
|
|
60
|
+
headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId }
|
|
61
|
+
});
|
|
60
62
|
return response.data;
|
|
61
63
|
}
|
|
62
64
|
catch (error) {
|
|
@@ -66,7 +68,10 @@ class WebhookCentralizerSDK {
|
|
|
66
68
|
else {
|
|
67
69
|
console.log(error);
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
return {
|
|
72
|
+
isError: true,
|
|
73
|
+
error: error,
|
|
74
|
+
};
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
async Update({ id, workSpaceId, ...data }) {
|
|
@@ -76,7 +81,11 @@ class WebhookCentralizerSDK {
|
|
|
76
81
|
secretToken: this.appToken,
|
|
77
82
|
workSpaceId,
|
|
78
83
|
};
|
|
79
|
-
await axios_1.default.put(`${this.apiUrl}/platform/${id}`, { token, ...data }
|
|
84
|
+
const res = await axios_1.default.put(`${this.apiUrl}/platform/${id}`, { token, ...data }, {
|
|
85
|
+
headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId }
|
|
86
|
+
});
|
|
87
|
+
const result = res.data;
|
|
88
|
+
return result;
|
|
80
89
|
}
|
|
81
90
|
catch (error) {
|
|
82
91
|
if (error instanceof axios_1.AxiosError) {
|
|
@@ -85,7 +94,10 @@ class WebhookCentralizerSDK {
|
|
|
85
94
|
else {
|
|
86
95
|
console.log(error);
|
|
87
96
|
}
|
|
88
|
-
|
|
97
|
+
return {
|
|
98
|
+
isError: true,
|
|
99
|
+
error: error,
|
|
100
|
+
};
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
async Delete({ id, workSpaceId }) {
|
|
@@ -98,6 +110,9 @@ class WebhookCentralizerSDK {
|
|
|
98
110
|
await axios_1.default.delete(`${this.apiUrl}/platform/${id}`, {
|
|
99
111
|
headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
|
|
100
112
|
});
|
|
113
|
+
return {
|
|
114
|
+
isError: false,
|
|
115
|
+
};
|
|
101
116
|
}
|
|
102
117
|
catch (error) {
|
|
103
118
|
if (error instanceof axios_1.AxiosError) {
|
|
@@ -106,7 +121,10 @@ class WebhookCentralizerSDK {
|
|
|
106
121
|
else {
|
|
107
122
|
console.log(error);
|
|
108
123
|
}
|
|
109
|
-
|
|
124
|
+
return {
|
|
125
|
+
isError: true,
|
|
126
|
+
error: error,
|
|
127
|
+
};
|
|
110
128
|
}
|
|
111
129
|
}
|
|
112
130
|
async Get({ page, pageSize, filter, workSpaceId }) {
|
|
@@ -132,6 +150,29 @@ class WebhookCentralizerSDK {
|
|
|
132
150
|
throw "Erro ao listar pixel";
|
|
133
151
|
}
|
|
134
152
|
}
|
|
153
|
+
async GetByTitle({ title, workSpaceId }) {
|
|
154
|
+
try {
|
|
155
|
+
const token = {
|
|
156
|
+
appId: this.appId,
|
|
157
|
+
secretToken: this.appToken,
|
|
158
|
+
workSpaceId,
|
|
159
|
+
};
|
|
160
|
+
const response = await axios_1.default.get(`${this.apiUrl}/platform/title`, {
|
|
161
|
+
headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
|
|
162
|
+
params: { title },
|
|
163
|
+
});
|
|
164
|
+
return response.data;
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (error instanceof axios_1.AxiosError) {
|
|
168
|
+
console.log(error.response?.data);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
console.log(error);
|
|
172
|
+
}
|
|
173
|
+
throw "Erro ao buscar plataforma por título";
|
|
174
|
+
}
|
|
175
|
+
}
|
|
135
176
|
async GetWebhooks({ id, page, pageSize, filter, workSpaceId }) {
|
|
136
177
|
try {
|
|
137
178
|
const token = {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { webhookCentralizerOrderStatus, webhookCentralizerPlatform } from './../types';
|
|
2
2
|
import { webhookCentralizerDispatchType } from '../types';
|
|
3
|
+
import { JsonValue } from 'aws-sdk/clients/appmesh';
|
|
3
4
|
interface ICreatePlatformDTO {
|
|
4
5
|
title: string;
|
|
5
|
-
platformToken
|
|
6
|
+
platformToken?: string;
|
|
6
7
|
dispatchType: webhookCentralizerDispatchType;
|
|
7
8
|
type: webhookCentralizerPlatform;
|
|
8
9
|
apiToken?: string;
|
|
@@ -13,7 +14,9 @@ interface ICreatePlatformDTO {
|
|
|
13
14
|
export declare namespace ICreatePlatformDTO {
|
|
14
15
|
type Params = ICreatePlatformDTO;
|
|
15
16
|
type Result = {
|
|
16
|
-
id
|
|
17
|
+
id?: string;
|
|
18
|
+
error?: any;
|
|
19
|
+
isError?: boolean;
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
22
|
export declare namespace IUpdatePlatformDTO {
|
|
@@ -21,12 +24,20 @@ export declare namespace IUpdatePlatformDTO {
|
|
|
21
24
|
id: string;
|
|
22
25
|
workSpaceId: string;
|
|
23
26
|
} & Partial<ICreatePlatformDTO>;
|
|
27
|
+
type Result = {
|
|
28
|
+
isError?: boolean;
|
|
29
|
+
error?: any;
|
|
30
|
+
};
|
|
24
31
|
}
|
|
25
32
|
export declare namespace IDeletePlatformDTO {
|
|
26
33
|
type Params = {
|
|
27
34
|
id: string;
|
|
28
35
|
workSpaceId: string;
|
|
29
36
|
};
|
|
37
|
+
type Result = {
|
|
38
|
+
isError?: boolean;
|
|
39
|
+
error?: any;
|
|
40
|
+
};
|
|
30
41
|
}
|
|
31
42
|
export declare namespace IGetPlatformDTO {
|
|
32
43
|
type Params = {
|
|
@@ -90,11 +101,35 @@ export declare namespace IGetPlatformWebhooksDTO {
|
|
|
90
101
|
};
|
|
91
102
|
};
|
|
92
103
|
}
|
|
104
|
+
export declare namespace IGetPlatformByTitleDTO {
|
|
105
|
+
type Params = {
|
|
106
|
+
title: string;
|
|
107
|
+
workSpaceId: string;
|
|
108
|
+
};
|
|
109
|
+
type Result = {
|
|
110
|
+
id: string;
|
|
111
|
+
title: string;
|
|
112
|
+
status: boolean;
|
|
113
|
+
dispatchType: webhookCentralizerDispatchType;
|
|
114
|
+
type: webhookCentralizerPlatform;
|
|
115
|
+
apiToken: string | null;
|
|
116
|
+
slug: string | null;
|
|
117
|
+
url: string;
|
|
118
|
+
platformSettingId: string;
|
|
119
|
+
appId: string;
|
|
120
|
+
workSpaceId: string;
|
|
121
|
+
meta: JsonValue | null;
|
|
122
|
+
createdAt: Date;
|
|
123
|
+
updatedAt: Date;
|
|
124
|
+
isDeleted: boolean;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
93
127
|
export interface IWebhookCentralizeSDK {
|
|
94
|
-
Create
|
|
95
|
-
Update
|
|
96
|
-
Delete
|
|
97
|
-
Get
|
|
98
|
-
GetWebhooks
|
|
128
|
+
Create(data: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
|
|
129
|
+
Update(data: IUpdatePlatformDTO.Params): Promise<IUpdatePlatformDTO.Result>;
|
|
130
|
+
Delete(data: IDeletePlatformDTO.Params): Promise<IDeletePlatformDTO.Result>;
|
|
131
|
+
Get(data: IGetPlatformDTO.Params): Promise<IGetPlatformDTO.Result>;
|
|
132
|
+
GetWebhooks(data: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
|
|
133
|
+
GetByTitle(data: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
|
|
99
134
|
}
|
|
100
135
|
export {};
|
package/package.json
CHANGED