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
parent 449e666428
commit 22d387dcce
45 changed files with 572 additions and 433 deletions

View File

@@ -150,7 +150,7 @@ describe("/store/carts", () => {
const cart = getRes.data.cart
expect(cart.context).toEqual({
ip: "::ffff:127.0.0.1",
user_agent: "axios/0.21.1",
user_agent: expect.stringContaining("axios/0.21."),
test_id: "test",
})
})

View File

@@ -68,7 +68,7 @@ class Client {
}
// Stolen from https://github.com/stripe/stripe-node/blob/fd0a597064289b8c82f374f4747d634050739043/lib/utils.js#L282
normalizeHeaders(obj: object): object {
normalizeHeaders(obj: object): Record<string, any> {
if (!(obj && typeof obj === "object")) {
return obj
}
@@ -109,9 +109,9 @@ class Client {
userHeaders: RequestOptions,
method: RequestMethod,
path: string,
customHeaders: object = {}
customHeaders: Record<string, any> = {}
): AxiosRequestHeaders {
let defaultHeaders: object = {
let defaultHeaders: Record<string, any> = {
Accept: "application/json",
"Content-Type": "application/json",
}
@@ -183,9 +183,9 @@ class Client {
async request(
method: RequestMethod,
path: string,
payload: object = {},
payload: Record<string, any> = {},
options: RequestOptions = {},
customHeaders: object = {}
customHeaders: Record<string, any> = {}
): Promise<any> {
const reqOpts = {
method,

View File

@@ -10,37 +10,40 @@ class AddressesResource extends BaseResource {
/**
* Adds an address to a customers saved addresses
* @param {StorePostCustomersCustomerAddressesReq} payload contains information to create an address
* @return {ResponsePromise<StoreCustomerResponse>}
* @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>}
*/
addAddress(
payload: StorePostCustomersCustomerAddressesReq
): ResponsePromise<StoreCustomersRes> {
payload: StorePostCustomersCustomerAddressesReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me/addresses`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Deletes an address of a customer
* @param {string} address_id id of the address to delete
* @return {ResponsePromise<StoreCustomersResponse>}
* @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>}
*/
deleteAddress(address_id: string): ResponsePromise<StoreCustomersRes> {
deleteAddress(address_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me/addresses/${address_id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* Update an address of a customer
* @param {string} address_id id of customer
* @param {StorePostCustomersCustomerAddressesAddressReq} payload address update
* @return {StoreCustomersResponse}
* @param customHeaders
* @return {StoreCustomersRes}
*/
updateAddress(
address_id: string,
payload: StorePostCustomersCustomerAddressesAddressReq
): ResponsePromise<StoreCustomersRes> {
payload: StorePostCustomersCustomerAddressesAddressReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me/addresses/${address_id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
}

View File

@@ -6,30 +6,33 @@ class AdminAuthResource extends BaseResource {
/**
* @description Retrieves an authenticated session
* Usually used to check if authenticated session is alive.
* @param customHeaders
* @return {ResponsePromise<AdminAuthRes>}
*/
getSession(): ResponsePromise<AdminAuthRes> {
getSession(customHeaders: Record<string, any> = {}): ResponsePromise<AdminAuthRes> {
const path = `/admin/auth`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description destroys an authenticated session
* @param customHeaders
* @return {ResponsePromise<void>}
*/
deleteSession(): ResponsePromise<void> {
deleteSession(customHeaders: Record<string, any> = {}): ResponsePromise<void> {
const path = `/admin/auth`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description Creates an authenticated session
* @param {AdminPostAuthReq} payload
* @param customHeaders
* @return {ResponsePromise<AdminAuthRes>}
*/
createSession(payload: AdminPostAuthReq): ResponsePromise<AdminAuthRes> {
createSession(payload: AdminPostAuthReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminAuthRes> {
const path = `/admin/auth`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
}

View File

@@ -14,56 +14,64 @@ class AdminCollectionsResource extends BaseResource {
/**
* @description Creates a collection.
* @param payload
* @param customHeaders
* @returns Created collection.
*/
create(
payload: AdminPostCollectionsReq
payload: AdminPostCollectionsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCollectionsRes> {
const path = `/admin/collections`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description Updates a collection
* @param id id of the collection to update.
* @param payload update to apply to collection.
* @param customHeaders
* @returns the updated collection.
*/
update(
id: string,
payload: AdminPostCollectionsCollectionReq
payload: AdminPostCollectionsCollectionReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCollectionsRes> {
const path = `/admin/collections/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description deletes a collection
* @param id id of collection to delete.
* @param customHeaders
* @returns Deleted response
*/
delete(id: string): ResponsePromise<AdminCollectionsDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminCollectionsDeleteRes> {
const path = `/admin/collections/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description get a collection
* @param id id of the collection to retrieve.
* @param customHeaders
* @returns the collection with the given id
*/
retrieve(id: string): ResponsePromise<AdminCollectionsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminCollectionsRes> {
const path = `/admin/collections/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Lists collections matching a query
* @param query Query for searching collections
* @param customHeaders
* @returns a list of collections matching the query.
*/
list(
query?: AdminGetCollectionsParams
query?: AdminGetCollectionsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCollectionsListRes> {
let path = `/admin/collections`
@@ -72,7 +80,7 @@ class AdminCollectionsResource extends BaseResource {
path = `/admin/collections?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -13,40 +13,46 @@ class AdminCustomersResource extends BaseResource {
/**
* Creates a customer
* @param payload information of customer
* @param customHeaders
*/
create(payload: AdminPostCustomersReq): ResponsePromise<AdminCustomersRes> {
create(payload: AdminPostCustomersReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminCustomersRes> {
const path = `/admin/customers`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Updates a customer
* @param id customer id
* @param payload data to update customer with
* @param customHeaders
*/
update(
id: string,
payload: AdminPostCustomersCustomerReq
payload: AdminPostCustomersCustomerReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCustomersRes> {
const path = `/admin/customers/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Retrieves a customer
* @param id customer id
* @param customHeaders
*/
retrieve(id: string): ResponsePromise<AdminCustomersRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminCustomersRes> {
const path = `/admin/customers/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* Lists customers
* @param query optional
* @param customHeaders
*/
list(
query?: AdminGetCustomersParams
query?: AdminGetCustomersParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCustomersListRes> {
let path = `/admin/customers`
@@ -55,7 +61,7 @@ class AdminCustomersResource extends BaseResource {
path = `/admin/customers?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -15,9 +15,9 @@ class AdminDiscountsResource extends BaseResource {
/**
* @description Adds region to discount
*/
addRegion(id: string, regionId: string): ResponsePromise<AdminDiscountsRes> {
addRegion(id: string, regionId: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/regions/${regionId}`
return this.client.request("POST", path, {})
return this.client.request("POST", path, {}, {}, customHeaders)
}
/**
@@ -25,8 +25,8 @@ class AdminDiscountsResource extends BaseResource {
*/
addValidProduct(
id: string,
productId: string
): ResponsePromise<AdminDiscountsRes> {
productId: string,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/products/${productId}`
return this.client.request("POST", path, {})
}
@@ -34,9 +34,9 @@ class AdminDiscountsResource extends BaseResource {
/**
* @description Creates discounts
*/
create(payload: AdminPostDiscountsReq): ResponsePromise<AdminDiscountsRes> {
create(payload: AdminPostDiscountsReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -44,10 +44,10 @@ class AdminDiscountsResource extends BaseResource {
*/
update(
id: string,
payload: AdminPostDiscountsDiscountReq
): ResponsePromise<AdminDiscountsRes> {
payload: AdminPostDiscountsDiscountReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -55,18 +55,18 @@ class AdminDiscountsResource extends BaseResource {
*/
createDynamicCode(
id: string,
payload: AdminPostDiscountsDiscountDynamicCodesReq
): ResponsePromise<AdminDiscountsRes> {
payload: AdminPostDiscountsDiscountDynamicCodesReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/dynamic-codes`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description Deletes a discount
*/
delete(id: string): ResponsePromise<AdminDiscountsDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsDeleteRes> {
const path = `/admin/discounts/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
@@ -74,34 +74,34 @@ class AdminDiscountsResource extends BaseResource {
*/
deleteDynamicCode(
id: string,
code: string
): ResponsePromise<AdminDiscountsRes> {
code: string,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/dynamic-codes/${code}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description Retrieves a discount
*/
retrieve(id: string): ResponsePromise<AdminDiscountsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Retrieves a discount by code
*/
retrieveByCode(code: string): ResponsePromise<AdminDiscountsRes> {
retrieveByCode(code: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/code/${code}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Lists discounts
*/
list(
query?: AdminGetDiscountsParams
): ResponsePromise<AdminDiscountsListRes> {
query?: AdminGetDiscountsParams,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsListRes> {
let path = `/admin/discounts`
if (query) {
@@ -109,7 +109,7 @@ class AdminDiscountsResource extends BaseResource {
path = `/admin/discounts?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
@@ -117,10 +117,10 @@ class AdminDiscountsResource extends BaseResource {
*/
removeRegion(
id: string,
regionId: string
): ResponsePromise<AdminDiscountsRes> {
regionId: string,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/regions/${regionId}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
@@ -128,10 +128,10 @@ class AdminDiscountsResource extends BaseResource {
*/
removeValidProduct(
id: string,
productId: string
): ResponsePromise<AdminDiscountsRes> {
productId: string,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/products/${productId}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
}

View File

@@ -17,10 +17,10 @@ class AdminDraftOrdersResource extends BaseResource {
* @description Creates a draft order
*/
create(
payload: AdminPostDraftOrdersDraftOrderReq
): ResponsePromise<AdminDraftOrdersRes> {
payload: AdminPostDraftOrdersDraftOrderReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -28,18 +28,18 @@ class AdminDraftOrdersResource extends BaseResource {
*/
addLineItem(
id: string,
payload: AdminPostDraftOrdersDraftOrderLineItemsReq
): ResponsePromise<AdminDraftOrdersRes> {
payload: AdminPostDraftOrdersDraftOrderLineItemsReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}/line-items`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description Delete draft order
*/
delete(id: string): ResponsePromise<AdminDraftOrdersDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersDeleteRes> {
const path = `/admin/draft-orders/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
@@ -47,26 +47,26 @@ class AdminDraftOrdersResource extends BaseResource {
*/
removeLineItem(
id: string,
itemId: string
): ResponsePromise<AdminDraftOrdersRes> {
itemId: string,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}/line-items/${itemId}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description Retrieves a draft order
*/
retrieve(id: string): ResponsePromise<AdminDraftOrdersRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Lists draft orders
*/
list(
query?: AdminGetDraftOrdersParams
): ResponsePromise<AdminDraftOrdersListRes> {
query?: AdminGetDraftOrdersParams,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersListRes> {
let path = `/admin/draft-orders`
if (query) {
@@ -74,14 +74,15 @@ class AdminDraftOrdersResource extends BaseResource {
path = `/admin/draft-orders?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Mark a draft order as paid
*/
markPaid(
id: string
id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminPostDraftOrdersDraftOrderRegisterPaymentRes> {
const path = `/admin/draft-orders/${id}/pay`
return this.client.request("POST", path, {})
@@ -92,10 +93,10 @@ class AdminDraftOrdersResource extends BaseResource {
*/
update(
id: string,
payload: AdminPostDraftOrdersDraftOrderReq
): ResponsePromise<AdminDraftOrdersRes> {
payload: AdminPostDraftOrdersDraftOrderReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -104,10 +105,10 @@ class AdminDraftOrdersResource extends BaseResource {
updateLineItem(
id: string,
itemId: string,
payload: AdminPostDraftOrdersDraftOrderLineItemsItemReq
): ResponsePromise<AdminDraftOrdersRes> {
payload: AdminPostDraftOrdersDraftOrderLineItemsItemReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}/line-items/${itemId}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
}

View File

@@ -14,9 +14,9 @@ class AdminGiftCardsResource extends BaseResource {
/**
* @description Creates a gift card
*/
create(payload: AdminPostGiftCardsReq): ResponsePromise<AdminGiftCardsRes> {
create(payload: AdminPostGiftCardsReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminGiftCardsRes> {
const path = `/admin/gift-cards`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -24,34 +24,34 @@ class AdminGiftCardsResource extends BaseResource {
*/
update(
id: string,
payload: AdminPostGiftCardsGiftCardReq
): ResponsePromise<AdminGiftCardsRes> {
payload: AdminPostGiftCardsGiftCardReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminGiftCardsRes> {
const path = `/admin/gift-cards/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description Deletes a gift card
*/
delete(id: string): ResponsePromise<AdminGiftCardsDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminGiftCardsDeleteRes> {
const path = `/admin/gift-cards/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description Deletes a gift card
*/
retrieve(id: string): ResponsePromise<AdminGiftCardsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminGiftCardsRes> {
const path = `/admin/gift-cards/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Lists gift cards
*/
list(
query?: AdminGetGiftCardsParams
): ResponsePromise<AdminGiftCardsListRes> {
query?: AdminGetGiftCardsParams,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminGiftCardsListRes> {
let path = `/admin/gift-cards/`
if (query) {
@@ -59,7 +59,7 @@ class AdminGiftCardsResource extends BaseResource {
path = `/admin/gift-cards?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -7,29 +7,29 @@ import { AdminPostInvitesPayload, ResponsePromise } from "../.."
import BaseResource from "../base"
class AdminInvitesResource extends BaseResource {
accept(payload: AdminPostInvitesInviteAcceptReq): ResponsePromise {
accept(payload: AdminPostInvitesInviteAcceptReq, customHeaders: Record<string, any> = {}): ResponsePromise {
const path = `/admin/invites/accept`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
create(payload: AdminPostInvitesPayload): ResponsePromise {
create(payload: AdminPostInvitesPayload, customHeaders: Record<string, any> = {}): ResponsePromise {
const path = `/admin/invites`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
delete(id: string): ResponsePromise<AdminInviteDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminInviteDeleteRes> {
const path = `/admin/invites/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
list(): ResponsePromise<AdminListInvitesRes> {
list(customHeaders: Record<string, any> = {}): ResponsePromise<AdminListInvitesRes> {
const path = `/admin/invites`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
resend(id: string): ResponsePromise {
resend(id: string, customHeaders: Record<string, any> = {}): ResponsePromise {
const path = `/admin/invites/${id}`
return this.client.request("POST", path, {})
return this.client.request("POST", path, {}, {}, customHeaders)
}
}

View File

@@ -11,30 +11,30 @@ import { ResponsePromise } from "../../typings"
import BaseResource from "../base"
class AdminNotesResource extends BaseResource {
create(payload: AdminPostNotesReq): ResponsePromise<AdminNotesRes> {
create(payload: AdminPostNotesReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotesRes> {
const path = `/admin/notes`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
update(
id: string,
payload: AdminPostNotesNoteReq
): ResponsePromise<AdminNotesRes> {
payload: AdminPostNotesNoteReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotesRes> {
const path = `/admin/notes/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
delete(id: string): ResponsePromise<AdminNotesDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotesDeleteRes> {
const path = `/admin/notes/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
retrieve(id: string): ResponsePromise<AdminNotesRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotesRes> {
const path = `/admin/notes/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
list(query?: AdminGetNotesParams): ResponsePromise<AdminNotesListRes> {
list(query?: AdminGetNotesParams, customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotesListRes> {
let path = `/admin/notes/`
if (query) {
@@ -42,7 +42,7 @@ class AdminNotesResource extends BaseResource {
path = `/admin/notes?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -10,8 +10,8 @@ import BaseResource from "../base"
class AdminNotificationsResource extends BaseResource {
list(
query?: AdminGetNotificationsParams
): ResponsePromise<AdminNotificationsListRes> {
query?: AdminGetNotificationsParams,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotificationsListRes> {
let path = `/admin/notifications`
if (query) {
@@ -19,15 +19,15 @@ class AdminNotificationsResource extends BaseResource {
path = `/admin/notifications?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
resend(
id: string,
payload: AdminPostNotificationsNotificationResendReq
): ResponsePromise<AdminNotificationsRes> {
payload: AdminPostNotificationsNotificationResendReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotificationsRes> {
const path = `/admin/notifications/${id}/resend`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
}

View File

@@ -22,25 +22,25 @@ import { ResponsePromise } from "../../typings"
import BaseResource from "../base"
class AdminOrdersResource extends BaseResource {
create(payload: AdminPostOrdersReq): ResponsePromise<AdminOrdersRes> {
create(payload: AdminPostOrdersReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
update(
id: string,
payload: AdminPostOrdersOrderReq
): ResponsePromise<AdminOrdersRes> {
payload: AdminPostOrdersOrderReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
retrieve(id: string): ResponsePromise<AdminOrdersRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
list(query?: AdminGetOrdersParams): ResponsePromise<AdminOrdersListRes> {
list(query?: AdminGetOrdersParams, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersListRes> {
let path = `/admin/orders`
if (query) {
@@ -48,177 +48,191 @@ class AdminOrdersResource extends BaseResource {
path = `/admin/orders?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
complete(id: string): ResponsePromise<AdminOrdersRes> {
complete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/complete`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
capturePayment(id: string): ResponsePromise<AdminOrdersRes> {
capturePayment(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/capture`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
refundPayment(
id: string,
payload: AdminPostOrdersOrderRefundsReq
): ResponsePromise<AdminOrdersRes> {
payload: AdminPostOrdersOrderRefundsReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/refund`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
createFulfillment(
id: string,
payload: AdminPostOrdersOrderFulfillmentsReq
): ResponsePromise<AdminOrdersRes> {
payload: AdminPostOrdersOrderFulfillmentsReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/fulfillment`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
cancelFulfillment(
id: string,
fulfillmentId: string
fulfillmentId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/fulfillments/${fulfillmentId}/cancel`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
cancelSwapFulfillment(
id: string,
swapId: string,
fulfillmentId: string
fulfillmentId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/fulfillments/${fulfillmentId}/cancel`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
cancelClaimFulfillment(
id: string,
claimId: string,
fulfillmentId: string
fulfillmentId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}/fulfillments/${fulfillmentId}/cancel`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
createShipment(
id: string,
payload: AdminPostOrdersOrderShipmentReq
payload: AdminPostOrdersOrderShipmentReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/shipment`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
requestReturn(
id: string,
payload: AdminPostOrdersOrderReturnsReq
payload: AdminPostOrdersOrderReturnsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/return`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
cancel(id: string): ResponsePromise<AdminOrdersRes> {
cancel(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/cancel`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
addShippingMethod(
id: string,
payload: AdminPostOrdersOrderShippingMethodsReq
payload: AdminPostOrdersOrderShippingMethodsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/shipping-methods`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
archive(id: string): ResponsePromise<AdminOrdersRes> {
archive(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/archive`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
createSwap(
id: string,
payload: AdminPostOrdersOrderSwapsReq
payload: AdminPostOrdersOrderSwapsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
cancelSwap(id: string, swapId: string): ResponsePromise<AdminOrdersRes> {
cancelSwap(id: string, swapId: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/cancel`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
fulfillSwap(
id: string,
swapId: string,
payload: AdminPostOrdersOrderSwapsSwapFulfillmentsReq
payload: AdminPostOrdersOrderSwapsSwapFulfillmentsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/fulfillments`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
createSwapShipment(
id: string,
swapId: string,
payload: AdminPostOrdersOrderSwapsSwapShipmentsReq
payload: AdminPostOrdersOrderSwapsSwapShipmentsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/shipments`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
processSwapPayment(
id: string,
swapId: string
swapId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/process-payment`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
createClaim(
id: string,
payload: AdminPostOrdersOrderClaimsReq
payload: AdminPostOrdersOrderClaimsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
cancelClaim(id: string, claimId: string): ResponsePromise<AdminOrdersRes> {
cancelClaim(id: string, claimId: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}/cancel`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
updateClaim(
id: string,
claimId: string,
payload: AdminPostOrdersOrderClaimsClaimReq
payload: AdminPostOrdersOrderClaimsClaimReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
fulfillClaim(
id: string,
claimId: string,
payload: AdminPostOrdersOrderClaimsClaimFulfillmentsReq
payload: AdminPostOrdersOrderClaimsClaimFulfillmentsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}/fulfillments`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
createClaimShipment(
id: string,
claimId: string,
payload: AdminPostOrdersOrderClaimsClaimShipmentsReq
payload: AdminPostOrdersOrderClaimsClaimShipmentsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}/shipments`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
deleteMetadata(id: string, key: string): ResponsePromise<AdminOrdersRes> {
deleteMetadata(id: string, key: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/metadata/${key}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
}

View File

@@ -20,30 +20,30 @@ import { ResponsePromise } from "../../typings"
import BaseResource from "../base"
class AdminProductsResource extends BaseResource {
create(payload: AdminPostProductsReq): ResponsePromise<AdminProductsRes> {
create(payload: AdminPostProductsReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
retrieve(id: string): ResponsePromise<AdminProductsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
update(
id: string,
payload: AdminPostProductsProductReq
): ResponsePromise<AdminProductsRes> {
payload: AdminPostProductsProductReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
delete(id: string): ResponsePromise<AdminProductsDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsDeleteRes> {
const path = `/admin/products/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
list(query?: AdminGetProductsParams): ResponsePromise<AdminProductsListRes> {
list(query?: AdminGetProductsParams, customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsListRes> {
let path = `/admin/products`
if (query) {
@@ -51,75 +51,82 @@ class AdminProductsResource extends BaseResource {
path = `/admin/products?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
listTypes(): ResponsePromise<AdminProductsListTypesRes> {
listTypes(customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsListTypesRes> {
const path = `/admin/products/types`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
listTags(): ResponsePromise<AdminProductsListTagsRes> {
listTags(customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsListTagsRes> {
const path = `/admin/products/tag-usage`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
setMetadata(
id: string,
payload: AdminPostProductsProductMetadataReq
payload: AdminPostProductsProductMetadataReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/metadata`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
createVariant(
id: string,
payload: AdminPostProductsProductVariantsReq
payload: AdminPostProductsProductVariantsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/variants`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
updateVariant(
id: string,
variantId: string,
payload: AdminPostProductsProductVariantsVariantReq
payload: AdminPostProductsProductVariantsVariantReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/variants/${variantId}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
deleteVariant(
id: string,
variantId: string
variantId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsDeleteVariantRes> {
const path = `/admin/products/${id}/variants/${variantId}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
addOption(
id: string,
payload: AdminPostProductsProductOptionsReq
payload: AdminPostProductsProductOptionsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/options`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
updateOption(
id: string,
optionId: string,
payload: AdminPostProductsProductOptionsOption
payload: AdminPostProductsProductOptionsOption,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/options/${optionId}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
deleteOption(
id: string,
optionId: string
optionId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsDeleteOptionRes> {
const path = `/admin/products/${id}/options/${optionId}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
}

View File

@@ -19,53 +19,59 @@ class AdminRegionsResource extends BaseResource {
/**
* @description creates a region.
* @param payload
* @param customHeaders
* @returns created region.
*/
create(payload: AdminPostRegionsReq): ResponsePromise<AdminRegionsRes> {
create(payload: AdminPostRegionsReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description updates a region
* @param id id of the region to update.
* @param payload update to apply to region.
* @param customHeaders
* @returns the updated region.
*/
update(
id: string,
payload: AdminPostRegionsRegionReq
payload: AdminPostRegionsRegionReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description deletes a region
* @param id id of region to delete.
* @param customHeaders
* @returns Deleted response
*/
delete(id: string): ResponsePromise<AdminRegionsDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminRegionsDeleteRes> {
const path = `/admin/regions/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description get a region
* @param id id of the region to retrieve.
* @param customHeaders
* @returns the region with the given id
*/
retrieve(id: string): ResponsePromise<AdminRegionsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description lists regions matching a query
* @param query query for searching regions
* @param customHeaders
* @returns a list of regions matching the query.
*/
list(query?: AdminGetRegionsParams): ResponsePromise<AdminRegionsListRes> {
list(query?: AdminGetRegionsParams, customHeaders: Record<string, any> = {}): ResponsePromise<AdminRegionsListRes> {
let path = `/admin/regions`
if (query) {
@@ -73,128 +79,145 @@ class AdminRegionsResource extends BaseResource {
path = `/admin/regions?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description adds metadata to a region
* @param id region id
* @param payload metadata
* @param customHeaders
* @returns updated region
*/
setMetadata(
id: string,
payload: AdminPostRegionsRegionMetadata
payload: AdminPostRegionsRegionMetadata,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/metadata`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description delete a region's metadata key value pair
* @param id region id
* @param key metadata key
* @param customHeaders
* @returns updated region
*/
deleteMetadata(id: string, key: string): ResponsePromise<AdminRegionsRes> {
deleteMetadata(id: string, key: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/metadata/${key}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description adds a country to the list of countries in a region
* @param id region id
* @param payload country data
* @param customHeaders
* @returns updated region
*/
addCountry(
id: string,
payload: AdminPostRegionsRegionCountriesReq
payload: AdminPostRegionsRegionCountriesReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/countries`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description remove a country from a region's list of coutnries
* @param id region id
* @param country_code the 2 character ISO code for the Country.
* @param customHeaders
* @returns updated region
*/
deleteCountry(
id: string,
country_code: string
country_code: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/countries/${country_code}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description adds a fulfillment provider to a region
* @param id region id
* @param payload fulfillment provider data
* @param customHeaders
* @returns updated region
*/
addFulfillmentProvider(
id: string,
payload: AdminPostRegionsRegionFulfillmentProvidersReq
payload: AdminPostRegionsRegionFulfillmentProvidersReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/fulfillment-providers`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description remove a fulfillment provider from a region
* @param id region id
* @param provider_id the if of the fulfillment provider
* @param customHeaders
* @returns updated region
*/
deleteFulfillmentProvider(
id: string,
provider_id: string
provider_id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/fulfillment-providers/${provider_id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description retrieves the list of fulfillment options available in a region
* @param id region id
* @param customHeaders
* @returns list of fulfillment options
*/
retrieveFulfillmentOptions(
id: string
id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminGetRegionsRegionFulfillmentOptionsRes> {
const path = `/admin/regions/${id}/fulfillment-options`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description adds a payment provider to a region
* @param id region id
* @param payload payment provider data
* @param customHeaders
* @returns updated region
*/
addPaymentProvider(
id: string,
payload: AdminPostRegionsRegionPaymentProvidersReq
payload: AdminPostRegionsRegionPaymentProvidersReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/payment-providers`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description removes a payment provider from a region
* @param id region id
* @param provider_id the id of the payment provider
* @param customHeaders
* @returns updated region
*/
deletePaymentProvider(
id: string,
provider_id: string
provider_id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/payment-providers/${provider_id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
}

View File

@@ -12,58 +12,64 @@ class AdminReturnReasonsResource extends BaseResource {
/**
* @description Creates a return reason.
* @param payload
* @param customHeaders
* @returns Created return reason.
*/
create(
payload: AdminPostReturnReasonsReq
payload: AdminPostReturnReasonsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminReturnReasonsRes> {
const path = `/admin/return-reasons`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description Updates a return reason
* @param id id of the return reason to update.
* @param payload update to apply to return reason.
* @param customHeaders
* @returns the updated return reason.
*/
update(
id: string,
payload: AdminPostReturnReasonsReasonReq
payload: AdminPostReturnReasonsReasonReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminReturnReasonsRes> {
const path = `/admin/return-reasons/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description deletes a return reason
* @param id id of return reason to delete.
* @param customHeaders
* @returns Deleted response
*/
delete(id: string): ResponsePromise<AdminReturnReasonsDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminReturnReasonsDeleteRes> {
const path = `/admin/return-reasons/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description retrieves a return reason
* @param id id of the return reason to retrieve.
* @param customHeaders
* @returns the return reason with the given id
*/
retrieve(id: string): ResponsePromise<AdminReturnReasonsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminReturnReasonsRes> {
const path = `/admin/return-reasons/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Lists return reasons matching a query
* @param query Query for searching return reasons
* @returns a list of return reasons matching the query.
* @param customHeaders
*/
list(): ResponsePromise<AdminReturnReasonsListRes> {
list(customHeaders: Record<string, any> = {}): ResponsePromise<AdminReturnReasonsListRes> {
const path = `/admin/return-reasons`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -13,33 +13,37 @@ class AdminReturnsResource extends BaseResource {
/**
* @description cancels a return
* @param id id of return to cancel
* @param customHeaders
* @returns the order for which the return was canceled
*/
cancel(id: string): ResponsePromise<AdminReturnsCancelRes> {
cancel(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminReturnsCancelRes> {
const path = `/admin/returns/${id}/cancel`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
/**
* @description receive a return
* @param id id of the return to receive.
* @param payload items to receive and an optional refund amount
* @param customHeaders
* @returns the return
*/
receive(
id: string,
payload: AdminPostReturnsReturnReceiveReq
payload: AdminPostReturnsReturnReceiveReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminReturnsRes> {
const path = `/admin/returns/${id}/receive`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description lists returns matching a query
* @param query query for searching returns
* @param customHeaders
* @returns a list of returns matching the query
*/
list(query?: AdminGetReturnsParams): ResponsePromise<AdminReturnsListRes> {
list(query?: AdminGetReturnsParams, customHeaders: Record<string, any> = {}): ResponsePromise<AdminReturnsListRes> {
let path = `/admin/returns/`
if (query) {
@@ -47,7 +51,7 @@ class AdminReturnsResource extends BaseResource {
path = `/admin/returns?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -14,56 +14,64 @@ class AdminShippingOptionsResource extends BaseResource {
/**
* @description creates a shipping option.
* @param payload
* @param customHeaders
* @returns created shipping option.
*/
create(
payload: AdminPostShippingOptionsReq
payload: AdminPostShippingOptionsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminShippingOptionsRes> {
const path = `/admin/shipping-options`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description updates a shipping option
* @param id id of the shipping option to update.
* @param payload update to apply to shipping option.
* @param customHeaders
* @returns the updated shipping option.
*/
update(
id: string,
payload: AdminPostShippingOptionsOptionReq
payload: AdminPostShippingOptionsOptionReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminShippingOptionsRes> {
const path = `/admin/shipping-options/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description deletes a shipping option
* @param id id of shipping option to delete.
* @param customHeaders
* @returns deleted response
*/
delete(id: string): ResponsePromise<AdminShippingOptionsDeleteRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingOptionsDeleteRes> {
const path = `/admin/shipping-options/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description get a shipping option
* @param id id of the shipping option to retrieve.
* @param customHeaders
* @returns the shipping option with the given id
*/
retrieve(id: string): ResponsePromise<AdminShippingOptionsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingOptionsRes> {
const path = `/admin/shipping-options/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description lists shipping options matching a query
* @param query query for searching shipping options
* @param customHeaders
* @returns a list of shipping options matching the query.
*/
list(
query?: AdminGetShippingOptionsParams
query?: AdminGetShippingOptionsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminShippingOptionsListRes> {
let path = `/admin/shipping-options`
@@ -72,7 +80,7 @@ class AdminShippingOptionsResource extends BaseResource {
path = `/admin/shipping-options?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -10,33 +10,33 @@ import BaseResource from "../base"
class AdminShippingProfilesResource extends BaseResource {
create(
payload: AdminPostShippingProfilesReq
): ResponsePromise<AdminShippingProfilesRes> {
payload: AdminPostShippingProfilesReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingProfilesRes> {
const path = `/admin/shipping-profiles/`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
update(
id: string,
payload: AdminPostShippingProfilesProfileReq
): ResponsePromise<AdminShippingProfilesRes> {
payload: AdminPostShippingProfilesProfileReq,
customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingProfilesRes> {
const path = `/admin/shipping-profiles/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
delete(id: string): ResponsePromise<AdminDeleteShippingProfileRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDeleteShippingProfileRes> {
const path = `/admin/shipping-profiles/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
retrieve(id: string): ResponsePromise<AdminShippingProfilesRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingProfilesRes> {
const path = `/admin/shipping-profiles/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
list(): ResponsePromise<AdminShippingProfilesListRes> {
list(customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingProfilesListRes> {
const path = `/admin/shipping-profiles/`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -10,49 +10,52 @@ class AdminStoresResource extends BaseResource {
/**
* @description Updates the store
* @param payload update to apply to the store.
* @param customHeaders
* @returns the updated store.
*/
update(payload: AdminPostStoreReq): ResponsePromise<AdminStoresRes> {
update(payload: AdminPostStoreReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminStoresRes> {
const path = `/admin/store/`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description adds a currency to the store.
* @param currency_code code of the currency to add
* @param customHeaders
* @returns updated store.
*/
addCurrency(currency_code: string): ResponsePromise<AdminStoresRes> {
addCurrency(currency_code: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminStoresRes> {
const path = `/admin/store/${currency_code}`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
/**
* @description deletes a currency from the available store currencies
* @param currency_code currency code of the currency to delete from the store.
* @param customHeaders
* @returns updated store
*/
deleteCurrency(currency_code: string): ResponsePromise<AdminStoresRes> {
deleteCurrency(currency_code: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminStoresRes> {
const path = `/admin/store/currencies/${currency_code}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description gets a medusa store
* @returns a medusa store
*/
retrieve(): ResponsePromise<AdminStoresRes> {
retrieve(customHeaders: Record<string, any> = {}): ResponsePromise<AdminStoresRes> {
const path = `/admin/store/`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Lists the store's payment providers
* @returns a list of payment providers configured on the store
*/
listPaymentProviders(): ResponsePromise<AdminPaymentProvidersList> {
listPaymentProviders(customHeaders: Record<string, any> = {}): ResponsePromise<AdminPaymentProvidersList> {
const path = `/admin/store/payment-providers`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -8,12 +8,12 @@ import { ResponsePromise } from "../../typings"
import BaseResource from "../base"
class AdminSwapsResource extends BaseResource {
retrieve(id: string): ResponsePromise<AdminSwapsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminSwapsRes> {
const path = `/admin/swaps/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
list(query?: AdminGetSwapsParams): ResponsePromise<AdminSwapsListRes> {
list(query?: AdminGetSwapsParams, customHeaders: Record<string, any> = {}): ResponsePromise<AdminSwapsListRes> {
let path = `/admin/swaps/`
if (query) {
@@ -21,7 +21,7 @@ class AdminSwapsResource extends BaseResource {
path = `/admin/swaps?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -16,78 +16,87 @@ class AdminUsersResource extends BaseResource {
/**
* @description resets password by re-sending password token.
* @param payload payload for generating reset-password token.
* @param customHeaders
* @returns
*/
sendResetPasswordToken(
payload: AdminResetPasswordTokenRequest
payload: AdminResetPasswordTokenRequest,
customHeaders: Record<string, any> = {}
): ResponsePromise<void> {
const path = `/admin/users/password-token`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description resets the users password given the correct token.
* @param payload reset password information.
* @param customHeaders
* @returns
*/
resetPassword(
payload: AdminResetPasswordRequest
payload: AdminResetPasswordRequest,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminUserRes> {
const path = `admin/users/reset-password`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Retrieves a given user
* @param id id of the user
* @param customHeaders
* @returns the user
*/
retrieve(id: string): ResponsePromise<AdminUserRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminUserRes> {
const path = `/admin/users/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description creates a user with the provided information
* @param payload user creation request body
* @param customHeaders
* @returns created user
*/
create(payload: AdminCreateUserPayload): ResponsePromise<AdminUserRes> {
create(payload: AdminCreateUserPayload, customHeaders: Record<string, any> = {}): ResponsePromise<AdminUserRes> {
const path = `/admin/users`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description updates a given user
* @param id id of the user to update
* @param payload user update request body
* @param customHeaders
* @returns the updated user
*/
update(
id: string,
payload: AdminUpdateUserPayload
payload: AdminUpdateUserPayload,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminUserRes> {
const path = `/admin/users/${id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description deletes a user
* @param id id of the user to be deleted
* @param customHeaders
* @returns delete response
*/
delete(id: string): ResponsePromise<AdminDeleteUserRes> {
delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDeleteUserRes> {
const path = `/admin/users/${id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* @description lists all users
* @returns a list of all users
*/
list(): ResponsePromise<AdminUsersListRes> {
list(customHeaders: Record<string, any> = {}): ResponsePromise<AdminUsersListRes> {
const path = `/admin/users`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -4,7 +4,7 @@ import { ResponsePromise } from "../.."
import BaseResource from "../base"
class AdminVariantsResource extends BaseResource {
list(query?: AdminGetVariantsParams): ResponsePromise<AdminVariantsListRes> {
list(query?: AdminGetVariantsParams, customHeaders: Record<string, any> = {}): ResponsePromise<AdminVariantsListRes> {
let path = `/admin/variants`
if (query) {
@@ -12,7 +12,7 @@ class AdminVariantsResource extends BaseResource {
path = `/admin/variants?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

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)
}
}

View File

@@ -18,14 +18,15 @@ class CartsResource extends BaseResource {
* Adds a shipping method to cart
* @param {string} cart_id Id of cart
* @param {StorePostCartsCartShippingMethodReq} payload Containg id of shipping option and optional data
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
addShippingMethod(
cart_id: string,
payload: StorePostCartsCartShippingMethodReq
): ResponsePromise<StoreCartsRes> {
payload: StorePostCartsCartShippingMethodReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/shipping-methods`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -35,22 +36,24 @@ class CartsResource extends BaseResource {
* The completion of a cart can be performed idempotently with a provided header Idempotency-Key.
* If not provuided, we will generate one for the request.
* @param {string} cart_id is required
* @param customHeaders
* @return {ResponsePromise<StoreCompleteCartRes>}
*/
complete(cart_id: string): ResponsePromise<StoreCompleteCartRes> {
complete(cart_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCompleteCartRes> {
const path = `/store/carts/${cart_id}/complete`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
/**
* Creates a cart
* @param {StorePostCartReq} payload is optional and can contain a region_id and items.
* The cart will contain the payload, if provided. Otherwise it will be empty
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
create(payload?: StorePostCartReq): ResponsePromise<StoreCartsRes> {
create(payload?: StorePostCartReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -58,25 +61,27 @@ class CartsResource extends BaseResource {
* Initializes the payment sessions that can be used to pay for the items of the cart.
* This is usually called when a customer proceeds to checkout.
* @param {string} cart_id is required
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
createPaymentSessions(cart_id: string): ResponsePromise<StoreCartsRes> {
createPaymentSessions(cart_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-sessions`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
/**
* Removes a discount from cart.
* @param {string} cart_id is required
* @param {string} code discount code to remove
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
deleteDiscount(
cart_id: string,
code: string
): ResponsePromise<StoreCartsRes> {
code: string,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/discounts/${code}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
@@ -84,66 +89,71 @@ class CartsResource extends BaseResource {
* Can be useful in case a payment has failed
* @param {string} cart_id is required
* @param {string} provider_id the provider id of the session e.g. "stripe"
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
deletePaymentSession(
cart_id: string,
provider_id: string
): ResponsePromise<StoreCartsRes> {
provider_id: string,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-sessions/${provider_id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* Refreshes a payment session.
* @param {string} cart_id is required
* @param {string} provider_id the provider id of the session e.g. "stripe"
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
refreshPaymentSession(
cart_id: string,
provider_id: string
): ResponsePromise<StoreCartsRes> {
provider_id: string,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-sessions/${provider_id}/refresh`
return this.client.request("POST", path)
return this.client.request("POST", path, {}, {}, customHeaders)
}
/**
* Retrieves a cart
* @param {string} cart_id is required
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
retrieve(cart_id: string): ResponsePromise<StoreCartsRes> {
retrieve(cart_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* Refreshes a payment session.
* @param {string} cart_id is required
* @param {StorePostCartsCartPaymentSessionReq} payload the provider id of the session e.g. "stripe"
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
setPaymentSession(
cart_id: string,
payload: StorePostCartsCartPaymentSessionReq
): ResponsePromise<StoreCartsRes> {
payload: StorePostCartsCartPaymentSessionReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-session`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Updates a cart
* @param {string} cart_id is required
* @param {StorePostCartsCartReq} payload is required and can contain region_id, email, billing and shipping address
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
update(
cart_id: string,
payload: StorePostCartsCartReq
): ResponsePromise<StoreCartsRes> {
payload: StorePostCartsCartReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -151,15 +161,16 @@ class CartsResource extends BaseResource {
* @param {string} cart_id is required
* @param {string} provider_id is required
* @param {StorePostCartsCartPaymentSessionUpdateReq} payload is required
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
updatePaymentSession(
cart_id: string,
provider_id: string,
payload: StorePostCartsCartPaymentSessionUpdateReq
): ResponsePromise<StoreCartsRes> {
payload: StorePostCartsCartPaymentSessionUpdateReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-sessions/${provider_id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
}

View File

@@ -11,21 +11,23 @@ class CollectionsResource extends BaseResource {
/**
* @description Retrieves a single collection
* @param {string} id id of the collection
* @param customHeaders
* @return {ResponsePromise<StoreCollectionsRes>}
*/
retrieve(id: string): ResponsePromise<StoreCollectionsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCollectionsRes> {
const path = `/store/collections/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Retrieves a list of collections
* @param {string} query is optional. Can contain a limit and offset for the returned list
* @param customHeaders
* @return {ResponsePromise<StoreCollectionsListRes>}
*/
list(
query?: StoreGetCollectionsParams
): ResponsePromise<StoreCollectionsListRes> {
query?: StoreGetCollectionsParams,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCollectionsListRes> {
let path = `/store/collections`
if (query) {
@@ -33,7 +35,7 @@ class CollectionsResource extends BaseResource {
path = `/store/collections?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -19,42 +19,46 @@ class CustomerResource extends BaseResource {
/**
* Creates a customer
* @param {StorePostCustomersReq} payload information of customer
* @param customHeaders
* @return { ResponsePromise<StoreCustomersRes>}
*/
create(payload: StorePostCustomersReq): ResponsePromise<StoreCustomersRes> {
create(payload: StorePostCustomersReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Retrieves the customer that is currently logged
* @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>}
*/
retrieve(): ResponsePromise<StoreCustomersRes> {
retrieve(customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* Updates a customer
* @param {StorePostCustomersCustomerReq} payload information to update customer with
* @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>}
*/
update(
payload: StorePostCustomersCustomerReq
): ResponsePromise<StoreCustomersRes> {
payload: StorePostCustomersCustomerReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Retrieve customer orders
* @param {StoreGetCustomersCustomerOrdersParams} params optional params to retrieve orders
* @param customHeaders
* @return {ResponsePromise<StoreCustomersListOrdersRes>}
*/
listOrders(
params?: StoreGetCustomersCustomerOrdersParams
): ResponsePromise<StoreCustomersListOrdersRes> {
params?: StoreGetCustomersCustomerOrdersParams,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersListOrdersRes> {
let path = `/store/customers/me/orders`
if (params) {
const query = qs.stringify(params)
@@ -62,32 +66,35 @@ class CustomerResource extends BaseResource {
path += `?${query}`
}
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* Resets customer password
* @param {StorePostCustomersCustomerPasswordTokenReq} payload info used to reset customer password
* @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>}
*/
resetPassword(
payload: StorePostCustomersCustomerPasswordTokenReq
): ResponsePromise<StoreCustomersRes> {
payload: StorePostCustomersCustomerPasswordTokenReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/password-reset`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Generates a reset password token, which can be used to reset the password.
* The token is not returned but should be sent out to the customer in an email.
* @param {StorePostCustomersCustomerPasswordTokenReq} payload info used to generate token
* @param customHeaders
* @return {ResponsePromise}
*/
generatePasswordToken(
payload: StorePostCustomersCustomerPasswordTokenReq
payload: StorePostCustomersCustomerPasswordTokenReq,
customHeaders: Record<string, any> = {}
): ResponsePromise {
const path = `/store/customers/password-token`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
}

View File

@@ -6,11 +6,12 @@ class GiftCardsResource extends BaseResource {
/**
* @description Retrieves a single GiftCard
* @param {string} code code of the gift card
* @param customHeaders
* @return {ResponsePromise<StoreGiftCardsRes>}
*/
retrieve(code: string): ResponsePromise<StoreGiftCardsRes> {
retrieve(code: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreGiftCardsRes> {
const path = `/store/gift-cards/${code}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -11,14 +11,15 @@ class LineItemsResource extends BaseResource {
* Creates a line-item for a cart
* @param {string} cart_id id of cart
* @param {StorePostCartsCartLineItemsReq} payload details needed to create a line-item
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
create(
cart_id: string,
payload: StorePostCartsCartLineItemsReq
): ResponsePromise<StoreCartsRes> {
payload: StorePostCartsCartLineItemsReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/line-items`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
@@ -27,26 +28,28 @@ class LineItemsResource extends BaseResource {
* @param {string} cart_id id of cart
* @param {string} line_id id of item to update
* @param {StorePostCartsCartLineItemsItemReq} payload details needed to update a line-item
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
update(
cart_id: string,
line_id: string,
payload: StorePostCartsCartLineItemsItemReq
): ResponsePromise<StoreCartsRes> {
payload: StorePostCartsCartLineItemsItemReq,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/line-items/${line_id}`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Remove a line-item from a cart
* @param {string} cart_id id of cart
* @param {string} line_id id of item to remove
* @return {ResponsePromise<StoreCartsDeleteRes>}
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>}
*/
delete(cart_id: string, line_id: string): ResponsePromise<StoreCartsRes> {
delete(cart_id: string, line_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/line-items/${line_id}`
return this.client.request("DELETE", path)
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
}

View File

@@ -7,35 +7,38 @@ class OrdersResource extends BaseResource {
/**
* @description Retrieves an order
* @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreOrdersRes>}
*/
retrieve(id: string): ResponsePromise<StoreOrdersRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreOrdersRes> {
const path = `/store/orders/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Retrieves an order by cart id
* @param {string} cart_id is required
* @param customHeaders
* @return {ResponsePromise<StoreOrdersRes>}
*/
retrieveByCartId(cart_id: string): ResponsePromise<StoreOrdersRes> {
retrieveByCartId(cart_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreOrdersRes> {
const path = `/store/orders/cart/${cart_id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Look up an order using order details
* @param {StoreGetOrdersParams} payload details used to look up the order
* @param customHeaders
* @return {ResponsePromise<StoreOrdersRes>}
*/
lookupOrder(payload: StoreGetOrdersParams): ResponsePromise<StoreOrdersRes> {
lookupOrder(payload: StoreGetOrdersParams, customHeaders: Record<string, any> = {}): ResponsePromise<StoreOrdersRes> {
let path = `/store/orders?`
const queryString = qs.stringify(payload)
path = `/store/orders?${queryString}`
return this.client.request("GET", path, payload)
return this.client.request("GET", path, payload, {}, customHeaders)
}
}

View File

@@ -6,11 +6,12 @@ class PaymentMethodsResource extends BaseResource {
/**
* Lists customer payment methods
* @param {string} id id of cart
* @param customHeaders
* @return {StoreCustomersListPaymentMethodsRes}
*/
list(id: string): ResponsePromise<StoreCustomersListPaymentMethodsRes> {
list(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersListPaymentMethodsRes> {
const path = `/store/carts/${id}/payment-methods`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -11,26 +11,28 @@ class ProductVariantsResource extends BaseResource {
/**
* @description Retrieves a single product variant
* @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreVariantsRes>}
*/
retrieve(id: string): ResponsePromise<StoreVariantsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreVariantsRes> {
const path = `/store/variants/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Retrieves a list of of Product Variants
* @param {StoreVariantsListParamsObject} query
* @param {StoreGetVariantsParams} query
* @param customHeaders
* @return {ResponsePromise<StoreVariantsListRes>}
*/
list(query?: StoreGetVariantsParams): ResponsePromise<StoreVariantsListRes> {
list(query?: StoreGetVariantsParams, customHeaders: Record<string, any> = {}): ResponsePromise<StoreVariantsListRes> {
let path = `/store/variants`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, undefined, {}, customHeaders)
}
}

View File

@@ -16,31 +16,35 @@ class ProductsResource extends BaseResource {
/**
* @description Retrieves a single Product
* @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreProductsRes>}
*/
retrieve(id: string): ResponsePromise<StoreProductsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreProductsRes> {
const path = `/store/products/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Searches for products
* @param {StorePostSearchReq} searchOptions is required
* @param customHeaders
* @return {ResponsePromise<StorePostSearchRes>}
*/
search(
searchOptions: StorePostSearchReq
searchOptions: StorePostSearchReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<StorePostSearchRes> {
const path = `/store/products/search`
return this.client.request("POST", path, searchOptions)
return this.client.request("POST", path, searchOptions, {}, customHeaders)
}
/**
* @description Retrieves a list of products
* @param {StoreGetProductsParams} query is optional. Can contain a limit and offset for the returned list
* @param customHeaders
* @return {ResponsePromise<StoreProductsListRes>}
*/
list(query?: StoreGetProductsParams): ResponsePromise<StoreProductsListRes> {
list(query?: StoreGetProductsParams, customHeaders: Record<string, any> = {}): ResponsePromise<StoreProductsListRes> {
let path = `/store/products`
if (query) {
@@ -48,7 +52,7 @@ class ProductsResource extends BaseResource {
path = `/store/products?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -5,21 +5,23 @@ import BaseResource from "./base"
class RegionsResource extends BaseResource {
/**
* @description Retrieves a list of regions
* @param customHeaders
* @return {ResponsePromise<StoreRegionsListRes>}
*/
list(): ResponsePromise<StoreRegionsListRes> {
list(customHeaders: Record<string, any> = {}): ResponsePromise<StoreRegionsListRes> {
const path = `/store/regions`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Retrieves a region
* @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreRegionsRes>}
*/
retrieve(id: string): ResponsePromise<StoreRegionsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreRegionsRes> {
const path = `/store/regions/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -9,20 +9,22 @@ class ReturnReasonsResource extends BaseResource {
/**
* @description Retrieves a single Return Reason
* @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreReturnReasonsRes>}
*/
retrieve(id: string): ResponsePromise<StoreReturnReasonsRes> {
retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreReturnReasonsRes> {
const path = `/store/return-reasons/${id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* Lists return reasons defined in Medusa Admin
* @param customHeaders
* @return {ResponsePromise<StoreReturnReasonsListRes>}
*/
list(): ResponsePromise<StoreReturnReasonsListRes> {
list(customHeaders: Record<string, any> = {}): ResponsePromise<StoreReturnReasonsListRes> {
const path = `/store/return-reasons`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -6,11 +6,12 @@ class ReturnsResource extends BaseResource {
/**
* Creates a return request
* @param {StorePostReturnsReq} payload details needed to create a return
* @param customHeaders
* @return {ResponsePromise<StoreReturnsRes>}
*/
create(payload: StorePostReturnsReq): ResponsePromise<StoreReturnsRes> {
create(payload: StorePostReturnsReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreReturnsRes> {
const path = `/store/returns`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
}

View File

@@ -10,23 +10,23 @@ class ShippingOptionsResource extends BaseResource {
/**
* @description Lists shiping options available for a cart
* @param {string} cart_id
* @param customHeaders
* @return {ResponsePromise<StoreShippingOptionsListRes>}
*/
listCartOptions(
cart_id: string
): ResponsePromise<StoreShippingOptionsListRes> {
listCartOptions(cart_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreShippingOptionsListRes> {
const path = `/store/shipping-options/${cart_id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
/**
* @description Lists shiping options available
* @param {StoreGetShippingOptionsParamsObject} query
* @param {StoreGetShippingOptionsParams} query
* @param customHeaders
* @return {ResponsePromise<StoreShippingOptionsListRes>}
*/
list(
query?: StoreGetShippingOptionsParams
): ResponsePromise<StoreShippingOptionsListRes> {
query?: StoreGetShippingOptionsParams,
customHeaders: Record<string, any> = {}): ResponsePromise<StoreShippingOptionsListRes> {
let path = `/store/shipping-options`
if (query) {
@@ -34,7 +34,7 @@ class ShippingOptionsResource extends BaseResource {
path = `/store/shipping-options?${queryString}`
}
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -6,21 +6,23 @@ class SwapsResource extends BaseResource {
/**
* @description Creates a swap from a cart
* @param {StorePostSwapsReq} payload
* @param customHeaders
* @return {ResponsePromise<StoreSwapsRes>}
*/
create(payload: StorePostSwapsReq): ResponsePromise<StoreSwapsRes> {
create(payload: StorePostSwapsReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreSwapsRes> {
const path = `/store/swaps`
return this.client.request("POST", path, payload)
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* @description Retrieves a swap by cart id
* @param {string} cart_id id of cart
* @param customHeaders
* @return {ResponsePromise<StoreSwapsRes>}
*/
retrieveByCartId(cart_id: string): ResponsePromise<StoreSwapsRes> {
retrieveByCartId(cart_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreSwapsRes> {
const path = `/store/swaps/${cart_id}`
return this.client.request("GET", path)
return this.client.request("GET", path, {}, {}, customHeaders)
}
}

View File

@@ -189,7 +189,7 @@ export class AdminPostDraftOrdersReq {
@IsObject()
@IsOptional()
metadata?: object = {}
metadata?: Record<string, any> = {}
}
class ShippingMethod {
@@ -198,7 +198,7 @@ class ShippingMethod {
@IsObject()
@IsOptional()
data?: object = {}
data?: Record<string, any> = {}
@IsNumber()
@IsOptional()
@@ -228,5 +228,5 @@ class Item {
@IsObject()
@IsOptional()
metadata?: object = {}
metadata?: Record<string, any> = {}
}

View File

@@ -134,5 +134,5 @@ export class AdminPostDraftOrdersDraftOrderLineItemsReq {
@IsObject()
@IsOptional()
metadata?: object = {}
metadata?: Record<string, any> = {}
}

View File

@@ -128,5 +128,5 @@ export class AdminPostDraftOrdersDraftOrderLineItemsItemReq {
@IsObject()
@IsOptional()
metadata?: object = {}
metadata?: Record<string, any> = {}
}

View File

@@ -70,5 +70,5 @@ export class AdminPostOrdersOrderShippingMethodsReq {
@IsObject()
@IsOptional()
data?: object = {}
data?: Record<string, any> = {}
}

View File

@@ -67,5 +67,5 @@ export class StorePostCartsCartShippingMethodReq {
option_id: string
@IsOptional()
data?: object = {}
data?: Record<string, any> = {}
}

View File

@@ -1215,7 +1215,7 @@ class CartService extends BaseService {
* this could be IP address or similar for fraud handling.
* @return {Promise<Cart>} the resulting cart
*/
async authorizePayment(cartId: string, context: object = {}): Promise<Cart> {
async authorizePayment(cartId: string, context: Record<string, any> = {}): Promise<Cart> {
return this.atomicPhase_(async (manager: EntityManager) => {
const cartRepository = manager.getCustomRepository(this.cartRepository_)
@@ -1520,7 +1520,7 @@ class CartService extends BaseService {
async addShippingMethod(
cartId: string,
optionId: string,
data: object = {}
data: Record<string, any> = {}
): Promise<Cart> {
return this.atomicPhase_(async (manager: EntityManager) => {
const cart = await this.retrieve(cartId, {

View File

@@ -666,7 +666,7 @@ class ProductVariantService extends BaseService {
* @param {Object} metadata - the metadata to set
* @return {Object} updated metadata object
*/
setMetadata_(variant: ProductVariant, metadata: object): object {
setMetadata_(variant: ProductVariant, metadata: object): Record<string, any> {
const existing = variant.metadata || {}
const newData = {}
for (const [key, value] of Object.entries(metadata)) {