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 PerettiandSebastian Rindom authored and olivermrbl committed 2022-02-25 18:53:49 +01:00
1 parent 1f2ee04abe
commit 8a2e4f74ff
45 files changed
+572 -433

No files matched your search

@@ -150,7 +150,7 @@ describe("/store/carts", () => {
const cart = getRes.data.cart const cart = getRes.data.cart
expect(cart.context).toEqual({ expect(cart.context).toEqual({
ip: "::ffff:127.0.0.1", ip: "::ffff:127.0.0.1",
user_agent: "axios/0.21.1", user_agent: expect.stringContaining("axios/0.21."),
test_id: "test", test_id: "test",
}) })
}) })
+5 -5
View File
@@ -68,7 +68,7 @@ class Client {
} }
// Stolen from https://github.com/stripe/stripe-node/blob/fd0a597064289b8c82f374f4747d634050739043/lib/utils.js#L282 // 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")) { if (!(obj && typeof obj === "object")) {
return obj return obj
} }
@@ -109,9 +109,9 @@ class Client {
userHeaders: RequestOptions, userHeaders: RequestOptions,
method: RequestMethod, method: RequestMethod,
path: string, path: string,
customHeaders: object = {} customHeaders: Record<string, any> = {}
): AxiosRequestHeaders { ): AxiosRequestHeaders {
let defaultHeaders: object = { let defaultHeaders: Record<string, any> = {
Accept: "application/json", Accept: "application/json",
"Content-Type": "application/json", "Content-Type": "application/json",
} }
@@ -183,9 +183,9 @@ class Client {
async request( async request(
method: RequestMethod, method: RequestMethod,
path: string, path: string,
payload: object = {}, payload: Record<string, any> = {},
options: RequestOptions = {}, options: RequestOptions = {},
customHeaders: object = {} customHeaders: Record<string, any> = {}
): Promise<any> { ): Promise<any> {
const reqOpts = { const reqOpts = {
method, method,
+14 -11
View File
@@ -10,37 +10,40 @@ class AddressesResource extends BaseResource {
/** /**
* Adds an address to a customers saved addresses * Adds an address to a customers saved addresses
* @param {StorePostCustomersCustomerAddressesReq} payload contains information to create an address * @param {StorePostCustomersCustomerAddressesReq} payload contains information to create an address
* @return {ResponsePromise<StoreCustomerResponse>} * @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>}
*/ */
addAddress( addAddress(
payload: StorePostCustomersCustomerAddressesReq payload: StorePostCustomersCustomerAddressesReq,
): ResponsePromise<StoreCustomersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me/addresses` 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 * Deletes an address of a customer
* @param {string} address_id id of the address to delete * @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}` 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 * Update an address of a customer
* @param {string} address_id id of customer * @param {string} address_id id of customer
* @param {StorePostCustomersCustomerAddressesAddressReq} payload address update * @param {StorePostCustomersCustomerAddressesAddressReq} payload address update
* @return {StoreCustomersResponse} * @param customHeaders
* @return {StoreCustomersRes}
*/ */
updateAddress( updateAddress(
address_id: string, address_id: string,
payload: StorePostCustomersCustomerAddressesAddressReq payload: StorePostCustomersCustomerAddressesAddressReq,
): ResponsePromise<StoreCustomersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me/addresses/${address_id}` const path = `/store/customers/me/addresses/${address_id}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
} }
@@ -6,30 +6,33 @@ class AdminAuthResource extends BaseResource {
/** /**
* @description Retrieves an authenticated session * @description Retrieves an authenticated session
* Usually used to check if authenticated session is alive. * Usually used to check if authenticated session is alive.
* @param customHeaders
* @return {ResponsePromise<AdminAuthRes>} * @return {ResponsePromise<AdminAuthRes>}
*/ */
getSession(): ResponsePromise<AdminAuthRes> { getSession(customHeaders: Record<string, any> = {}): ResponsePromise<AdminAuthRes> {
const path = `/admin/auth` const path = `/admin/auth`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description destroys an authenticated session * @description destroys an authenticated session
* @param customHeaders
* @return {ResponsePromise<void>} * @return {ResponsePromise<void>}
*/ */
deleteSession(): ResponsePromise<void> { deleteSession(customHeaders: Record<string, any> = {}): ResponsePromise<void> {
const path = `/admin/auth` const path = `/admin/auth`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
/** /**
* @description Creates an authenticated session * @description Creates an authenticated session
* @param {AdminPostAuthReq} payload * @param {AdminPostAuthReq} payload
* @param customHeaders
* @return {ResponsePromise<AdminAuthRes>} * @return {ResponsePromise<AdminAuthRes>}
*/ */
createSession(payload: AdminPostAuthReq): ResponsePromise<AdminAuthRes> { createSession(payload: AdminPostAuthReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminAuthRes> {
const path = `/admin/auth` const path = `/admin/auth`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
} }
@@ -14,56 +14,64 @@ class AdminCollectionsResource extends BaseResource {
/** /**
* @description Creates a collection. * @description Creates a collection.
* @param payload * @param payload
* @param customHeaders
* @returns Created collection. * @returns Created collection.
*/ */
create( create(
payload: AdminPostCollectionsReq payload: AdminPostCollectionsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCollectionsRes> { ): ResponsePromise<AdminCollectionsRes> {
const path = `/admin/collections` const path = `/admin/collections`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* @description Updates a collection * @description Updates a collection
* @param id id of the collection to update. * @param id id of the collection to update.
* @param payload update to apply to collection. * @param payload update to apply to collection.
* @param customHeaders
* @returns the updated collection. * @returns the updated collection.
*/ */
update( update(
id: string, id: string,
payload: AdminPostCollectionsCollectionReq payload: AdminPostCollectionsCollectionReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCollectionsRes> { ): ResponsePromise<AdminCollectionsRes> {
const path = `/admin/collections/${id}` const path = `/admin/collections/${id}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* @description deletes a collection * @description deletes a collection
* @param id id of collection to delete. * @param id id of collection to delete.
* @param customHeaders
* @returns Deleted response * @returns Deleted response
*/ */
delete(id: string): ResponsePromise<AdminCollectionsDeleteRes> { delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminCollectionsDeleteRes> {
const path = `/admin/collections/${id}` const path = `/admin/collections/${id}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
/** /**
* @description get a collection * @description get a collection
* @param id id of the collection to retrieve. * @param id id of the collection to retrieve.
* @param customHeaders
* @returns the collection with the given id * @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}` const path = `/admin/collections/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Lists collections matching a query * @description Lists collections matching a query
* @param query Query for searching collections * @param query Query for searching collections
* @param customHeaders
* @returns a list of collections matching the query. * @returns a list of collections matching the query.
*/ */
list( list(
query?: AdminGetCollectionsParams query?: AdminGetCollectionsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCollectionsListRes> { ): ResponsePromise<AdminCollectionsListRes> {
let path = `/admin/collections` let path = `/admin/collections`
@@ -72,7 +80,7 @@ class AdminCollectionsResource extends BaseResource {
path = `/admin/collections?${queryString}` path = `/admin/collections?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -13,40 +13,46 @@ class AdminCustomersResource extends BaseResource {
/** /**
* Creates a customer * Creates a customer
* @param payload information of 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` const path = `/admin/customers`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* Updates a customer * Updates a customer
* @param id customer id * @param id customer id
* @param payload data to update customer with * @param payload data to update customer with
* @param customHeaders
*/ */
update( update(
id: string, id: string,
payload: AdminPostCustomersCustomerReq payload: AdminPostCustomersCustomerReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCustomersRes> { ): ResponsePromise<AdminCustomersRes> {
const path = `/admin/customers/${id}` const path = `/admin/customers/${id}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* Retrieves a customer * Retrieves a customer
* @param id customer id * @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}` const path = `/admin/customers/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* Lists customers * Lists customers
* @param query optional * @param query optional
* @param customHeaders
*/ */
list( list(
query?: AdminGetCustomersParams query?: AdminGetCustomersParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminCustomersListRes> { ): ResponsePromise<AdminCustomersListRes> {
let path = `/admin/customers` let path = `/admin/customers`
@@ -55,7 +61,7 @@ class AdminCustomersResource extends BaseResource {
path = `/admin/customers?${queryString}` path = `/admin/customers?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -15,9 +15,9 @@ class AdminDiscountsResource extends BaseResource {
/** /**
* @description Adds region to discount * @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}` 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( addValidProduct(
id: string, id: string,
productId: string productId: string,
): ResponsePromise<AdminDiscountsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/products/${productId}` const path = `/admin/discounts/${id}/products/${productId}`
return this.client.request("POST", path, {}) return this.client.request("POST", path, {})
} }
@@ -34,9 +34,9 @@ class AdminDiscountsResource extends BaseResource {
/** /**
* @description Creates discounts * @description Creates discounts
*/ */
create(payload: AdminPostDiscountsReq): ResponsePromise<AdminDiscountsRes> { create(payload: AdminPostDiscountsReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts` 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( update(
id: string, id: string,
payload: AdminPostDiscountsDiscountReq payload: AdminPostDiscountsDiscountReq,
): ResponsePromise<AdminDiscountsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}` 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( createDynamicCode(
id: string, id: string,
payload: AdminPostDiscountsDiscountDynamicCodesReq payload: AdminPostDiscountsDiscountDynamicCodesReq,
): ResponsePromise<AdminDiscountsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/dynamic-codes` 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 * @description Deletes a discount
*/ */
delete(id: string): ResponsePromise<AdminDiscountsDeleteRes> { delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsDeleteRes> {
const path = `/admin/discounts/${id}` 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( deleteDynamicCode(
id: string, id: string,
code: string code: string,
): ResponsePromise<AdminDiscountsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/dynamic-codes/${code}` 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 * @description Retrieves a discount
*/ */
retrieve(id: string): ResponsePromise<AdminDiscountsRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}` const path = `/admin/discounts/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Retrieves a discount by code * @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}` const path = `/admin/discounts/code/${code}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Lists discounts * @description Lists discounts
*/ */
list( list(
query?: AdminGetDiscountsParams query?: AdminGetDiscountsParams,
): ResponsePromise<AdminDiscountsListRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsListRes> {
let path = `/admin/discounts` let path = `/admin/discounts`
if (query) { if (query) {
@@ -109,7 +109,7 @@ class AdminDiscountsResource extends BaseResource {
path = `/admin/discounts?${queryString}` 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( removeRegion(
id: string, id: string,
regionId: string regionId: string,
): ResponsePromise<AdminDiscountsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/regions/${regionId}` 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( removeValidProduct(
id: string, id: string,
productId: string productId: string,
): ResponsePromise<AdminDiscountsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDiscountsRes> {
const path = `/admin/discounts/${id}/products/${productId}` const path = `/admin/discounts/${id}/products/${productId}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
} }
@@ -17,10 +17,10 @@ class AdminDraftOrdersResource extends BaseResource {
* @description Creates a draft order * @description Creates a draft order
*/ */
create( create(
payload: AdminPostDraftOrdersDraftOrderReq payload: AdminPostDraftOrdersDraftOrderReq,
): ResponsePromise<AdminDraftOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders` 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( addLineItem(
id: string, id: string,
payload: AdminPostDraftOrdersDraftOrderLineItemsReq payload: AdminPostDraftOrdersDraftOrderLineItemsReq,
): ResponsePromise<AdminDraftOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}/line-items` 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 * @description Delete draft order
*/ */
delete(id: string): ResponsePromise<AdminDraftOrdersDeleteRes> { delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersDeleteRes> {
const path = `/admin/draft-orders/${id}` 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( removeLineItem(
id: string, id: string,
itemId: string itemId: string,
): ResponsePromise<AdminDraftOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}/line-items/${itemId}` 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 * @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}` const path = `/admin/draft-orders/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Lists draft orders * @description Lists draft orders
*/ */
list( list(
query?: AdminGetDraftOrdersParams query?: AdminGetDraftOrdersParams,
): ResponsePromise<AdminDraftOrdersListRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersListRes> {
let path = `/admin/draft-orders` let path = `/admin/draft-orders`
if (query) { if (query) {
@@ -74,14 +74,15 @@ class AdminDraftOrdersResource extends BaseResource {
path = `/admin/draft-orders?${queryString}` 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 * @description Mark a draft order as paid
*/ */
markPaid( markPaid(
id: string id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminPostDraftOrdersDraftOrderRegisterPaymentRes> { ): ResponsePromise<AdminPostDraftOrdersDraftOrderRegisterPaymentRes> {
const path = `/admin/draft-orders/${id}/pay` const path = `/admin/draft-orders/${id}/pay`
return this.client.request("POST", path, {}) return this.client.request("POST", path, {})
@@ -92,10 +93,10 @@ class AdminDraftOrdersResource extends BaseResource {
*/ */
update( update(
id: string, id: string,
payload: AdminPostDraftOrdersDraftOrderReq payload: AdminPostDraftOrdersDraftOrderReq,
): ResponsePromise<AdminDraftOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}` 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( updateLineItem(
id: string, id: string,
itemId: string, itemId: string,
payload: AdminPostDraftOrdersDraftOrderLineItemsItemReq payload: AdminPostDraftOrdersDraftOrderLineItemsItemReq,
): ResponsePromise<AdminDraftOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminDraftOrdersRes> {
const path = `/admin/draft-orders/${id}/line-items/${itemId}` const path = `/admin/draft-orders/${id}/line-items/${itemId}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
} }
@@ -14,9 +14,9 @@ class AdminGiftCardsResource extends BaseResource {
/** /**
* @description Creates a gift card * @description Creates a gift card
*/ */
create(payload: AdminPostGiftCardsReq): ResponsePromise<AdminGiftCardsRes> { create(payload: AdminPostGiftCardsReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminGiftCardsRes> {
const path = `/admin/gift-cards` 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( update(
id: string, id: string,
payload: AdminPostGiftCardsGiftCardReq payload: AdminPostGiftCardsGiftCardReq,
): ResponsePromise<AdminGiftCardsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminGiftCardsRes> {
const path = `/admin/gift-cards/${id}` 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 * @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}` const path = `/admin/gift-cards/${id}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
/** /**
* @description Deletes a gift card * @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}` const path = `/admin/gift-cards/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Lists gift cards * @description Lists gift cards
*/ */
list( list(
query?: AdminGetGiftCardsParams query?: AdminGetGiftCardsParams,
): ResponsePromise<AdminGiftCardsListRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminGiftCardsListRes> {
let path = `/admin/gift-cards/` let path = `/admin/gift-cards/`
if (query) { if (query) {
@@ -59,7 +59,7 @@ class AdminGiftCardsResource extends BaseResource {
path = `/admin/gift-cards?${queryString}` path = `/admin/gift-cards?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -7,29 +7,29 @@ import { AdminPostInvitesPayload, ResponsePromise } from "../.."
import BaseResource from "../base" import BaseResource from "../base"
class AdminInvitesResource extends BaseResource { class AdminInvitesResource extends BaseResource {
accept(payload: AdminPostInvitesInviteAcceptReq): ResponsePromise { accept(payload: AdminPostInvitesInviteAcceptReq, customHeaders: Record<string, any> = {}): ResponsePromise {
const path = `/admin/invites/accept` 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` 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}` 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` 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}` const path = `/admin/invites/${id}`
return this.client.request("POST", path, {}) return this.client.request("POST", path, {}, {}, customHeaders)
} }
} }
+11 -11
View File
@@ -11,30 +11,30 @@ import { ResponsePromise } from "../../typings"
import BaseResource from "../base" import BaseResource from "../base"
class AdminNotesResource extends BaseResource { class AdminNotesResource extends BaseResource {
create(payload: AdminPostNotesReq): ResponsePromise<AdminNotesRes> { create(payload: AdminPostNotesReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotesRes> {
const path = `/admin/notes` const path = `/admin/notes`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
update( update(
id: string, id: string,
payload: AdminPostNotesNoteReq payload: AdminPostNotesNoteReq,
): ResponsePromise<AdminNotesRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotesRes> {
const path = `/admin/notes/${id}` 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}` 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}` 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/` let path = `/admin/notes/`
if (query) { if (query) {
@@ -42,7 +42,7 @@ class AdminNotesResource extends BaseResource {
path = `/admin/notes?${queryString}` path = `/admin/notes?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -10,8 +10,8 @@ import BaseResource from "../base"
class AdminNotificationsResource extends BaseResource { class AdminNotificationsResource extends BaseResource {
list( list(
query?: AdminGetNotificationsParams query?: AdminGetNotificationsParams,
): ResponsePromise<AdminNotificationsListRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotificationsListRes> {
let path = `/admin/notifications` let path = `/admin/notifications`
if (query) { if (query) {
@@ -19,15 +19,15 @@ class AdminNotificationsResource extends BaseResource {
path = `/admin/notifications?${queryString}` path = `/admin/notifications?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
resend( resend(
id: string, id: string,
payload: AdminPostNotificationsNotificationResendReq payload: AdminPostNotificationsNotificationResendReq,
): ResponsePromise<AdminNotificationsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminNotificationsRes> {
const path = `/admin/notifications/${id}/resend` const path = `/admin/notifications/${id}/resend`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
} }
@@ -22,25 +22,25 @@ import { ResponsePromise } from "../../typings"
import BaseResource from "../base" import BaseResource from "../base"
class AdminOrdersResource extends BaseResource { class AdminOrdersResource extends BaseResource {
create(payload: AdminPostOrdersReq): ResponsePromise<AdminOrdersRes> { create(payload: AdminPostOrdersReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders` const path = `/admin/orders`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
update( update(
id: string, id: string,
payload: AdminPostOrdersOrderReq payload: AdminPostOrdersOrderReq,
): ResponsePromise<AdminOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}` 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}` 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` let path = `/admin/orders`
if (query) { if (query) {
@@ -48,177 +48,191 @@ class AdminOrdersResource extends BaseResource {
path = `/admin/orders?${queryString}` 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` 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` const path = `/admin/orders/${id}/capture`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
refundPayment( refundPayment(
id: string, id: string,
payload: AdminPostOrdersOrderRefundsReq payload: AdminPostOrdersOrderRefundsReq,
): ResponsePromise<AdminOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/refund` const path = `/admin/orders/${id}/refund`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
createFulfillment( createFulfillment(
id: string, id: string,
payload: AdminPostOrdersOrderFulfillmentsReq payload: AdminPostOrdersOrderFulfillmentsReq,
): ResponsePromise<AdminOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/fulfillment` const path = `/admin/orders/${id}/fulfillment`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
cancelFulfillment( cancelFulfillment(
id: string, id: string,
fulfillmentId: string fulfillmentId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/fulfillments/${fulfillmentId}/cancel` const path = `/admin/orders/${id}/fulfillments/${fulfillmentId}/cancel`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
cancelSwapFulfillment( cancelSwapFulfillment(
id: string, id: string,
swapId: string, swapId: string,
fulfillmentId: string fulfillmentId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/fulfillments/${fulfillmentId}/cancel` const path = `/admin/orders/${id}/swaps/${swapId}/fulfillments/${fulfillmentId}/cancel`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
cancelClaimFulfillment( cancelClaimFulfillment(
id: string, id: string,
claimId: string, claimId: string,
fulfillmentId: string fulfillmentId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}/fulfillments/${fulfillmentId}/cancel` const path = `/admin/orders/${id}/claims/${claimId}/fulfillments/${fulfillmentId}/cancel`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
createShipment( createShipment(
id: string, id: string,
payload: AdminPostOrdersOrderShipmentReq payload: AdminPostOrdersOrderShipmentReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/shipment` const path = `/admin/orders/${id}/shipment`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
requestReturn( requestReturn(
id: string, id: string,
payload: AdminPostOrdersOrderReturnsReq payload: AdminPostOrdersOrderReturnsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/return` 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` const path = `/admin/orders/${id}/cancel`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
addShippingMethod( addShippingMethod(
id: string, id: string,
payload: AdminPostOrdersOrderShippingMethodsReq payload: AdminPostOrdersOrderShippingMethodsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/shipping-methods` 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` const path = `/admin/orders/${id}/archive`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
createSwap( createSwap(
id: string, id: string,
payload: AdminPostOrdersOrderSwapsReq payload: AdminPostOrdersOrderSwapsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps` 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` const path = `/admin/orders/${id}/swaps/${swapId}/cancel`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
fulfillSwap( fulfillSwap(
id: string, id: string,
swapId: string, swapId: string,
payload: AdminPostOrdersOrderSwapsSwapFulfillmentsReq payload: AdminPostOrdersOrderSwapsSwapFulfillmentsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/fulfillments` const path = `/admin/orders/${id}/swaps/${swapId}/fulfillments`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
createSwapShipment( createSwapShipment(
id: string, id: string,
swapId: string, swapId: string,
payload: AdminPostOrdersOrderSwapsSwapShipmentsReq payload: AdminPostOrdersOrderSwapsSwapShipmentsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/shipments` const path = `/admin/orders/${id}/swaps/${swapId}/shipments`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
processSwapPayment( processSwapPayment(
id: string, id: string,
swapId: string swapId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/swaps/${swapId}/process-payment` const path = `/admin/orders/${id}/swaps/${swapId}/process-payment`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
createClaim( createClaim(
id: string, id: string,
payload: AdminPostOrdersOrderClaimsReq payload: AdminPostOrdersOrderClaimsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims` 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` const path = `/admin/orders/${id}/claims/${claimId}/cancel`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
updateClaim( updateClaim(
id: string, id: string,
claimId: string, claimId: string,
payload: AdminPostOrdersOrderClaimsClaimReq payload: AdminPostOrdersOrderClaimsClaimReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}` const path = `/admin/orders/${id}/claims/${claimId}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
fulfillClaim( fulfillClaim(
id: string, id: string,
claimId: string, claimId: string,
payload: AdminPostOrdersOrderClaimsClaimFulfillmentsReq payload: AdminPostOrdersOrderClaimsClaimFulfillmentsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}/fulfillments` const path = `/admin/orders/${id}/claims/${claimId}/fulfillments`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
createClaimShipment( createClaimShipment(
id: string, id: string,
claimId: string, claimId: string,
payload: AdminPostOrdersOrderClaimsClaimShipmentsReq payload: AdminPostOrdersOrderClaimsClaimShipmentsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminOrdersRes> { ): ResponsePromise<AdminOrdersRes> {
const path = `/admin/orders/${id}/claims/${claimId}/shipments` 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}` const path = `/admin/orders/${id}/metadata/${key}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
} }
@@ -20,30 +20,30 @@ import { ResponsePromise } from "../../typings"
import BaseResource from "../base" import BaseResource from "../base"
class AdminProductsResource extends BaseResource { class AdminProductsResource extends BaseResource {
create(payload: AdminPostProductsReq): ResponsePromise<AdminProductsRes> { create(payload: AdminPostProductsReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/` 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}` const path = `/admin/products/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
update( update(
id: string, id: string,
payload: AdminPostProductsProductReq payload: AdminPostProductsProductReq,
): ResponsePromise<AdminProductsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}` 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}` 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` let path = `/admin/products`
if (query) { if (query) {
@@ -51,75 +51,82 @@ class AdminProductsResource extends BaseResource {
path = `/admin/products?${queryString}` 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` 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` const path = `/admin/products/tag-usage`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
setMetadata( setMetadata(
id: string, id: string,
payload: AdminPostProductsProductMetadataReq payload: AdminPostProductsProductMetadataReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> { ): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/metadata` const path = `/admin/products/${id}/metadata`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
createVariant( createVariant(
id: string, id: string,
payload: AdminPostProductsProductVariantsReq payload: AdminPostProductsProductVariantsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> { ): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/variants` const path = `/admin/products/${id}/variants`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
updateVariant( updateVariant(
id: string, id: string,
variantId: string, variantId: string,
payload: AdminPostProductsProductVariantsVariantReq payload: AdminPostProductsProductVariantsVariantReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> { ): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/variants/${variantId}` const path = `/admin/products/${id}/variants/${variantId}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
deleteVariant( deleteVariant(
id: string, id: string,
variantId: string variantId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsDeleteVariantRes> { ): ResponsePromise<AdminProductsDeleteVariantRes> {
const path = `/admin/products/${id}/variants/${variantId}` const path = `/admin/products/${id}/variants/${variantId}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
addOption( addOption(
id: string, id: string,
payload: AdminPostProductsProductOptionsReq payload: AdminPostProductsProductOptionsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> { ): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/options` const path = `/admin/products/${id}/options`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
updateOption( updateOption(
id: string, id: string,
optionId: string, optionId: string,
payload: AdminPostProductsProductOptionsOption payload: AdminPostProductsProductOptionsOption,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsRes> { ): ResponsePromise<AdminProductsRes> {
const path = `/admin/products/${id}/options/${optionId}` const path = `/admin/products/${id}/options/${optionId}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
deleteOption( deleteOption(
id: string, id: string,
optionId: string optionId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminProductsDeleteOptionRes> { ): ResponsePromise<AdminProductsDeleteOptionRes> {
const path = `/admin/products/${id}/options/${optionId}` const path = `/admin/products/${id}/options/${optionId}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
} }
@@ -19,53 +19,59 @@ class AdminRegionsResource extends BaseResource {
/** /**
* @description creates a region. * @description creates a region.
* @param payload * @param payload
* @param customHeaders
* @returns created region. * @returns created region.
*/ */
create(payload: AdminPostRegionsReq): ResponsePromise<AdminRegionsRes> { create(payload: AdminPostRegionsReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions` const path = `/admin/regions`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* @description updates a region * @description updates a region
* @param id id of the region to update. * @param id id of the region to update.
* @param payload update to apply to region. * @param payload update to apply to region.
* @param customHeaders
* @returns the updated region. * @returns the updated region.
*/ */
update( update(
id: string, id: string,
payload: AdminPostRegionsRegionReq payload: AdminPostRegionsRegionReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> { ): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}` const path = `/admin/regions/${id}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* @description deletes a region * @description deletes a region
* @param id id of region to delete. * @param id id of region to delete.
* @param customHeaders
* @returns Deleted response * @returns Deleted response
*/ */
delete(id: string): ResponsePromise<AdminRegionsDeleteRes> { delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminRegionsDeleteRes> {
const path = `/admin/regions/${id}` const path = `/admin/regions/${id}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
/** /**
* @description get a region * @description get a region
* @param id id of the region to retrieve. * @param id id of the region to retrieve.
* @param customHeaders
* @returns the region with the given id * @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}` const path = `/admin/regions/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description lists regions matching a query * @description lists regions matching a query
* @param query query for searching regions * @param query query for searching regions
* @param customHeaders
* @returns a list of regions matching the query. * @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` let path = `/admin/regions`
if (query) { if (query) {
@@ -73,128 +79,145 @@ class AdminRegionsResource extends BaseResource {
path = `/admin/regions?${queryString}` path = `/admin/regions?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description adds metadata to a region * @description adds metadata to a region
* @param id region id * @param id region id
* @param payload metadata * @param payload metadata
* @param customHeaders
* @returns updated region * @returns updated region
*/ */
setMetadata( setMetadata(
id: string, id: string,
payload: AdminPostRegionsRegionMetadata payload: AdminPostRegionsRegionMetadata,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> { ): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/metadata` 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 * @description delete a region's metadata key value pair
* @param id region id * @param id region id
* @param key metadata key * @param key metadata key
* @param customHeaders
* @returns updated region * @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}` 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 * @description adds a country to the list of countries in a region
* @param id region id * @param id region id
* @param payload country data * @param payload country data
* @param customHeaders
* @returns updated region * @returns updated region
*/ */
addCountry( addCountry(
id: string, id: string,
payload: AdminPostRegionsRegionCountriesReq payload: AdminPostRegionsRegionCountriesReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> { ): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/countries` 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 * @description remove a country from a region's list of coutnries
* @param id region id * @param id region id
* @param country_code the 2 character ISO code for the Country. * @param country_code the 2 character ISO code for the Country.
* @param customHeaders
* @returns updated region * @returns updated region
*/ */
deleteCountry( deleteCountry(
id: string, id: string,
country_code: string country_code: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> { ): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/countries/${country_code}` 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 * @description adds a fulfillment provider to a region
* @param id region id * @param id region id
* @param payload fulfillment provider data * @param payload fulfillment provider data
* @param customHeaders
* @returns updated region * @returns updated region
*/ */
addFulfillmentProvider( addFulfillmentProvider(
id: string, id: string,
payload: AdminPostRegionsRegionFulfillmentProvidersReq payload: AdminPostRegionsRegionFulfillmentProvidersReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> { ): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/fulfillment-providers` 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 * @description remove a fulfillment provider from a region
* @param id region id * @param id region id
* @param provider_id the if of the fulfillment provider * @param provider_id the if of the fulfillment provider
* @param customHeaders
* @returns updated region * @returns updated region
*/ */
deleteFulfillmentProvider( deleteFulfillmentProvider(
id: string, id: string,
provider_id: string provider_id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> { ): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/fulfillment-providers/${provider_id}` 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 * @description retrieves the list of fulfillment options available in a region
* @param id region id * @param id region id
* @param customHeaders
* @returns list of fulfillment options * @returns list of fulfillment options
*/ */
retrieveFulfillmentOptions( retrieveFulfillmentOptions(
id: string id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminGetRegionsRegionFulfillmentOptionsRes> { ): ResponsePromise<AdminGetRegionsRegionFulfillmentOptionsRes> {
const path = `/admin/regions/${id}/fulfillment-options` 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 * @description adds a payment provider to a region
* @param id region id * @param id region id
* @param payload payment provider data * @param payload payment provider data
* @param customHeaders
* @returns updated region * @returns updated region
*/ */
addPaymentProvider( addPaymentProvider(
id: string, id: string,
payload: AdminPostRegionsRegionPaymentProvidersReq payload: AdminPostRegionsRegionPaymentProvidersReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> { ): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/payment-providers` 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 * @description removes a payment provider from a region
* @param id region id * @param id region id
* @param provider_id the id of the payment provider * @param provider_id the id of the payment provider
* @param customHeaders
* @returns updated region * @returns updated region
*/ */
deletePaymentProvider( deletePaymentProvider(
id: string, id: string,
provider_id: string provider_id: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminRegionsRes> { ): ResponsePromise<AdminRegionsRes> {
const path = `/admin/regions/${id}/payment-providers/${provider_id}` const path = `/admin/regions/${id}/payment-providers/${provider_id}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
} }
@@ -12,58 +12,64 @@ class AdminReturnReasonsResource extends BaseResource {
/** /**
* @description Creates a return reason. * @description Creates a return reason.
* @param payload * @param payload
* @param customHeaders
* @returns Created return reason. * @returns Created return reason.
*/ */
create( create(
payload: AdminPostReturnReasonsReq payload: AdminPostReturnReasonsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminReturnReasonsRes> { ): ResponsePromise<AdminReturnReasonsRes> {
const path = `/admin/return-reasons` 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 * @description Updates a return reason
* @param id id of the return reason to update. * @param id id of the return reason to update.
* @param payload update to apply to return reason. * @param payload update to apply to return reason.
* @param customHeaders
* @returns the updated return reason. * @returns the updated return reason.
*/ */
update( update(
id: string, id: string,
payload: AdminPostReturnReasonsReasonReq payload: AdminPostReturnReasonsReasonReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminReturnReasonsRes> { ): ResponsePromise<AdminReturnReasonsRes> {
const path = `/admin/return-reasons/${id}` 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 * @description deletes a return reason
* @param id id of return reason to delete. * @param id id of return reason to delete.
* @param customHeaders
* @returns Deleted response * @returns Deleted response
*/ */
delete(id: string): ResponsePromise<AdminReturnReasonsDeleteRes> { delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminReturnReasonsDeleteRes> {
const path = `/admin/return-reasons/${id}` const path = `/admin/return-reasons/${id}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
/** /**
* @description retrieves a return reason * @description retrieves a return reason
* @param id id of the return reason to retrieve. * @param id id of the return reason to retrieve.
* @param customHeaders
* @returns the return reason with the given id * @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}` 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 * @description Lists return reasons matching a query
* @param query Query for searching return reasons
* @returns a list of return reasons matching the query. * @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` const path = `/admin/return-reasons`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -13,33 +13,37 @@ class AdminReturnsResource extends BaseResource {
/** /**
* @description cancels a return * @description cancels a return
* @param id id of return to cancel * @param id id of return to cancel
* @param customHeaders
* @returns the order for which the return was canceled * @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` const path = `/admin/returns/${id}/cancel`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
/** /**
* @description receive a return * @description receive a return
* @param id id of the return to receive. * @param id id of the return to receive.
* @param payload items to receive and an optional refund amount * @param payload items to receive and an optional refund amount
* @param customHeaders
* @returns the return * @returns the return
*/ */
receive( receive(
id: string, id: string,
payload: AdminPostReturnsReturnReceiveReq payload: AdminPostReturnsReturnReceiveReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminReturnsRes> { ): ResponsePromise<AdminReturnsRes> {
const path = `/admin/returns/${id}/receive` 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 * @description lists returns matching a query
* @param query query for searching returns * @param query query for searching returns
* @param customHeaders
* @returns a list of returns matching the query * @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/` let path = `/admin/returns/`
if (query) { if (query) {
@@ -47,7 +51,7 @@ class AdminReturnsResource extends BaseResource {
path = `/admin/returns?${queryString}` path = `/admin/returns?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -14,56 +14,64 @@ class AdminShippingOptionsResource extends BaseResource {
/** /**
* @description creates a shipping option. * @description creates a shipping option.
* @param payload * @param payload
* @param customHeaders
* @returns created shipping option. * @returns created shipping option.
*/ */
create( create(
payload: AdminPostShippingOptionsReq payload: AdminPostShippingOptionsReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminShippingOptionsRes> { ): ResponsePromise<AdminShippingOptionsRes> {
const path = `/admin/shipping-options` 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 * @description updates a shipping option
* @param id id of the shipping option to update. * @param id id of the shipping option to update.
* @param payload update to apply to shipping option. * @param payload update to apply to shipping option.
* @param customHeaders
* @returns the updated shipping option. * @returns the updated shipping option.
*/ */
update( update(
id: string, id: string,
payload: AdminPostShippingOptionsOptionReq payload: AdminPostShippingOptionsOptionReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminShippingOptionsRes> { ): ResponsePromise<AdminShippingOptionsRes> {
const path = `/admin/shipping-options/${id}` 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 * @description deletes a shipping option
* @param id id of shipping option to delete. * @param id id of shipping option to delete.
* @param customHeaders
* @returns deleted response * @returns deleted response
*/ */
delete(id: string): ResponsePromise<AdminShippingOptionsDeleteRes> { delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingOptionsDeleteRes> {
const path = `/admin/shipping-options/${id}` const path = `/admin/shipping-options/${id}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
/** /**
* @description get a shipping option * @description get a shipping option
* @param id id of the shipping option to retrieve. * @param id id of the shipping option to retrieve.
* @param customHeaders
* @returns the shipping option with the given id * @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}` 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 * @description lists shipping options matching a query
* @param query query for searching shipping options * @param query query for searching shipping options
* @param customHeaders
* @returns a list of shipping options matching the query. * @returns a list of shipping options matching the query.
*/ */
list( list(
query?: AdminGetShippingOptionsParams query?: AdminGetShippingOptionsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminShippingOptionsListRes> { ): ResponsePromise<AdminShippingOptionsListRes> {
let path = `/admin/shipping-options` let path = `/admin/shipping-options`
@@ -72,7 +80,7 @@ class AdminShippingOptionsResource extends BaseResource {
path = `/admin/shipping-options?${queryString}` path = `/admin/shipping-options?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -10,33 +10,33 @@ import BaseResource from "../base"
class AdminShippingProfilesResource extends BaseResource { class AdminShippingProfilesResource extends BaseResource {
create( create(
payload: AdminPostShippingProfilesReq payload: AdminPostShippingProfilesReq,
): ResponsePromise<AdminShippingProfilesRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingProfilesRes> {
const path = `/admin/shipping-profiles/` const path = `/admin/shipping-profiles/`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
update( update(
id: string, id: string,
payload: AdminPostShippingProfilesProfileReq payload: AdminPostShippingProfilesProfileReq,
): ResponsePromise<AdminShippingProfilesRes> { customHeaders: Record<string, any> = {}): ResponsePromise<AdminShippingProfilesRes> {
const path = `/admin/shipping-profiles/${id}` 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}` 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}` 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/` const path = `/admin/shipping-profiles/`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+13 -10
View File
@@ -10,49 +10,52 @@ class AdminStoresResource extends BaseResource {
/** /**
* @description Updates the store * @description Updates the store
* @param payload update to apply to the store. * @param payload update to apply to the store.
* @param customHeaders
* @returns the updated store. * @returns the updated store.
*/ */
update(payload: AdminPostStoreReq): ResponsePromise<AdminStoresRes> { update(payload: AdminPostStoreReq, customHeaders: Record<string, any> = {}): ResponsePromise<AdminStoresRes> {
const path = `/admin/store/` 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. * @description adds a currency to the store.
* @param currency_code code of the currency to add * @param currency_code code of the currency to add
* @param customHeaders
* @returns updated store. * @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}` 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 * @description deletes a currency from the available store currencies
* @param currency_code currency code of the currency to delete from the store. * @param currency_code currency code of the currency to delete from the store.
* @param customHeaders
* @returns updated store * @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}` 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 * @description gets a medusa store
* @returns a medusa store * @returns a medusa store
*/ */
retrieve(): ResponsePromise<AdminStoresRes> { retrieve(customHeaders: Record<string, any> = {}): ResponsePromise<AdminStoresRes> {
const path = `/admin/store/` const path = `/admin/store/`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Lists the store's payment providers * @description Lists the store's payment providers
* @returns a list of payment providers configured on the store * @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` const path = `/admin/store/payment-providers`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -8,12 +8,12 @@ import { ResponsePromise } from "../../typings"
import BaseResource from "../base" import BaseResource from "../base"
class AdminSwapsResource extends BaseResource { class AdminSwapsResource extends BaseResource {
retrieve(id: string): ResponsePromise<AdminSwapsRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminSwapsRes> {
const path = `/admin/swaps/${id}` 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/` let path = `/admin/swaps/`
if (query) { if (query) {
@@ -21,7 +21,7 @@ class AdminSwapsResource extends BaseResource {
path = `/admin/swaps?${queryString}` path = `/admin/swaps?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+23 -14
View File
@@ -16,78 +16,87 @@ class AdminUsersResource extends BaseResource {
/** /**
* @description resets password by re-sending password token. * @description resets password by re-sending password token.
* @param payload payload for generating reset-password token. * @param payload payload for generating reset-password token.
* @param customHeaders
* @returns * @returns
*/ */
sendResetPasswordToken( sendResetPasswordToken(
payload: AdminResetPasswordTokenRequest payload: AdminResetPasswordTokenRequest,
customHeaders: Record<string, any> = {}
): ResponsePromise<void> { ): ResponsePromise<void> {
const path = `/admin/users/password-token` 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. * @description resets the users password given the correct token.
* @param payload reset password information. * @param payload reset password information.
* @param customHeaders
* @returns * @returns
*/ */
resetPassword( resetPassword(
payload: AdminResetPasswordRequest payload: AdminResetPasswordRequest,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminUserRes> { ): ResponsePromise<AdminUserRes> {
const path = `admin/users/reset-password` 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 * Retrieves a given user
* @param id id of the user * @param id id of the user
* @param customHeaders
* @returns the user * @returns the user
*/ */
retrieve(id: string): ResponsePromise<AdminUserRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminUserRes> {
const path = `/admin/users/${id}` 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 * @description creates a user with the provided information
* @param payload user creation request body * @param payload user creation request body
* @param customHeaders
* @returns created user * @returns created user
*/ */
create(payload: AdminCreateUserPayload): ResponsePromise<AdminUserRes> { create(payload: AdminCreateUserPayload, customHeaders: Record<string, any> = {}): ResponsePromise<AdminUserRes> {
const path = `/admin/users` const path = `/admin/users`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* @description updates a given user * @description updates a given user
* @param id id of the user to update * @param id id of the user to update
* @param payload user update request body * @param payload user update request body
* @param customHeaders
* @returns the updated user * @returns the updated user
*/ */
update( update(
id: string, id: string,
payload: AdminUpdateUserPayload payload: AdminUpdateUserPayload,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminUserRes> { ): ResponsePromise<AdminUserRes> {
const path = `/admin/users/${id}` const path = `/admin/users/${id}`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* @description deletes a user * @description deletes a user
* @param id id of the user to be deleted * @param id id of the user to be deleted
* @param customHeaders
* @returns delete response * @returns delete response
*/ */
delete(id: string): ResponsePromise<AdminDeleteUserRes> { delete(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<AdminDeleteUserRes> {
const path = `/admin/users/${id}` const path = `/admin/users/${id}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
/** /**
* @description lists all users * @description lists all users
* @returns a list of all users * @returns a list of all users
*/ */
list(): ResponsePromise<AdminUsersListRes> { list(customHeaders: Record<string, any> = {}): ResponsePromise<AdminUsersListRes> {
const path = `/admin/users` const path = `/admin/users`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -4,7 +4,7 @@ import { ResponsePromise } from "../.."
import BaseResource from "../base" import BaseResource from "../base"
class AdminVariantsResource extends BaseResource { class AdminVariantsResource extends BaseResource {
list(query?: AdminGetVariantsParams): ResponsePromise<AdminVariantsListRes> { list(query?: AdminGetVariantsParams, customHeaders: Record<string, any> = {}): ResponsePromise<AdminVariantsListRes> {
let path = `/admin/variants` let path = `/admin/variants`
if (query) { if (query) {
@@ -12,7 +12,7 @@ class AdminVariantsResource extends BaseResource {
path = `/admin/variants?${queryString}` path = `/admin/variants?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+9 -6
View File
@@ -10,31 +10,34 @@ class AuthResource extends BaseResource {
/** /**
* @description Authenticates a customer using email and password combination * @description Authenticates a customer using email and password combination
* @param {StorePostAuthReq} payload authentication payload * @param {StorePostAuthReq} payload authentication payload
* @param customHeaders
* @return {ResponsePromise<StoreAuthRes>} * @return {ResponsePromise<StoreAuthRes>}
*/ */
authenticate(payload: StorePostAuthReq): ResponsePromise<StoreAuthRes> { authenticate(payload: StorePostAuthReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreAuthRes> {
const path = `/store/auth` const path = `/store/auth`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* @description Retrieves an authenticated session * @description Retrieves an authenticated session
* Usually used to check if authenticated session is alive. * Usually used to check if authenticated session is alive.
* @param customHeaders
* @return {ResponsePromise<StoreAuthRes>} * @return {ResponsePromise<StoreAuthRes>}
*/ */
getSession(): ResponsePromise<StoreAuthRes> { getSession(customHeaders: Record<string, any> = {}): ResponsePromise<StoreAuthRes> {
const path = `/store/auth` const path = `/store/auth`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Check if email exists * @description Check if email exists
* @param {string} email is required * @param {string} email is required
* @param customHeaders
* @return {ResponsePromise<StoreGetAuthEmailRes>} * @return {ResponsePromise<StoreGetAuthEmailRes>}
*/ */
exists(email: string): ResponsePromise<StoreGetAuthEmailRes> { exists(email: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreGetAuthEmailRes> {
const path = `/store/auth/${email}` const path = `/store/auth/${email}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+40 -29
View File
@@ -18,14 +18,15 @@ class CartsResource extends BaseResource {
* Adds a shipping method to cart * Adds a shipping method to cart
* @param {string} cart_id Id of cart * @param {string} cart_id Id of cart
* @param {StorePostCartsCartShippingMethodReq} payload Containg id of shipping option and optional data * @param {StorePostCartsCartShippingMethodReq} payload Containg id of shipping option and optional data
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
addShippingMethod( addShippingMethod(
cart_id: string, cart_id: string,
payload: StorePostCartsCartShippingMethodReq payload: StorePostCartsCartShippingMethodReq,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/shipping-methods` 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. * 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. * If not provuided, we will generate one for the request.
* @param {string} cart_id is required * @param {string} cart_id is required
* @param customHeaders
* @return {ResponsePromise<StoreCompleteCartRes>} * @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` const path = `/store/carts/${cart_id}/complete`
return this.client.request("POST", path) return this.client.request("POST", path, {}, {}, customHeaders)
} }
/** /**
* Creates a cart * Creates a cart
* @param {StorePostCartReq} payload is optional and can contain a region_id and items. * @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 * The cart will contain the payload, if provided. Otherwise it will be empty
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
create(payload?: StorePostCartReq): ResponsePromise<StoreCartsRes> { create(payload?: StorePostCartReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts` 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. * 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. * This is usually called when a customer proceeds to checkout.
* @param {string} cart_id is required * @param {string} cart_id is required
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @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` 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. * Removes a discount from cart.
* @param {string} cart_id is required * @param {string} cart_id is required
* @param {string} code discount code to remove * @param {string} code discount code to remove
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
deleteDiscount( deleteDiscount(
cart_id: string, cart_id: string,
code: string code: string,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/discounts/${code}` 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 * Can be useful in case a payment has failed
* @param {string} cart_id is required * @param {string} cart_id is required
* @param {string} provider_id the provider id of the session e.g. "stripe" * @param {string} provider_id the provider id of the session e.g. "stripe"
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
deletePaymentSession( deletePaymentSession(
cart_id: string, cart_id: string,
provider_id: string provider_id: string,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-sessions/${provider_id}` 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. * Refreshes a payment session.
* @param {string} cart_id is required * @param {string} cart_id is required
* @param {string} provider_id the provider id of the session e.g. "stripe" * @param {string} provider_id the provider id of the session e.g. "stripe"
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
refreshPaymentSession( refreshPaymentSession(
cart_id: string, cart_id: string,
provider_id: string provider_id: string,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-sessions/${provider_id}/refresh` 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 * Retrieves a cart
* @param {string} cart_id is required * @param {string} cart_id is required
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @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}` const path = `/store/carts/${cart_id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* Refreshes a payment session. * Refreshes a payment session.
* @param {string} cart_id is required * @param {string} cart_id is required
* @param {StorePostCartsCartPaymentSessionReq} payload the provider id of the session e.g. "stripe" * @param {StorePostCartsCartPaymentSessionReq} payload the provider id of the session e.g. "stripe"
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
setPaymentSession( setPaymentSession(
cart_id: string, cart_id: string,
payload: StorePostCartsCartPaymentSessionReq payload: StorePostCartsCartPaymentSessionReq,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-session` 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 * Updates a cart
* @param {string} cart_id is required * @param {string} cart_id is required
* @param {StorePostCartsCartReq} payload is required and can contain region_id, email, billing and shipping address * @param {StorePostCartsCartReq} payload is required and can contain region_id, email, billing and shipping address
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
update( update(
cart_id: string, cart_id: string,
payload: StorePostCartsCartReq payload: StorePostCartsCartReq,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}` 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} cart_id is required
* @param {string} provider_id is required * @param {string} provider_id is required
* @param {StorePostCartsCartPaymentSessionUpdateReq} payload is required * @param {StorePostCartsCartPaymentSessionUpdateReq} payload is required
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
updatePaymentSession( updatePaymentSession(
cart_id: string, cart_id: string,
provider_id: string, provider_id: string,
payload: StorePostCartsCartPaymentSessionUpdateReq payload: StorePostCartsCartPaymentSessionUpdateReq,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/payment-sessions/${provider_id}` 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)
} }
} }
@@ -11,21 +11,23 @@ class CollectionsResource extends BaseResource {
/** /**
* @description Retrieves a single collection * @description Retrieves a single collection
* @param {string} id id of the collection * @param {string} id id of the collection
* @param customHeaders
* @return {ResponsePromise<StoreCollectionsRes>} * @return {ResponsePromise<StoreCollectionsRes>}
*/ */
retrieve(id: string): ResponsePromise<StoreCollectionsRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCollectionsRes> {
const path = `/store/collections/${id}` const path = `/store/collections/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Retrieves a list of collections * @description Retrieves a list of collections
* @param {string} query is optional. Can contain a limit and offset for the returned list * @param {string} query is optional. Can contain a limit and offset for the returned list
* @param customHeaders
* @return {ResponsePromise<StoreCollectionsListRes>} * @return {ResponsePromise<StoreCollectionsListRes>}
*/ */
list( list(
query?: StoreGetCollectionsParams query?: StoreGetCollectionsParams,
): ResponsePromise<StoreCollectionsListRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCollectionsListRes> {
let path = `/store/collections` let path = `/store/collections`
if (query) { if (query) {
@@ -33,7 +35,7 @@ class CollectionsResource extends BaseResource {
path = `/store/collections?${queryString}` path = `/store/collections?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+22 -15
View File
@@ -19,42 +19,46 @@ class CustomerResource extends BaseResource {
/** /**
* Creates a customer * Creates a customer
* @param {StorePostCustomersReq} payload information of customer * @param {StorePostCustomersReq} payload information of customer
* @param customHeaders
* @return { ResponsePromise<StoreCustomersRes>} * @return { ResponsePromise<StoreCustomersRes>}
*/ */
create(payload: StorePostCustomersReq): ResponsePromise<StoreCustomersRes> { create(payload: StorePostCustomersReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers` 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 * Retrieves the customer that is currently logged
* @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>} * @return {ResponsePromise<StoreCustomersRes>}
*/ */
retrieve(): ResponsePromise<StoreCustomersRes> { retrieve(customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me` const path = `/store/customers/me`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* Updates a customer * Updates a customer
* @param {StorePostCustomersCustomerReq} payload information to update customer with * @param {StorePostCustomersCustomerReq} payload information to update customer with
* @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>} * @return {ResponsePromise<StoreCustomersRes>}
*/ */
update( update(
payload: StorePostCustomersCustomerReq payload: StorePostCustomersCustomerReq,
): ResponsePromise<StoreCustomersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/me` const path = `/store/customers/me`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
/** /**
* Retrieve customer orders * Retrieve customer orders
* @param {StoreGetCustomersCustomerOrdersParams} params optional params to retrieve orders * @param {StoreGetCustomersCustomerOrdersParams} params optional params to retrieve orders
* @param customHeaders
* @return {ResponsePromise<StoreCustomersListOrdersRes>} * @return {ResponsePromise<StoreCustomersListOrdersRes>}
*/ */
listOrders( listOrders(
params?: StoreGetCustomersCustomerOrdersParams params?: StoreGetCustomersCustomerOrdersParams,
): ResponsePromise<StoreCustomersListOrdersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersListOrdersRes> {
let path = `/store/customers/me/orders` let path = `/store/customers/me/orders`
if (params) { if (params) {
const query = qs.stringify(params) const query = qs.stringify(params)
@@ -62,32 +66,35 @@ class CustomerResource extends BaseResource {
path += `?${query}` path += `?${query}`
} }
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* Resets customer password * Resets customer password
* @param {StorePostCustomersCustomerPasswordTokenReq} payload info used to reset customer password * @param {StorePostCustomersCustomerPasswordTokenReq} payload info used to reset customer password
* @param customHeaders
* @return {ResponsePromise<StoreCustomersRes>} * @return {ResponsePromise<StoreCustomersRes>}
*/ */
resetPassword( resetPassword(
payload: StorePostCustomersCustomerPasswordTokenReq payload: StorePostCustomersCustomerPasswordTokenReq,
): ResponsePromise<StoreCustomersRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersRes> {
const path = `/store/customers/password-reset` 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. * 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. * 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 {StorePostCustomersCustomerPasswordTokenReq} payload info used to generate token
* @param customHeaders
* @return {ResponsePromise} * @return {ResponsePromise}
*/ */
generatePasswordToken( generatePasswordToken(
payload: StorePostCustomersCustomerPasswordTokenReq payload: StorePostCustomersCustomerPasswordTokenReq,
customHeaders: Record<string, any> = {}
): ResponsePromise { ): ResponsePromise {
const path = `/store/customers/password-token` const path = `/store/customers/password-token`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
} }
@@ -6,11 +6,12 @@ class GiftCardsResource extends BaseResource {
/** /**
* @description Retrieves a single GiftCard * @description Retrieves a single GiftCard
* @param {string} code code of the gift card * @param {string} code code of the gift card
* @param customHeaders
* @return {ResponsePromise<StoreGiftCardsRes>} * @return {ResponsePromise<StoreGiftCardsRes>}
*/ */
retrieve(code: string): ResponsePromise<StoreGiftCardsRes> { retrieve(code: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreGiftCardsRes> {
const path = `/store/gift-cards/${code}` const path = `/store/gift-cards/${code}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+12 -9
View File
@@ -11,14 +11,15 @@ class LineItemsResource extends BaseResource {
* Creates a line-item for a cart * Creates a line-item for a cart
* @param {string} cart_id id of cart * @param {string} cart_id id of cart
* @param {StorePostCartsCartLineItemsReq} payload details needed to create a line-item * @param {StorePostCartsCartLineItemsReq} payload details needed to create a line-item
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
create( create(
cart_id: string, cart_id: string,
payload: StorePostCartsCartLineItemsReq payload: StorePostCartsCartLineItemsReq,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/line-items` 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} cart_id id of cart
* @param {string} line_id id of item to update * @param {string} line_id id of item to update
* @param {StorePostCartsCartLineItemsItemReq} payload details needed to update a line-item * @param {StorePostCartsCartLineItemsItemReq} payload details needed to update a line-item
* @param customHeaders
* @return {ResponsePromise<StoreCartsRes>} * @return {ResponsePromise<StoreCartsRes>}
*/ */
update( update(
cart_id: string, cart_id: string,
line_id: string, line_id: string,
payload: StorePostCartsCartLineItemsItemReq payload: StorePostCartsCartLineItemsItemReq,
): ResponsePromise<StoreCartsRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreCartsRes> {
const path = `/store/carts/${cart_id}/line-items/${line_id}` 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 * Remove a line-item from a cart
* @param {string} cart_id id of cart * @param {string} cart_id id of cart
* @param {string} line_id id of item to remove * @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}` const path = `/store/carts/${cart_id}/line-items/${line_id}`
return this.client.request("DELETE", path) return this.client.request("DELETE", path, {}, {}, customHeaders)
} }
} }
+9 -6
View File
@@ -7,35 +7,38 @@ class OrdersResource extends BaseResource {
/** /**
* @description Retrieves an order * @description Retrieves an order
* @param {string} id is required * @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreOrdersRes>} * @return {ResponsePromise<StoreOrdersRes>}
*/ */
retrieve(id: string): ResponsePromise<StoreOrdersRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreOrdersRes> {
const path = `/store/orders/${id}` 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 * @description Retrieves an order by cart id
* @param {string} cart_id is required * @param {string} cart_id is required
* @param customHeaders
* @return {ResponsePromise<StoreOrdersRes>} * @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}` 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 * @description Look up an order using order details
* @param {StoreGetOrdersParams} payload details used to look up the order * @param {StoreGetOrdersParams} payload details used to look up the order
* @param customHeaders
* @return {ResponsePromise<StoreOrdersRes>} * @return {ResponsePromise<StoreOrdersRes>}
*/ */
lookupOrder(payload: StoreGetOrdersParams): ResponsePromise<StoreOrdersRes> { lookupOrder(payload: StoreGetOrdersParams, customHeaders: Record<string, any> = {}): ResponsePromise<StoreOrdersRes> {
let path = `/store/orders?` let path = `/store/orders?`
const queryString = qs.stringify(payload) const queryString = qs.stringify(payload)
path = `/store/orders?${queryString}` path = `/store/orders?${queryString}`
return this.client.request("GET", path, payload) return this.client.request("GET", path, payload, {}, customHeaders)
} }
} }
@@ -6,11 +6,12 @@ class PaymentMethodsResource extends BaseResource {
/** /**
* Lists customer payment methods * Lists customer payment methods
* @param {string} id id of cart * @param {string} id id of cart
* @param customHeaders
* @return {StoreCustomersListPaymentMethodsRes} * @return {StoreCustomersListPaymentMethodsRes}
*/ */
list(id: string): ResponsePromise<StoreCustomersListPaymentMethodsRes> { list(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreCustomersListPaymentMethodsRes> {
const path = `/store/carts/${id}/payment-methods` const path = `/store/carts/${id}/payment-methods`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -11,26 +11,28 @@ class ProductVariantsResource extends BaseResource {
/** /**
* @description Retrieves a single product variant * @description Retrieves a single product variant
* @param {string} id is required * @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreVariantsRes>} * @return {ResponsePromise<StoreVariantsRes>}
*/ */
retrieve(id: string): ResponsePromise<StoreVariantsRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreVariantsRes> {
const path = `/store/variants/${id}` 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 * @description Retrieves a list of of Product Variants
* @param {StoreVariantsListParamsObject} query * @param {StoreGetVariantsParams} query
* @param customHeaders
* @return {ResponsePromise<StoreVariantsListRes>} * @return {ResponsePromise<StoreVariantsListRes>}
*/ */
list(query?: StoreGetVariantsParams): ResponsePromise<StoreVariantsListRes> { list(query?: StoreGetVariantsParams, customHeaders: Record<string, any> = {}): ResponsePromise<StoreVariantsListRes> {
let path = `/store/variants` let path = `/store/variants`
if (query) { if (query) {
const queryString = qs.stringify(query) const queryString = qs.stringify(query)
path += `?${queryString}` path += `?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, undefined, {}, customHeaders)
} }
} }
+10 -6
View File
@@ -16,31 +16,35 @@ class ProductsResource extends BaseResource {
/** /**
* @description Retrieves a single Product * @description Retrieves a single Product
* @param {string} id is required * @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreProductsRes>} * @return {ResponsePromise<StoreProductsRes>}
*/ */
retrieve(id: string): ResponsePromise<StoreProductsRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreProductsRes> {
const path = `/store/products/${id}` const path = `/store/products/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Searches for products * @description Searches for products
* @param {StorePostSearchReq} searchOptions is required * @param {StorePostSearchReq} searchOptions is required
* @param customHeaders
* @return {ResponsePromise<StorePostSearchRes>} * @return {ResponsePromise<StorePostSearchRes>}
*/ */
search( search(
searchOptions: StorePostSearchReq searchOptions: StorePostSearchReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<StorePostSearchRes> { ): ResponsePromise<StorePostSearchRes> {
const path = `/store/products/search` 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 * @description Retrieves a list of products
* @param {StoreGetProductsParams} query is optional. Can contain a limit and offset for the returned list * @param {StoreGetProductsParams} query is optional. Can contain a limit and offset for the returned list
* @param customHeaders
* @return {ResponsePromise<StoreProductsListRes>} * @return {ResponsePromise<StoreProductsListRes>}
*/ */
list(query?: StoreGetProductsParams): ResponsePromise<StoreProductsListRes> { list(query?: StoreGetProductsParams, customHeaders: Record<string, any> = {}): ResponsePromise<StoreProductsListRes> {
let path = `/store/products` let path = `/store/products`
if (query) { if (query) {
@@ -48,7 +52,7 @@ class ProductsResource extends BaseResource {
path = `/store/products?${queryString}` path = `/store/products?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+6 -4
View File
@@ -5,21 +5,23 @@ import BaseResource from "./base"
class RegionsResource extends BaseResource { class RegionsResource extends BaseResource {
/** /**
* @description Retrieves a list of regions * @description Retrieves a list of regions
* @param customHeaders
* @return {ResponsePromise<StoreRegionsListRes>} * @return {ResponsePromise<StoreRegionsListRes>}
*/ */
list(): ResponsePromise<StoreRegionsListRes> { list(customHeaders: Record<string, any> = {}): ResponsePromise<StoreRegionsListRes> {
const path = `/store/regions` const path = `/store/regions`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
/** /**
* @description Retrieves a region * @description Retrieves a region
* @param {string} id is required * @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreRegionsRes>} * @return {ResponsePromise<StoreRegionsRes>}
*/ */
retrieve(id: string): ResponsePromise<StoreRegionsRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreRegionsRes> {
const path = `/store/regions/${id}` const path = `/store/regions/${id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -9,20 +9,22 @@ class ReturnReasonsResource extends BaseResource {
/** /**
* @description Retrieves a single Return Reason * @description Retrieves a single Return Reason
* @param {string} id is required * @param {string} id is required
* @param customHeaders
* @return {ResponsePromise<StoreReturnReasonsRes>} * @return {ResponsePromise<StoreReturnReasonsRes>}
*/ */
retrieve(id: string): ResponsePromise<StoreReturnReasonsRes> { retrieve(id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreReturnReasonsRes> {
const path = `/store/return-reasons/${id}` 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 * Lists return reasons defined in Medusa Admin
* @param customHeaders
* @return {ResponsePromise<StoreReturnReasonsListRes>} * @return {ResponsePromise<StoreReturnReasonsListRes>}
*/ */
list(): ResponsePromise<StoreReturnReasonsListRes> { list(customHeaders: Record<string, any> = {}): ResponsePromise<StoreReturnReasonsListRes> {
const path = `/store/return-reasons` const path = `/store/return-reasons`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+3 -2
View File
@@ -6,11 +6,12 @@ class ReturnsResource extends BaseResource {
/** /**
* Creates a return request * Creates a return request
* @param {StorePostReturnsReq} payload details needed to create a return * @param {StorePostReturnsReq} payload details needed to create a return
* @param customHeaders
* @return {ResponsePromise<StoreReturnsRes>} * @return {ResponsePromise<StoreReturnsRes>}
*/ */
create(payload: StorePostReturnsReq): ResponsePromise<StoreReturnsRes> { create(payload: StorePostReturnsReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreReturnsRes> {
const path = `/store/returns` const path = `/store/returns`
return this.client.request("POST", path, payload) return this.client.request("POST", path, payload, {}, customHeaders)
} }
} }
@@ -10,23 +10,23 @@ class ShippingOptionsResource extends BaseResource {
/** /**
* @description Lists shiping options available for a cart * @description Lists shiping options available for a cart
* @param {string} cart_id * @param {string} cart_id
* @param customHeaders
* @return {ResponsePromise<StoreShippingOptionsListRes>} * @return {ResponsePromise<StoreShippingOptionsListRes>}
*/ */
listCartOptions( listCartOptions(cart_id: string, customHeaders: Record<string, any> = {}): ResponsePromise<StoreShippingOptionsListRes> {
cart_id: string
): ResponsePromise<StoreShippingOptionsListRes> {
const path = `/store/shipping-options/${cart_id}` 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 * @description Lists shiping options available
* @param {StoreGetShippingOptionsParamsObject} query * @param {StoreGetShippingOptionsParams} query
* @param customHeaders
* @return {ResponsePromise<StoreShippingOptionsListRes>} * @return {ResponsePromise<StoreShippingOptionsListRes>}
*/ */
list( list(
query?: StoreGetShippingOptionsParams query?: StoreGetShippingOptionsParams,
): ResponsePromise<StoreShippingOptionsListRes> { customHeaders: Record<string, any> = {}): ResponsePromise<StoreShippingOptionsListRes> {
let path = `/store/shipping-options` let path = `/store/shipping-options`
if (query) { if (query) {
@@ -34,7 +34,7 @@ class ShippingOptionsResource extends BaseResource {
path = `/store/shipping-options?${queryString}` path = `/store/shipping-options?${queryString}`
} }
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
+6 -4
View File
@@ -6,21 +6,23 @@ class SwapsResource extends BaseResource {
/** /**
* @description Creates a swap from a cart * @description Creates a swap from a cart
* @param {StorePostSwapsReq} payload * @param {StorePostSwapsReq} payload
* @param customHeaders
* @return {ResponsePromise<StoreSwapsRes>} * @return {ResponsePromise<StoreSwapsRes>}
*/ */
create(payload: StorePostSwapsReq): ResponsePromise<StoreSwapsRes> { create(payload: StorePostSwapsReq, customHeaders: Record<string, any> = {}): ResponsePromise<StoreSwapsRes> {
const path = `/store/swaps` 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 * @description Retrieves a swap by cart id
* @param {string} cart_id id of cart * @param {string} cart_id id of cart
* @param customHeaders
* @return {ResponsePromise<StoreSwapsRes>} * @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}` const path = `/store/swaps/${cart_id}`
return this.client.request("GET", path) return this.client.request("GET", path, {}, {}, customHeaders)
} }
} }
@@ -189,7 +189,7 @@ export class AdminPostDraftOrdersReq {
@IsObject() @IsObject()
@IsOptional() @IsOptional()
metadata?: object = {} metadata?: Record<string, any> = {}
} }
class ShippingMethod { class ShippingMethod {
@@ -198,7 +198,7 @@ class ShippingMethod {
@IsObject() @IsObject()
@IsOptional() @IsOptional()
data?: object = {} data?: Record<string, any> = {}
@IsNumber() @IsNumber()
@IsOptional() @IsOptional()
@@ -228,5 +228,5 @@ class Item {
@IsObject() @IsObject()
@IsOptional() @IsOptional()
metadata?: object = {} metadata?: Record<string, any> = {}
} }
@@ -134,5 +134,5 @@ export class AdminPostDraftOrdersDraftOrderLineItemsReq {
@IsObject() @IsObject()
@IsOptional() @IsOptional()
metadata?: object = {} metadata?: Record<string, any> = {}
} }
@@ -128,5 +128,5 @@ export class AdminPostDraftOrdersDraftOrderLineItemsItemReq {
@IsObject() @IsObject()
@IsOptional() @IsOptional()
metadata?: object = {} metadata?: Record<string, any> = {}
} }
@@ -70,5 +70,5 @@ export class AdminPostOrdersOrderShippingMethodsReq {
@IsObject() @IsObject()
@IsOptional() @IsOptional()
data?: object = {} data?: Record<string, any> = {}
} }
@@ -67,5 +67,5 @@ export class StorePostCartsCartShippingMethodReq {
option_id: string option_id: string
@IsOptional() @IsOptional()
data?: object = {} data?: Record<string, any> = {}
} }
+2 -2
View File
@@ -1215,7 +1215,7 @@ class CartService extends BaseService {
* this could be IP address or similar for fraud handling. * this could be IP address or similar for fraud handling.
* @return {Promise<Cart>} the resulting cart * @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) => { return this.atomicPhase_(async (manager: EntityManager) => {
const cartRepository = manager.getCustomRepository(this.cartRepository_) const cartRepository = manager.getCustomRepository(this.cartRepository_)
@@ -1520,7 +1520,7 @@ class CartService extends BaseService {
async addShippingMethod( async addShippingMethod(
cartId: string, cartId: string,
optionId: string, optionId: string,
data: object = {} data: Record<string, any> = {}
): Promise<Cart> { ): Promise<Cart> {
return this.atomicPhase_(async (manager: EntityManager) => { return this.atomicPhase_(async (manager: EntityManager) => {
const cart = await this.retrieve(cartId, { const cart = await this.retrieve(cartId, {
@@ -666,7 +666,7 @@ class ProductVariantService extends BaseService {
* @param {Object} metadata - the metadata to set * @param {Object} metadata - the metadata to set
* @return {Object} updated metadata object * @return {Object} updated metadata object
*/ */
setMetadata_(variant: ProductVariant, metadata: object): object { setMetadata_(variant: ProductVariant, metadata: object): Record<string, any> {
const existing = variant.metadata || {} const existing = variant.metadata || {}
const newData = {} const newData = {}
for (const [key, value] of Object.entries(metadata)) { for (const [key, value] of Object.entries(metadata)) {