Skip to content

Commit 7b7bb71

Browse files
committed
update axios & nock
1 parent adb0eb4 commit 7b7bb71

File tree

5 files changed

+7291
-4958
lines changed

5 files changed

+7291
-4958
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"prepublishOnly": "yarn lint && yarn test"
1919
},
2020
"dependencies": {
21-
"axios": "^0.21.1",
21+
"axios": "^1.6.1",
2222
"form-data": "^4.0.0",
2323
"lodash": "^4.17.21"
2424
},
@@ -40,7 +40,7 @@
4040
"eslint-plugin-standard": "^5.0.0",
4141
"husky": "^8.0.3",
4242
"jest": "^29.6.1",
43-
"nock": "^13.3.2",
43+
"nock": "^13.3.8",
4444
"prettier": "^3.0.0",
4545
"rimraf": "^5.0.1",
4646
"tslib": "^2.6.0",

src/modules/contacts/httpClient/prepareParamsForRequest/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('prepareParamsForRequest', () => {
5959
// given
6060
const contactParams: GetContactsQueryParams = {
6161
birthdayDate: [new Date('2015-07-13'), new Date('2015-07-15')],
62-
email: 'someEmail',
62+
email: ['someEmail1', 'someEmail2'],
6363
firstName: 'someFirstName',
6464
gender: 'female',
6565
groupId: 'someGroupId',
@@ -72,8 +72,8 @@ describe('prepareParamsForRequest', () => {
7272
};
7373

7474
const body = {
75-
birthday_date: ['2015-07-13', '2015-07-15'],
76-
email: contactParams.email,
75+
birthday_date: '2015-07-13,2015-07-15',
76+
email: 'someEmail1,someEmail2',
7777
first_name: contactParams.firstName,
7878
gender: contactParams.gender,
7979
group_id: contactParams.groupId,

src/modules/contacts/httpClient/prepareParamsForRequest/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { stringify } from 'querystring';
22

3-
import { AxiosRequestConfig } from 'axios';
3+
import { InternalAxiosRequestConfig } from 'axios';
44
import isArray from 'lodash/isArray';
55
import mapKeys from 'lodash/mapKeys';
66
import mapValues from 'lodash/mapValues';
@@ -15,20 +15,24 @@ const formatKeys = (data: Record<string, string | boolean | number>) => {
1515
};
1616

1717
export const prepareParamsForRequest = (
18-
config: AxiosRequestConfig,
19-
): AxiosRequestConfig => {
18+
config: InternalAxiosRequestConfig,
19+
): InternalAxiosRequestConfig => {
2020
const { data, method, params } = config;
2121

2222
if (['get', 'delete'].includes((method as string).toLowerCase())) {
2323
let formattedParams = mapValues(params, (value, key) => {
2424
if (key === 'birthdayDate') {
2525
if (isArray(value)) {
26-
return value.map(formatDate);
26+
return value.map(formatDate).join(',');
2727
}
2828

2929
return formatDate(value);
3030
}
3131

32+
if (isArray(value)) {
33+
return value.join(',');
34+
}
35+
3236
return value;
3337
});
3438

src/smsapi/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* eslint-disable @typescript-eslint/ban-ts-comment */
22
import axios, { AxiosInstance } from 'axios';
3-
// @ts-ignore TS7016
4-
import adapter from 'axios/lib/adapters/http';
53

64
import { Contacts } from '../modules/contacts';
75
import { Hlr } from '../modules/hlr';
@@ -56,7 +54,7 @@ export class SMSAPI {
5654

5755
private setHttpClient(): AxiosInstance {
5856
const httpClient = axios.create({
59-
adapter,
57+
adapter: 'http',
6058
baseURL: API_URL,
6159
headers: {
6260
Accept: 'application/json',

0 commit comments

Comments
 (0)