@maxzima/wa-communicator 1.0.11 → 1.0.13
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 +2 -5
- 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 +8 -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
|
@@ -135,15 +135,12 @@ export class Communicator {
|
|
|
135
135
|
registration(data) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
137
|
const headers = this.getHeaders(data.accessToken);
|
|
138
|
-
const body = JSON.stringify({
|
|
139
|
-
name: data.name,
|
|
140
|
-
source: {
|
|
138
|
+
const body = JSON.stringify(Object.assign(Object.assign({ name: data.name }, (data.countryCode && { country_code: data.countryCode })), { source: {
|
|
141
139
|
hash: data.hash,
|
|
142
140
|
device_type: data.deviceType,
|
|
143
141
|
ga_id: data.gaId,
|
|
144
142
|
origin: data.origin,
|
|
145
|
-
}
|
|
146
|
-
});
|
|
143
|
+
} }));
|
|
147
144
|
return yield this.send({
|
|
148
145
|
method: 'POST',
|
|
149
146
|
url: `${this.props.clientFAPIBaseUrl}${"clients/registration"}`,
|
|
@@ -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
|
+
...(data.countryCode && { country_code: data.countryCode }),
|
|
131
132
|
source: {
|
|
132
133
|
hash: data.hash,
|
|
133
134
|
device_type: data.deviceType,
|
|
@@ -165,26 +166,26 @@ export class Communicator {
|
|
|
165
166
|
} catch (error) {}
|
|
166
167
|
|
|
167
168
|
return resolve({
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
status: response.status,
|
|
170
|
+
ok: response.ok,
|
|
171
|
+
json: data,
|
|
172
|
+
});
|
|
172
173
|
});
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
private getHeaders = (token?: string) => {
|
|
177
|
-
let headers = CommunicatorDefaultRequestData.FETCH_HEADERS_INIT
|
|
178
|
+
let headers = CommunicatorDefaultRequestData.FETCH_HEADERS_INIT;
|
|
178
179
|
|
|
179
180
|
if (token) {
|
|
180
181
|
headers = {
|
|
181
182
|
...headers,
|
|
182
183
|
'Authorization': `Bearer ${token}`,
|
|
183
|
-
}
|
|
184
|
+
};
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
return headers;
|
|
187
|
-
}
|
|
188
|
+
};
|
|
188
189
|
|
|
189
190
|
private getMeta = (browserData: TAccountBrowserData): TAccountMeta => {
|
|
190
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
|
+
};
|