@maxzima/wa-communicator 1.0.10 → 1.0.12
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/engine/Communicator/Public/Communicator.js +13 -6
- package/dist/types/TCommunicator.d.ts +2 -0
- package/package.json +1 -1
- package/src/engine/Communicator/Constants/Communicator.ts +2 -2
- package/src/engine/Communicator/Public/Communicator.ts +15 -7
- package/src/types/TCommunicator.ts +2 -0
- package/test/__snapshots__/communicator.spec.ts.snap +1 -1
- package/test/testunits/accountTracker/events.ts +1 -1
- package/test/testunits/accountTracker/general.ts +1 -1
- package/test/testunits/communicator/general.ts +3 -2
- package/test/testunits/communicator/requests.ts +2 -1
- package/test/testunits/communicator/utils.ts +4 -4
|
@@ -137,6 +137,7 @@ export class Communicator {
|
|
|
137
137
|
const headers = this.getHeaders(data.accessToken);
|
|
138
138
|
const body = JSON.stringify({
|
|
139
139
|
name: data.name,
|
|
140
|
+
country_code: data.countryCode,
|
|
140
141
|
source: {
|
|
141
142
|
hash: data.hash,
|
|
142
143
|
device_type: data.deviceType,
|
|
@@ -164,12 +165,18 @@ export class Communicator {
|
|
|
164
165
|
headers: requestInitProps.headers,
|
|
165
166
|
})
|
|
166
167
|
.then((response) => {
|
|
167
|
-
return new Promise((resolve) =>
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
let data = {};
|
|
170
|
+
try {
|
|
171
|
+
data = yield response.json();
|
|
172
|
+
}
|
|
173
|
+
catch (error) { }
|
|
174
|
+
return resolve({
|
|
175
|
+
status: response.status,
|
|
176
|
+
ok: response.ok,
|
|
177
|
+
json: data,
|
|
178
|
+
});
|
|
179
|
+
}));
|
|
173
180
|
});
|
|
174
181
|
});
|
|
175
182
|
}
|
|
@@ -104,6 +104,7 @@ declare type TRegistrationRequestBodySource = {
|
|
|
104
104
|
};
|
|
105
105
|
declare type TRegistrationRequestBody = {
|
|
106
106
|
name: string;
|
|
107
|
+
country_code: string;
|
|
107
108
|
source: TRegistrationRequestBodySource;
|
|
108
109
|
};
|
|
109
110
|
declare type TGetCurrentUserProfileRequestData = {
|
|
@@ -112,6 +113,7 @@ declare type TGetCurrentUserProfileRequestData = {
|
|
|
112
113
|
declare type TRegistrationRequestData = {
|
|
113
114
|
accessToken: string;
|
|
114
115
|
name: TRegistrationRequestBody['name'];
|
|
116
|
+
countryCode: TRegistrationRequestBody['name'];
|
|
115
117
|
deviceType: TRegistrationRequestBodySource['device_type'];
|
|
116
118
|
hash: TRegistrationRequestBodySource['hash'];
|
|
117
119
|
gaId: TRegistrationRequestBodySource['ga_id'];
|
package/package.json
CHANGED
|
@@ -128,6 +128,7 @@ export class Communicator {
|
|
|
128
128
|
const headers = this.getHeaders(data.accessToken);
|
|
129
129
|
const body = JSON.stringify({
|
|
130
130
|
name: data.name,
|
|
131
|
+
country_code: data.countryCode,
|
|
131
132
|
source: {
|
|
132
133
|
hash: data.hash,
|
|
133
134
|
device_type: data.deviceType,
|
|
@@ -157,27 +158,34 @@ export class Communicator {
|
|
|
157
158
|
headers: requestInitProps.headers,
|
|
158
159
|
})
|
|
159
160
|
.then((response) => {
|
|
160
|
-
return new Promise((resolve) =>
|
|
161
|
-
|
|
161
|
+
return new Promise(async (resolve) => {
|
|
162
|
+
let data = {};
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
data = await response.json();
|
|
166
|
+
} catch (error) {}
|
|
167
|
+
|
|
168
|
+
return resolve({
|
|
162
169
|
status: response.status,
|
|
163
170
|
ok: response.ok,
|
|
164
|
-
json,
|
|
165
|
-
})
|
|
171
|
+
json: data,
|
|
172
|
+
});
|
|
173
|
+
});
|
|
166
174
|
});
|
|
167
175
|
}
|
|
168
176
|
|
|
169
177
|
private getHeaders = (token?: string) => {
|
|
170
|
-
let headers = CommunicatorDefaultRequestData.FETCH_HEADERS_INIT
|
|
178
|
+
let headers = CommunicatorDefaultRequestData.FETCH_HEADERS_INIT;
|
|
171
179
|
|
|
172
180
|
if (token) {
|
|
173
181
|
headers = {
|
|
174
182
|
...headers,
|
|
175
183
|
'Authorization': `Bearer ${token}`,
|
|
176
|
-
}
|
|
184
|
+
};
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
return headers;
|
|
180
|
-
}
|
|
188
|
+
};
|
|
181
189
|
|
|
182
190
|
private getMeta = (browserData: TAccountBrowserData): TAccountMeta => {
|
|
183
191
|
return {
|
|
@@ -149,6 +149,7 @@ type TRegistrationRequestBodySource = {
|
|
|
149
149
|
|
|
150
150
|
type TRegistrationRequestBody = {
|
|
151
151
|
name: string,
|
|
152
|
+
country_code: string,
|
|
152
153
|
source: TRegistrationRequestBodySource,
|
|
153
154
|
}
|
|
154
155
|
|
|
@@ -159,6 +160,7 @@ type TGetCurrentUserProfileRequestData = {
|
|
|
159
160
|
type TRegistrationRequestData = {
|
|
160
161
|
accessToken: string,
|
|
161
162
|
name: TRegistrationRequestBody['name'],
|
|
163
|
+
countryCode: TRegistrationRequestBody['name'],
|
|
162
164
|
deviceType: TRegistrationRequestBodySource['device_type']
|
|
163
165
|
hash: TRegistrationRequestBodySource['hash'],
|
|
164
166
|
gaId: TRegistrationRequestBodySource['ga_id'],
|
|
@@ -70,7 +70,7 @@ Object {
|
|
|
70
70
|
|
|
71
71
|
exports[`Communicator requests registration 1`] = `
|
|
72
72
|
Object {
|
|
73
|
-
"body": "{\\"name\\":\\"_companyName_\\",\\"source\\":{\\"hash\\":\\"_hash_\\",\\"device_type\\":\\"mobile\\",\\"ga_id\\":\\"_gaId_\\",\\"origin\\":\\"_origin_\\"}}",
|
|
73
|
+
"body": "{\\"name\\":\\"_companyName_\\",\\"country_code\\":\\"CAN\\",\\"source\\":{\\"hash\\":\\"_hash_\\",\\"device_type\\":\\"mobile\\",\\"ga_id\\":\\"_gaId_\\",\\"origin\\":\\"_origin_\\"}}",
|
|
74
74
|
"headers": Object {
|
|
75
75
|
"Accept": "application/json, text/plain, */*",
|
|
76
76
|
"Authorization": "Bearer _accessToken_",
|
|
@@ -19,13 +19,14 @@ const communicatorTestData = {
|
|
|
19
19
|
companyName: '_companyName_',
|
|
20
20
|
deviceType: 'mobile' as TRegistrationRequestBodySourceDeviceType,
|
|
21
21
|
otpCode: '123456',
|
|
22
|
+
countryCode: 'CAN',
|
|
22
23
|
authToken: '_authToken_',
|
|
23
24
|
accessToken: '_accessToken_',
|
|
24
25
|
hash: '_hash_',
|
|
25
26
|
gaId: '_gaId_',
|
|
26
27
|
origin: '_origin_',
|
|
27
|
-
}
|
|
28
|
+
};
|
|
28
29
|
|
|
29
30
|
export {
|
|
30
31
|
communicatorTestData
|
|
31
|
-
}
|
|
32
|
+
};
|
|
@@ -46,6 +46,7 @@ const getCurrentUserProfileData: TGetCurrentUserProfileRequestData = {
|
|
|
46
46
|
const registrationData: TRegistrationRequestData = {
|
|
47
47
|
accessToken: communicatorTestData.accessToken,
|
|
48
48
|
name: communicatorTestData.companyName,
|
|
49
|
+
countryCode: communicatorTestData.countryCode,
|
|
49
50
|
deviceType: communicatorTestData.deviceType,
|
|
50
51
|
hash: communicatorTestData.hash,
|
|
51
52
|
gaId: communicatorTestData.gaId,
|
|
@@ -61,4 +62,4 @@ export {
|
|
|
61
62
|
createSessionData,
|
|
62
63
|
getCurrentUserProfileData,
|
|
63
64
|
registrationData,
|
|
64
|
-
}
|
|
65
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const headerTokenNormal = '_token_'
|
|
1
|
+
const headerTokenNormal = '_token_';
|
|
2
2
|
const queryParamsNormal = {
|
|
3
3
|
queryParamKey1: 'queryParamValue1',
|
|
4
|
-
}
|
|
4
|
+
};
|
|
5
5
|
const queryParamsMulti = {
|
|
6
6
|
queryParamKey1: 'queryParamValue1',
|
|
7
7
|
queryParamKey2: 'queryParamValue2',
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
11
|
headerTokenNormal,
|
|
12
12
|
queryParamsNormal,
|
|
13
13
|
queryParamsMulti,
|
|
14
|
-
}
|
|
14
|
+
};
|