@adtrackify/at-service-common 1.0.19 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adtrackify/at-service-common",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  import { Destination } from 'aws-sdk/clients/lexmodelbuildingservice';
2
2
  import * as log from 'lambda-log';
3
3
  import { HttpStatusCodes } from '../../libs';
4
- import { ApiResponse } from '../../types/api-response';
4
+ import { ApiResponse, ErrorData } from '../../types/api-response';
5
5
  import { axiosHttpService } from '../generic/http-client';
6
6
 
7
7
  //const BASE_API_URL = process.env.BASE_API_URL;
@@ -44,11 +44,15 @@ export class DestinationsClient {
44
44
  } as ApiResponse<{ destination: Destination; } | any>;
45
45
  };
46
46
 
47
- getPixelDestinations = async (pixelId: string): Promise<ApiResponse<{ destinations: Destination[]; } | any>> => {
47
+ getPixelDestinations = async (pixelId: string): Promise<ApiResponse<{ destinations: Destination[]; } | ErrorData>> => {
48
48
  const client = await this.getClient();
49
- const pixelDestinationsResponse = await client.get(`/?pixelId=${pixelId}`);
50
- log.info('pixelDestinationsResponse', { pixelDestinationsResponse });
51
- return pixelDestinationsResponse;
49
+ const response = await client.get(`/?pixelId=${pixelId}`);
50
+ log.info('getPixelResponse', { response });
51
+ return {
52
+ status: response.status,
53
+ headers: response.headers,
54
+ data: response.status === HttpStatusCodes.OK ? response.data as { destinations: Destination[]; } : response.data as ErrorData
55
+ } as ApiResponse<{ destination: Destination; } | any>;
52
56
  };
53
57
  }
54
58
 
@@ -3,4 +3,6 @@ export interface ApiResponse<T> {
3
3
  data: T;
4
4
  status: number;
5
5
  headers?: AxiosResponseHeaders;
6
- }
6
+ }
7
+
8
+ export type ErrorData = any;