@adtrackify/at-service-common 1.0.23 → 1.0.25
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,6 +74,57 @@ 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
|
+
|
|
77
128
|
}
|
|
78
129
|
declare module '@adtrackify/at-service-common/clients/internal-api/destinations-client' {
|
|
79
130
|
import { ApiResponse } from '@adtrackify/at-service-common/types/api-response';
|
|
@@ -130,11 +181,11 @@ declare module '@adtrackify/at-service-common/clients/internal-api/destinations-
|
|
|
130
181
|
destination: Destination;
|
|
131
182
|
[key: string]: any;
|
|
132
183
|
}
|
|
133
|
-
export default DestinationsClient;
|
|
134
184
|
|
|
135
185
|
}
|
|
136
186
|
declare module '@adtrackify/at-service-common/clients/internal-api/index' {
|
|
137
187
|
export * from '@adtrackify/at-service-common/clients/internal-api/destinations-client';
|
|
188
|
+
export * from '@adtrackify/at-service-common/clients/internal-api/accounts-client';
|
|
138
189
|
|
|
139
190
|
}
|
|
140
191
|
declare module '@adtrackify/at-service-common/helpers/index' {
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './destinations-client';
|
|
1
|
+
export * from './destinations-client';
|
|
2
|
+
export * from './accounts-client';
|