Skip to content

Commit

Permalink
Upgrade axios to 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
awilczek committed Nov 19, 2023
1 parent a229f8f commit d7db833
Show file tree
Hide file tree
Showing 9 changed files with 8,782 additions and 9,025 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-nails-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@voucherify/sdk': minor
---

Update axios to 1.6.1 in SDK package
3 changes: 3 additions & 0 deletions packages/sdk/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ module.exports = {
globals: {
__VERSION__: require('./package.json').version,
},
moduleNameMapper: {
axios: 'axios/dist/node/axios.cjs',
},
}
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"form-data": "4.0.0",
"axios": "0.27.2",
"axios": "1.6.1",
"qs": "6.9.7"
},
"devDependencies": {
Expand Down
9 changes: 8 additions & 1 deletion packages/sdk/src/Campaigns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ export class Campaigns {
const fileStream = fs.createReadStream(filePath)
const form = new FormData()
form.append('file', fileStream)
return this.client.post<AAT.AsyncActionCreateResponse>(`/campaigns/${campaignId}/importCSV`, form)
const headers = { 'Content-Type': 'multipart/form-data' }

return this.client.post<AAT.AsyncActionCreateResponse>(
`/campaigns/${campaignId}/importCSV`,
form,
undefined,
headers,
)
}
/**
* @see https://docs.voucherify.io/reference/enable-campaign
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/Customers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ class Customers {
const fileStream = fs.createReadStream(filePath)
const form = new FormData()
form.append('file', fileStream)
return this.client.post<AAT.AsyncActionCreateResponse>(`/customers/importCSV`, form)
const headers = { 'Content-Type': 'multipart/form-data' }

return this.client.post<AAT.AsyncActionCreateResponse>(`/customers/importCSV`, form, undefined, headers)
}
}

Expand Down
8 changes: 6 additions & 2 deletions packages/sdk/src/Products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export class Products {
const fileStream = fs.createReadStream(filePath)
const form = new FormData()
form.append('file', fileStream)
return this.client.post<AAT.AsyncActionCreateResponse>(`/skus/importCSV`, form)
const headers = { 'Content-Type': 'multipart/form-data' }

return this.client.post<AAT.AsyncActionCreateResponse>(`/skus/importCSV`, form, undefined, headers)
}
/**
* @see https://docs.voucherify.io/reference/import-products-using-csv
Expand All @@ -112,6 +114,8 @@ export class Products {
const fileStream = fs.createReadStream(filePath)
const form = new FormData()
form.append('file', fileStream)
return this.client.post<AAT.AsyncActionCreateResponse>(`/products/importCSV`, form)
const headers = { 'Content-Type': 'multipart/form-data' }

return this.client.post<AAT.AsyncActionCreateResponse>(`/products/importCSV`, form, undefined, headers)
}
}
11 changes: 8 additions & 3 deletions packages/sdk/src/RequestController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosError, AxiosInstance } from 'axios'
import axios, { AxiosError, AxiosInstance, RawAxiosResponseHeaders } from 'axios'

import Qs from 'qs'
import { VoucherifyError } from './VoucherifyError'
Expand Down Expand Up @@ -60,8 +60,13 @@ export class RequestController {
public getLastResponseHeaders(): Record<string, string> {
return this.lastResponseHeaders
}
private setLastResponseHeaders(headers: Record<string, string>) {
this.lastResponseHeaders = headers
private setLastResponseHeaders(headers: RawAxiosResponseHeaders) {
const result: Record<string, string> = {}
for (const key in headers) {
result[key] = String(headers[key])
}

this.lastResponseHeaders = result
this.isLastResponseHeadersSet = true
}
public setBaseUrl(baseURL: string) {
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/Vouchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export class Vouchers {
const fileStream = fs.createReadStream(filePath)
const form = new FormData()
form.append('file', fileStream)
return this.client.post<AAT.AsyncActionCreateResponse>('/vouchers/importCSV', form)
const headers = { 'Content-Type': 'multipart/form-data' }

return this.client.post<AAT.AsyncActionCreateResponse>('/vouchers/importCSV', form, undefined, headers)
}
/**
* @see https://docs.voucherify.io/reference/list-voucher-transactions
Expand Down
17,761 changes: 8,745 additions & 9,016 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit d7db833

Please sign in to comment.