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

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, IUpdateOffersDTO } from './interface';
2
+ import { ICreatePixelDTO, IGetOnePixelDTO, IGetPixelDTO, IDeletePixelDTO, IUpdatePixelDTO, IPixelSdk, IUpdateOffersDTO, IMetricsDTO } from './interface';
3
3
  /**
4
4
  * Classe responsável por com vendas e pixels
5
5
  */
@@ -25,7 +25,8 @@ export declare class PixelSDK implements IPixelSdk {
25
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
- Get({ page, pageSize, filter, workSpaceId }: IGetPixelDTO.Params): Promise<IGetPixelDTO.Result>;
28
+ Get({ page, pageSize, filter, workSpaceId, platform, productIds, offerIds }: IGetPixelDTO.Params): Promise<IGetPixelDTO.Result>;
29
29
  GetOne({ id, workSpaceId }: IGetOnePixelDTO.Params): Promise<IGetOnePixelDTO.Result>;
30
30
  UpdateOffers({ id, workspaceId, offerIds, type }: IUpdateOffersDTO.Params): Promise<void>;
31
+ Metrics({ workSpaceId, platform, productIds, offerIds, filter }: IMetricsDTO.Params): Promise<IMetricsDTO.Result>;
31
32
  }
@@ -151,7 +151,7 @@ class PixelSDK {
151
151
  throw "Erro ao deletar pixel";
152
152
  }
153
153
  }
154
- async Get({ page, pageSize, filter, workSpaceId }) {
154
+ async Get({ page, pageSize, filter, workSpaceId, platform, productIds, offerIds }) {
155
155
  try {
156
156
  const token = {
157
157
  appId: this.appId,
@@ -160,7 +160,7 @@ class PixelSDK {
160
160
  };
161
161
  const response = await axios_1.default.get(`${this.apiUrl}/pixels`, {
162
162
  headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
163
- params: { page, pageSize, filter },
163
+ params: { page, pageSize, filter, platform, productIds, offerIds },
164
164
  });
165
165
  return response.data;
166
166
  }
@@ -217,5 +217,28 @@ class PixelSDK {
217
217
  throw "Erro ao criar pixel";
218
218
  }
219
219
  }
220
+ async Metrics({ workSpaceId, platform, productIds, offerIds, filter }) {
221
+ try {
222
+ const token = {
223
+ appId: this.appId,
224
+ secretToken: this.appToken,
225
+ workSpaceId: workSpaceId,
226
+ };
227
+ const response = await axios_1.default.get(`${this.apiUrl}/metrics`, {
228
+ headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
229
+ params: { platform, productIds, offerIds, filter },
230
+ });
231
+ return response.data;
232
+ }
233
+ catch (error) {
234
+ if (error instanceof axios_1.AxiosError) {
235
+ console.log(error.response?.data);
236
+ }
237
+ else {
238
+ console.log(error);
239
+ }
240
+ throw "Erro ao obter métricas";
241
+ }
242
+ }
220
243
  }
221
244
  exports.PixelSDK = PixelSDK;
@@ -60,6 +60,9 @@ export declare namespace IGetPixelDTO {
60
60
  page: number;
61
61
  pageSize: number;
62
62
  filter?: string;
63
+ platform?: MarketingPlatform;
64
+ productIds?: string[];
65
+ offerIds?: string[];
63
66
  };
64
67
  type Result = {
65
68
  data: {
@@ -147,6 +150,22 @@ export declare namespace IUpdateOffersDTO {
147
150
  offerIds: string[];
148
151
  };
149
152
  }
153
+ export declare namespace IMetricsDTO {
154
+ type Params = {
155
+ workSpaceId: string;
156
+ platform?: MarketingPlatform;
157
+ productIds?: string[];
158
+ offerIds?: string[];
159
+ filter?: string;
160
+ };
161
+ type Result = {
162
+ metrics: {
163
+ total: number;
164
+ active: number;
165
+ sendedEvents: number;
166
+ };
167
+ };
168
+ }
150
169
  export interface IPixelSdk {
151
170
  Create(params: ICreatePixelDTO.Params): Promise<ICreatePixelDTO.Result>;
152
171
  Update(params: IUpdatePixelDTO.Params): Promise<void>;
@@ -154,5 +173,6 @@ export interface IPixelSdk {
154
173
  Get(params: IGetPixelDTO.Params): Promise<IGetPixelDTO.Result>;
155
174
  GetOne(params: IGetOnePixelDTO.Params): Promise<IGetOnePixelDTO.Result>;
156
175
  UpdateOffers(params: IUpdateOffersDTO.Params): Promise<void>;
176
+ Metrics(params: IMetricsDTO.Params): Promise<IMetricsDTO.Result>;
157
177
  }
158
178
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenus-io/pixel-backend-sdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
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",