Feat(medusajs) Allow to pass custom headers (#1009)

* Feat(medusajs) Allow to pass custom headers

* fix: axios exprexted output

* fix: integration test cart

* refactor: Update types object > Record<string, any>

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
This commit is contained in:
Adrien de Peretti
2022-02-17 16:50:03 +01:00
committed by GitHub
co-authored by Sebastian Rindom
parent 449e666428
commit 22d387dcce
45 changed files with 572 additions and 433 deletions
+9 -6
View File
@@ -10,31 +10,34 @@ class AuthResource extends BaseResource {
/**
* @description Authenticates a customer using email and password combination
* @param {StorePostAuthReq} payload authentication payload
* @param customHeaders
* @return {ResponsePromise<StoreAuthRes>}
*/
authenticate(payload: StorePostAuthReq): ResponsePromise<StoreAuthRes> {
authenticate(payload: StorePostAuthReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreAuthRes> {
const path = `/store/auth`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description Retrieves an authenticated session
* Usually used to check if authenticated session is alive.
* @param customHeaders
* @return {ResponsePromise<StoreAuthRes>}
*/
getSession(): ResponsePromise<StoreAuthRes> {
getSession(customHeaders: Record<string, any> = {}): ResponsePromise<StoreAuthRes> {
const path = `/store/auth`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Check if email exists
* @param {string} email is required
* @param customHeaders
* @return {ResponsePromise<StoreGetAuthEmailRes>}
*/
exists(email: string): ResponsePromise<StoreGetAuthEmailRes> {
exists(email: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreGetAuthEmailRes> {
const path = `/store/auth/${email}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}