@agenus-io/pixel-backend-sdk 1.0.18 → 1.0.20
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/README.md +9 -9
- package/dist/Class/index.d.ts +3 -2
- package/dist/Class/index.js +21 -2
- package/dist/Class/interface.d.ts +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,11 +5,11 @@ SDK completo para gerenciamento de pixels e envio de vendas para fila AWS SQS do
|
|
|
5
5
|
## Instalação
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @agenus-io/pixel-backend-sdk
|
|
9
9
|
# ou
|
|
10
|
-
yarn add @
|
|
10
|
+
yarn add @agenus-io/pixel-backend-sdk
|
|
11
11
|
# ou
|
|
12
|
-
pnpm add @
|
|
12
|
+
pnpm add @agenus-io/pixel-backend-sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Funcionalidades
|
|
@@ -24,8 +24,8 @@ Este SDK fornece duas funcionalidades principais:
|
|
|
24
24
|
### Configuração Inicial
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
import { PixelSDK } from "@
|
|
28
|
-
import type { AWSConfig, Order } from "@
|
|
27
|
+
import { PixelSDK } from "@agenus-io/pixel-backend-sdk";
|
|
28
|
+
import type { AWSConfig, Order } from "@agenus-io/pixel-backend-sdk";
|
|
29
29
|
|
|
30
30
|
// Configure o SDK com suas credenciais AWS e credenciais da aplicação
|
|
31
31
|
const config: AWSConfig = {
|
|
@@ -248,8 +248,8 @@ APP_TOKEN=your-app-token
|
|
|
248
248
|
## Exemplo Completo
|
|
249
249
|
|
|
250
250
|
```typescript
|
|
251
|
-
import { PixelSDK } from "@
|
|
252
|
-
import type { AWSConfig, Order } from "@
|
|
251
|
+
import { PixelSDK } from "@agenus-io/pixel-backend-sdk";
|
|
252
|
+
import type { AWSConfig, Order } from "@agenus-io/pixel-backend-sdk";
|
|
253
253
|
|
|
254
254
|
// 1. Configurar SDK
|
|
255
255
|
const config: AWSConfig = {
|
|
@@ -329,7 +329,7 @@ async function exemploCompleto() {
|
|
|
329
329
|
Quando houver atualizações no SDK:
|
|
330
330
|
|
|
331
331
|
1. A versão será atualizada no npm
|
|
332
|
-
2. Atualize o pacote nos seus apps: `npm update @
|
|
332
|
+
2. Atualize o pacote nos seus apps: `npm update @agenus-io/pixel-backend-sdk`
|
|
333
333
|
3. Se houver breaking changes, serão documentados nas release notes
|
|
334
334
|
|
|
335
335
|
## Segurança
|
|
@@ -338,7 +338,7 @@ Quando houver atualizações no SDK:
|
|
|
338
338
|
|
|
339
339
|
## API de Pixels
|
|
340
340
|
|
|
341
|
-
O SDK se conecta à API de pixels hospedada em: `https://micro-
|
|
341
|
+
O SDK se conecta à API de pixels hospedada em: `https://micro-service-pixel-production-4826.up.railway.app`
|
|
342
342
|
|
|
343
343
|
Todas as operações CRUD de pixels utilizam autenticação via headers:
|
|
344
344
|
- `app-id`: ID da aplicação
|
package/dist/Class/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AWSConfig, SendSaleParams } from "../config";
|
|
2
|
-
import { ICreatePixelDTO, IGetOnePixelDTO, IGetPixelDTO, IDeletePixelDTO, IUpdatePixelDTO, IPixelSdk } from './interface';
|
|
2
|
+
import { ICreatePixelDTO, IGetOnePixelDTO, IGetPixelDTO, IDeletePixelDTO, IUpdatePixelDTO, IPixelSdk, IUpdateOffersDTO } from './interface';
|
|
3
3
|
/**
|
|
4
4
|
* Classe responsável por com vendas e pixels
|
|
5
5
|
*/
|
|
@@ -15,7 +15,7 @@ export declare class PixelSDK implements IPixelSdk {
|
|
|
15
15
|
* @param appId ID da aplicação
|
|
16
16
|
* @param appToken Token da aplicação
|
|
17
17
|
*/
|
|
18
|
-
constructor(config: AWSConfig, appId: string, appToken: string);
|
|
18
|
+
constructor(config: AWSConfig, appId: string, appToken: string, environment?: "production" | "develop");
|
|
19
19
|
/**
|
|
20
20
|
* Envia uma venda para a fila AWS SQS
|
|
21
21
|
* @param params Parâmetros contendo os dados da venda
|
|
@@ -27,4 +27,5 @@ export declare class PixelSDK implements IPixelSdk {
|
|
|
27
27
|
Delete({ id, workspaceId }: IDeletePixelDTO.Params): Promise<void>;
|
|
28
28
|
Get({ page, pageSize, filter, workSpaceId }: IGetPixelDTO.Params): Promise<IGetPixelDTO.Result>;
|
|
29
29
|
GetOne({ id, workSpaceId }: IGetOnePixelDTO.Params): Promise<IGetOnePixelDTO.Result>;
|
|
30
|
+
UpdateOffers({ id, workspaceId, offerIds, type }: IUpdateOffersDTO.Params): Promise<void>;
|
|
30
31
|
}
|
package/dist/Class/index.js
CHANGED
|
@@ -49,11 +49,11 @@ class PixelSDK {
|
|
|
49
49
|
* @param appId ID da aplicação
|
|
50
50
|
* @param appToken Token da aplicação
|
|
51
51
|
*/
|
|
52
|
-
constructor(config, appId, appToken) {
|
|
52
|
+
constructor(config, appId, appToken, environment = "production") {
|
|
53
53
|
this.queueUrl = config.queueUrl;
|
|
54
54
|
this.appId = appId;
|
|
55
55
|
this.appToken = appToken;
|
|
56
|
-
this.apiUrl = "https://micro-servico-pixel-develop.up.railway.app";
|
|
56
|
+
this.apiUrl = environment === "production" ? "https://micro-service-pixel-production-4826.up.railway.app" : "https://micro-servico-pixel-develop.up.railway.app";
|
|
57
57
|
this.sqs = new aws_sdk_1.default.SQS({
|
|
58
58
|
region: config.region,
|
|
59
59
|
credentials: {
|
|
@@ -197,5 +197,24 @@ class PixelSDK {
|
|
|
197
197
|
throw "Erro ao deletar pixel";
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
+
async UpdateOffers({ id, workspaceId, offerIds, type }) {
|
|
201
|
+
try {
|
|
202
|
+
const token = {
|
|
203
|
+
appId: this.appId,
|
|
204
|
+
secretToken: this.appToken,
|
|
205
|
+
workSpaceId: workspaceId,
|
|
206
|
+
};
|
|
207
|
+
await axios_1.default.post(`${this.apiUrl}/pixels/${id}/offer`, { token, offerIds, type });
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
if (error instanceof axios_1.AxiosError) {
|
|
211
|
+
console.log(error.response?.data);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
console.log(error);
|
|
215
|
+
}
|
|
216
|
+
throw "Erro ao criar pixel";
|
|
217
|
+
}
|
|
218
|
+
}
|
|
200
219
|
}
|
|
201
220
|
exports.PixelSDK = PixelSDK;
|
|
@@ -13,6 +13,7 @@ interface CreatePixel {
|
|
|
13
13
|
purchaseValueType: PurchaseValueType;
|
|
14
14
|
type: MarketingPlatform;
|
|
15
15
|
productIds: string[];
|
|
16
|
+
offerIds: string[];
|
|
16
17
|
sendIp: SendIp;
|
|
17
18
|
pixelMeta?: {
|
|
18
19
|
id: string;
|
|
@@ -59,6 +60,7 @@ export declare namespace IGetPixelDTO {
|
|
|
59
60
|
};
|
|
60
61
|
type Result = {
|
|
61
62
|
data: {
|
|
63
|
+
offerIds: string[];
|
|
62
64
|
productIds: string[];
|
|
63
65
|
id: string;
|
|
64
66
|
code: string;
|
|
@@ -93,6 +95,7 @@ export declare namespace IGetOnePixelDTO {
|
|
|
93
95
|
type Result = {
|
|
94
96
|
data: {
|
|
95
97
|
productIds: string[];
|
|
98
|
+
offerIds: string[];
|
|
96
99
|
pixelTikTok: {
|
|
97
100
|
id: string;
|
|
98
101
|
title?: string;
|
|
@@ -133,11 +136,20 @@ export declare namespace IGetOnePixelDTO {
|
|
|
133
136
|
} | null;
|
|
134
137
|
};
|
|
135
138
|
}
|
|
139
|
+
export declare namespace IUpdateOffersDTO {
|
|
140
|
+
type Params = {
|
|
141
|
+
id: string;
|
|
142
|
+
type: "ADD" | "REMOVE";
|
|
143
|
+
workspaceId: string;
|
|
144
|
+
offerIds: string[];
|
|
145
|
+
};
|
|
146
|
+
}
|
|
136
147
|
export interface IPixelSdk {
|
|
137
148
|
Create(params: ICreatePixelDTO.Params): Promise<void>;
|
|
138
149
|
Update(params: IUpdatePixelDTO.Params): Promise<void>;
|
|
139
150
|
Delete(params: IDeletePixelDTO.Params): Promise<void>;
|
|
140
151
|
Get(params: IGetPixelDTO.Params): Promise<IGetPixelDTO.Result>;
|
|
141
152
|
GetOne(params: IGetOnePixelDTO.Params): Promise<IGetOnePixelDTO.Result>;
|
|
153
|
+
UpdateOffers(params: IUpdateOffersDTO.Params): Promise<void>;
|
|
142
154
|
}
|
|
143
155
|
export {};
|