@adtrackify/at-service-common 1.0.20 → 1.0.22

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.20",
3
+ "version": "1.0.22",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,7 +1,6 @@
1
1
  import { Destination } from 'aws-sdk/clients/lexmodelbuildingservice';
2
2
  import * as log from 'lambda-log';
3
- import { HttpStatusCodes } from '../../libs';
4
- import { ApiResponse, ErrorData } from '../../types/api-response';
3
+ import { ApiResponse } from '../../types/api-response';
5
4
  import { axiosHttpService } from '../generic/http-client';
6
5
 
7
6
  //const BASE_API_URL = process.env.BASE_API_URL;
@@ -33,28 +32,28 @@ export class DestinationsClient {
33
32
  return axiosHttpService(this.getConfig());
34
33
  };
35
34
 
36
- createDestination = async (createDestinationRequest: any): Promise<ApiResponse<{ destination: Destination; } | any>> => {
35
+ createDestination = async (createDestinationRequest: any): Promise<ApiResponse<CreateDestinationResponseData>> => {
37
36
  const client = await this.getClient();
38
- const createDestinationResponse = await client.post('/', createDestinationRequest);
39
- log.info('createDestinationResponse', { createDestinationResponse });
40
- return {
41
- status: createDestinationResponse.status,
42
- headers: createDestinationResponse.headers,
43
- data: createDestinationResponse.status === HttpStatusCodes.OK ? createDestinationResponse.data as { destination: Destination; } : createDestinationResponse.data
44
- } as ApiResponse<{ destination: Destination; } | any>;
37
+ const response = await client.post('/', createDestinationRequest);
38
+ log.info('createDestinationResponse', { response });
39
+ return response as ApiResponse<CreateDestinationResponseData>;
45
40
  };
46
41
 
47
- getPixelDestinations = async (pixelId: string): Promise<ApiResponse<{ destinations: Destination[]; } | ErrorData>> => {
42
+ getPixelDestinations = async (pixelId: string): Promise<ApiResponse<GetDestinationsResponseData>> => {
48
43
  const client = await this.getClient();
49
44
  const response = await client.get(`/?pixelId=${pixelId}`);
50
45
  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>;
46
+ return response as ApiResponse<GetDestinationsResponseData>;
56
47
  };
57
48
  }
58
49
 
50
+ export interface GetDestinationsResponseData {
51
+ destinations: Destination[];
52
+ [ key: string ]: any;
53
+ }
54
+ export interface CreateDestinationResponseData {
55
+ destination: Destination;
56
+ [ key: string ]: any;
57
+ }
59
58
 
60
59
  export default DestinationsClient;
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './clients';
1
+ export * from './clients/generic';
2
2
  export * from './helpers';
3
3
  export * from './libs';
4
4
  export * from './types';
@@ -5,4 +5,4 @@ export interface ApiResponse<T> {
5
5
  headers?: AxiosResponseHeaders;
6
6
  }
7
7
 
8
- export type ErrorData = any;
8
+ export type ErrorData = unknown;