@adtrackify/at-service-common 1.0.22 → 1.0.24

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/dist/index.d.ts CHANGED
@@ -74,10 +74,62 @@ declare module '@adtrackify/at-service-common/clients/index' {
74
74
  export * from '@adtrackify/at-service-common/clients/generic/index';
75
75
  export * from '@adtrackify/at-service-common/clients/internal-api/index';
76
76
 
77
+ }
78
+ declare module '@adtrackify/at-service-common/clients/internal-api/accounts-client' {
79
+ import { ApiResponse } from '@adtrackify/at-service-common/types/api-response';
80
+ export class AccountsClient {
81
+ BASE_API_URL: string;
82
+ ACCOUNTS_API_KEY: string;
83
+ constructor(baseApiUrl: string, accountsApiKey: string);
84
+ getConfig: () => {
85
+ baseURL: string;
86
+ headers: {
87
+ common: {
88
+ 'x-api-key': string;
89
+ };
90
+ };
91
+ };
92
+ getClient: () => Promise<{
93
+ instance: () => import("axios").AxiosInstance;
94
+ get: (url: string, config?: any) => Promise<{
95
+ headers: any;
96
+ data: any;
97
+ status: any;
98
+ }>;
99
+ post: (url: string, data?: any, config?: any) => Promise<{
100
+ headers: any;
101
+ data: any;
102
+ status: any;
103
+ }>;
104
+ delete: (url: string, config?: any) => Promise<{
105
+ headers: any;
106
+ data: any;
107
+ status: any;
108
+ }>;
109
+ put: (url: string, data?: any, config?: any) => Promise<{
110
+ headers: any;
111
+ data: any;
112
+ status: any;
113
+ }>;
114
+ patch: (url: string, data?: any, config?: any) => Promise<{
115
+ headers: any;
116
+ data: any;
117
+ status: any;
118
+ }>;
119
+ setBaseUrl: (url: string) => boolean;
120
+ }>;
121
+ isAuthorizedUser: (userId: string, accountId: string, pixelId: string) => Promise<ApiResponse<IsAuthorizedUserResponseData>>;
122
+ }
123
+ export interface IsAuthorizedUserResponseData {
124
+ isAccountUser: boolean;
125
+ [key: string]: any;
126
+ }
127
+ export default AccountsClient;
128
+
77
129
  }
78
130
  declare module '@adtrackify/at-service-common/clients/internal-api/destinations-client' {
79
- import { Destination } from 'aws-sdk/clients/lexmodelbuildingservice';
80
131
  import { ApiResponse } from '@adtrackify/at-service-common/types/api-response';
132
+ import { Destination } from '@adtrackify/at-service-common/types/db/destination';
81
133
  export class DestinationsClient {
82
134
  BASE_API_URL: string;
83
135
  DESTINATIONS_API_KEY: string;
@@ -135,6 +187,7 @@ declare module '@adtrackify/at-service-common/clients/internal-api/destinations-
135
187
  }
136
188
  declare module '@adtrackify/at-service-common/clients/internal-api/index' {
137
189
  export * from '@adtrackify/at-service-common/clients/internal-api/destinations-client';
190
+ export * from '@adtrackify/at-service-common/clients/internal-api/accounts-client';
138
191
 
139
192
  }
140
193
  declare module '@adtrackify/at-service-common/helpers/index' {
@@ -307,7 +360,6 @@ declare module '@adtrackify/at-service-common/types/api-response' {
307
360
  status: number;
308
361
  headers?: AxiosResponseHeaders;
309
362
  }
310
- export type ErrorData = unknown;
311
363
 
312
364
  }
313
365
  declare module '@adtrackify/at-service-common/types/db/destination' {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adtrackify/at-service-common",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -0,0 +1,50 @@
1
+ import * as log from 'lambda-log';
2
+ import { ApiResponse } from '../../types/api-response';
3
+ import { axiosHttpService } from '../generic/http-client';
4
+
5
+ //const BASE_API_URL = process.env.BASE_API_URL;
6
+
7
+ //const SERVICE_API_ROOT_URL = `${BASE_API_URL}/accounts`;
8
+ //const ACCOUNTS_API_KEY = process.env.ACCOUNTS_API_KEY;
9
+
10
+ export class AccountsClient {
11
+ public BASE_API_URL: string;
12
+ public ACCOUNTS_API_KEY: string;
13
+
14
+ constructor (baseApiUrl: string, accountsApiKey: string) {
15
+ this.BASE_API_URL = baseApiUrl;
16
+ this.ACCOUNTS_API_KEY = accountsApiKey;
17
+ }
18
+
19
+ getConfig = () => {
20
+ const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/accounts`;
21
+ return {
22
+ baseURL: SERVICE_API_ROOT_URL,
23
+ headers: {
24
+ common: {
25
+ 'x-api-key': this.ACCOUNTS_API_KEY
26
+ }
27
+ }
28
+ };
29
+ };
30
+
31
+ getClient = async () => {
32
+ return axiosHttpService(this.getConfig());
33
+ };
34
+
35
+ isAuthorizedUser = async (userId: string, accountId: string, pixelId: string): Promise<ApiResponse<IsAuthorizedUserResponseData>> => {
36
+ const client = await this.getClient();
37
+ const body = {
38
+ userId, accountId, pixelId
39
+ };
40
+ const response = await client.post('/checkUserAuthorization', body);
41
+ log.info('checkUserAuthorization', { response });
42
+ return response as ApiResponse<IsAuthorizedUserResponseData>;
43
+ };
44
+ }
45
+
46
+ export interface IsAuthorizedUserResponseData {
47
+ isAccountUser: boolean;
48
+ [ key: string ]: any;
49
+ }
50
+ export default AccountsClient;
@@ -1,8 +1,7 @@
1
- import { Destination } from 'aws-sdk/clients/lexmodelbuildingservice';
2
1
  import * as log from 'lambda-log';
3
2
  import { ApiResponse } from '../../types/api-response';
4
3
  import { axiosHttpService } from '../generic/http-client';
5
-
4
+ import { Destination } from '../../types/db/destination';
6
5
  //const BASE_API_URL = process.env.BASE_API_URL;
7
6
  //const DESTINATIONS_API_KEY = process.env.DESTINATIONS_API_KEY;
8
7
 
@@ -1 +1,2 @@
1
- export * from './destinations-client';
1
+ export * from './destinations-client';
2
+ export * from './accounts-client';
@@ -4,5 +4,3 @@ export interface ApiResponse<T> {
4
4
  status: number;
5
5
  headers?: AxiosResponseHeaders;
6
6
  }
7
-
8
- export type ErrorData = unknown;