@agenus-io/pixel-backend-sdk 1.0.19 → 1.0.21

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,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
  */
@@ -22,9 +22,10 @@ export declare class PixelSDK implements IPixelSdk {
22
22
  * @throws {Error} Se houver erro ao enviar a mensagem para a fila
23
23
  */
24
24
  SendOrder(params: SendSaleParams): Promise<void>;
25
- Create({ data, workspaceId }: ICreatePixelDTO.Params): Promise<void>;
25
+ Create({ data, workspaceId }: ICreatePixelDTO.Params): Promise<ICreatePixelDTO.Result>;
26
26
  Update({ data, workspaceId, id }: IUpdatePixelDTO.Params): Promise<void>;
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
  }
@@ -98,7 +98,8 @@ class PixelSDK {
98
98
  secretToken: this.appToken,
99
99
  workSpaceId: workspaceId,
100
100
  };
101
- await axios_1.default.post(`${this.apiUrl}/pixels`, { token, ...data });
101
+ const response = await axios_1.default.post(`${this.apiUrl}/pixels`, { token, ...data });
102
+ return response.data;
102
103
  }
103
104
  catch (error) {
104
105
  if (error instanceof axios_1.AxiosError) {
@@ -197,5 +198,24 @@ class PixelSDK {
197
198
  throw "Erro ao deletar pixel";
198
199
  }
199
200
  }
201
+ async UpdateOffers({ id, workspaceId, offerIds, type }) {
202
+ try {
203
+ const token = {
204
+ appId: this.appId,
205
+ secretToken: this.appToken,
206
+ workSpaceId: workspaceId,
207
+ };
208
+ await axios_1.default.post(`${this.apiUrl}/pixels/${id}/offer`, { token, offerIds, type });
209
+ }
210
+ catch (error) {
211
+ if (error instanceof axios_1.AxiosError) {
212
+ console.log(error.response?.data);
213
+ }
214
+ else {
215
+ console.log(error);
216
+ }
217
+ throw "Erro ao criar pixel";
218
+ }
219
+ }
200
220
  }
201
221
  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;
@@ -36,6 +37,9 @@ export declare namespace ICreatePixelDTO {
36
37
  workspaceId: string;
37
38
  data: CreatePixel;
38
39
  };
40
+ type Result = {
41
+ id: string;
42
+ };
39
43
  }
40
44
  export declare namespace IUpdatePixelDTO {
41
45
  type Params = {
@@ -59,6 +63,7 @@ export declare namespace IGetPixelDTO {
59
63
  };
60
64
  type Result = {
61
65
  data: {
66
+ offerIds: string[];
62
67
  productIds: string[];
63
68
  id: string;
64
69
  code: string;
@@ -93,6 +98,7 @@ export declare namespace IGetOnePixelDTO {
93
98
  type Result = {
94
99
  data: {
95
100
  productIds: string[];
101
+ offerIds: string[];
96
102
  pixelTikTok: {
97
103
  id: string;
98
104
  title?: string;
@@ -133,11 +139,20 @@ export declare namespace IGetOnePixelDTO {
133
139
  } | null;
134
140
  };
135
141
  }
142
+ export declare namespace IUpdateOffersDTO {
143
+ type Params = {
144
+ id: string;
145
+ type: "ADD" | "REMOVE";
146
+ workspaceId: string;
147
+ offerIds: string[];
148
+ };
149
+ }
136
150
  export interface IPixelSdk {
137
- Create(params: ICreatePixelDTO.Params): Promise<void>;
151
+ Create(params: ICreatePixelDTO.Params): Promise<ICreatePixelDTO.Result>;
138
152
  Update(params: IUpdatePixelDTO.Params): Promise<void>;
139
153
  Delete(params: IDeletePixelDTO.Params): Promise<void>;
140
154
  Get(params: IGetPixelDTO.Params): Promise<IGetPixelDTO.Result>;
141
155
  GetOne(params: IGetOnePixelDTO.Params): Promise<IGetOnePixelDTO.Result>;
156
+ UpdateOffers(params: IUpdateOffersDTO.Params): Promise<void>;
142
157
  }
143
158
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenus-io/pixel-backend-sdk",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "SDK para envio de vendas para fila AWS SQS do micro-serviço de pixels",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",