chore(js-sdk,types): add missing examples for JS SDK methods (#11934)
* chore(js-sdk,types): add TSDocs for calculate method * added tsdocs for promotions * finished adding examples * fixes * remove unused import
This commit is contained in:
@@ -214,6 +214,15 @@ export class Campaign {
|
||||
* @param payload - The promotions to add or remove associations to them.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The campaign's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.campaign.batchPromotions("procamp_123", {
|
||||
* add: ["prom_123", "prom_456"],
|
||||
* remove: ["prom_789"]
|
||||
* })
|
||||
* .then(({ campaign }) => {
|
||||
* console.log(campaign)
|
||||
* })
|
||||
*/
|
||||
async batchPromotions(
|
||||
id: string,
|
||||
|
||||
@@ -77,12 +77,18 @@ export class FulfillmentProvider {
|
||||
|
||||
/**
|
||||
* This method retrieves a list of fulfillment options for a given fulfillment provider. It sends a request to the
|
||||
* [List Fulfillment Options](https://docs.medusajs.com/api/admin#fulfillment-providers_getfulfillmentprovideroptions)
|
||||
* [List Fulfillment Options](https://docs.medusajs.com/api/admin#fulfillment-providers_getfulfillmentprovidersidoptions)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the fulfillment provider.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of fulfillment options.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.fulfillmentProvider.listFulfillmentOptions("fp_123")
|
||||
* .then(({ fulfillment_options }) => {
|
||||
* console.log(fulfillment_options)
|
||||
* })
|
||||
*/
|
||||
async listFulfillmentOptions(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminFulfillmentProviderOptionsListResponse>(
|
||||
|
||||
@@ -14,6 +14,39 @@ export class Promotion {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a promotion by its ID. It sends a request to the
|
||||
* [Retrieve Promotion](https://docs.medusajs.com/api/admin#promotions_getpromotionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The promotion's ID.
|
||||
* @param query - Configure the fields to retrieve in the promotion.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The promotion's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a promotion by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.promotion.retrieve("promo_123")
|
||||
* .then(({ promotion }) => {
|
||||
* console.log(promotion)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.promotion.retrieve("promo_123", {
|
||||
* fields: "id,*application_method"
|
||||
* })
|
||||
* .then(({ promotion }) => {
|
||||
* console.log(promotion)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminGetPromotionParams,
|
||||
@@ -28,6 +61,53 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of promotions. It sends a request to the
|
||||
* [List Promotions](https://docs.medusajs.com/api/admin#promotions_getpromotions)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of promotions.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of promotions:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.promotion.list()
|
||||
* .then(({ promotions, count, limit, offset }) => {
|
||||
* console.log(promotions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.promotion.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ promotions, count, limit, offset }) => {
|
||||
* console.log(promotions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each promotion:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.promotion.list({
|
||||
* fields: "id,*application_method"
|
||||
* })
|
||||
* .then(({ promotions, count, limit, offset }) => {
|
||||
* console.log(promotions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminGetPromotionsParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -41,6 +121,27 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a new promotion. It sends a request to the
|
||||
* [Create Promotion](https://docs.medusajs.com/api/admin#promotions_postpromotions)
|
||||
* API route.
|
||||
*
|
||||
* @param payload - The promotion to create.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The promotion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.create({
|
||||
* name: "My Promotion",
|
||||
* description: "This is a test promotion",
|
||||
* code: "PROMO123",
|
||||
* starts_at: "2021-01-01",
|
||||
* ends_at: "2021-01-01",
|
||||
* })
|
||||
* .then(({ promotion }) => {
|
||||
* console.log(promotion)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
payload: HttpTypes.AdminCreatePromotion,
|
||||
headers?: ClientHeaders
|
||||
@@ -55,6 +156,24 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a promotion. It sends a request to the
|
||||
* [Update Promotion](https://docs.medusajs.com/api/admin#promotions_postpromotionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The promotion's ID.
|
||||
* @param payload - The details to update in the promotion.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The promotion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.update("promo_123", {
|
||||
* code: "PROMO123",
|
||||
* })
|
||||
* .then(({ promotion }) => {
|
||||
* console.log(promotion)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
payload: HttpTypes.AdminUpdatePromotion,
|
||||
@@ -70,6 +189,21 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a promotion. It sends a request to the
|
||||
* [Delete Promotion](https://docs.medusajs.com/api/admin#promotions_deletepromotionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The promotion's ID.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deleted promotion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.delete("promo_123")
|
||||
* .then(({ promotion }) => {
|
||||
* console.log(promotion)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.DeleteResponse<"promotion">>(
|
||||
`/admin/promotions/${id}`,
|
||||
@@ -80,6 +214,38 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates and adds rules to a promotion. It can be the promotion's rules,
|
||||
* or its application method's buy or target rules. That depends on the rule type
|
||||
* you specify as a parameter.
|
||||
*
|
||||
* - If you set the `ruleType` to `rules`, the method sends a request to the
|
||||
* [Manage Promotion's Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidrulesbatch).
|
||||
* - If you set the `ruleType` to `buy-rules`, the method sends a request to the
|
||||
* [Manage Promotion's Buy Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidbuyrulesbatch).
|
||||
* - If you set the `ruleType` to `target-rules`, the method sends a request to the
|
||||
* [Manage Promotion's Target Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidtargetrulesbatch).
|
||||
*
|
||||
* @param id - The promotion's ID.
|
||||
* @param ruleType - The type of rules to create.
|
||||
* @param payload - The rules to create.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The promotion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.addRules("promo_123", "rules", {
|
||||
* rules: [
|
||||
* {
|
||||
* operator: "eq",
|
||||
* attribute: "product_id",
|
||||
* values: ["prod_123"]
|
||||
* }
|
||||
* ]
|
||||
* })
|
||||
* .then(({ promotion }) => {
|
||||
* console.log(promotion)
|
||||
* })
|
||||
*/
|
||||
async addRules(
|
||||
id: string,
|
||||
ruleType: string,
|
||||
@@ -96,6 +262,37 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates the rules of a promotion. It can be the promotion's rules,
|
||||
* or its application method's buy or target rules. That depends on the rule type
|
||||
* you specify as a parameter.
|
||||
*
|
||||
* - If you set the `ruleType` to `rules`, the method sends a request to the
|
||||
* [Manage Promotion's Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidrulesbatch).
|
||||
* - If you set the `ruleType` to `buy-rules`, the method sends a request to the
|
||||
* [Manage Promotion's Buy Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidbuyrulesbatch).
|
||||
* - If you set the `ruleType` to `target-rules`, the method sends a request to the
|
||||
* [Manage Promotion's Target Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidtargetrulesbatch).
|
||||
*
|
||||
* @param id - The promotion's ID.
|
||||
* @param ruleType - The type of rules to update.
|
||||
* @param payload - The rules to update.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The promotion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.updateRules("promo_123", "rules", {
|
||||
* rules: [
|
||||
* {
|
||||
* id: "rule_123",
|
||||
* operator: "ne",
|
||||
* }
|
||||
* ]
|
||||
* })
|
||||
* .then(({ promotion }) => {
|
||||
* console.log(promotion)
|
||||
* })
|
||||
*/
|
||||
async updateRules(
|
||||
id: string,
|
||||
ruleType: string,
|
||||
@@ -112,6 +309,32 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes rules from a promotion. It can be the promotion's rules,
|
||||
* or its application method's buy or target rules. That depends on the rule type
|
||||
* you specify as a parameter.
|
||||
*
|
||||
* - If you set the `ruleType` to `rules`, the method sends a request to the
|
||||
* [Manage Promotion's Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidrulesbatch).
|
||||
* - If you set the `ruleType` to `buy-rules`, the method sends a request to the
|
||||
* [Manage Promotion's Buy Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidbuyrulesbatch).
|
||||
* - If you set the `ruleType` to `target-rules`, the method sends a request to the
|
||||
* [Manage Promotion's Target Rules API Route](https://docs.medusajs.com/api/admin#promotions_postpromotionsidtargetrulesbatch).
|
||||
*
|
||||
* @param id - The promotion's ID.
|
||||
* @param ruleType - The type of rules to remove.
|
||||
* @param payload - The rules to remove.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The promotion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.removeRules("promo_123", "rules", {
|
||||
* rule_ids: ["rule_123"]
|
||||
* })
|
||||
* .then(({ promotion }) => {
|
||||
* console.log(promotion)
|
||||
* })
|
||||
*/
|
||||
async removeRules(
|
||||
id: string,
|
||||
ruleType: string,
|
||||
@@ -128,6 +351,26 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves the rules of a promotion. It can be the promotion's rules,
|
||||
* or its application method's buy or target rules. That depends on the rule type
|
||||
* you specify as a parameter.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [List Rules of a Promotion API Route](https://docs.medusajs.com/api/admin#promotions_getpromotionsidrule_type)
|
||||
*
|
||||
* @param id - The promotion's ID.
|
||||
* @param ruleType - The type of rules to retrieve. Can be `rules`, `buy-rules`, or `target-rules`.
|
||||
* @param query - Configure the fields to retrieve in the rules.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The promotion's rules.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.listRules("promo_123", "rules")
|
||||
* .then(({ rules }) => {
|
||||
* console.log(rules)
|
||||
* })
|
||||
*/
|
||||
async listRules(
|
||||
id: string | null,
|
||||
ruleType: string,
|
||||
@@ -144,6 +387,27 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a list of potential rule attributes for the promotion and application method types specified in the query parameters. Only the attributes of the rule type specified in the path parameter are retrieved:
|
||||
*
|
||||
* - If `rule_type` is `rules`, the attributes of the promotion's type are retrieved.
|
||||
* - If `rule_type` is `target-rules`, the target rules' attributes of the application method's type are retrieved.
|
||||
* - If `rule_type` is `buy-rules`, the buy rules' attributes of the application method's type are retrieved.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [List Rule Attribute Options API Route](https://docs.medusajs.com/api/admin#promotions_getpromotionsruleattributeoptionsrule_type)
|
||||
*
|
||||
* @param ruleType - The type of rules to retrieve the attributes for. Can be `rules`, `buy-rules`, or `target-rules`.
|
||||
* @param promotionType - The type of promotion to retrieve the attributes for. It can be `standard` or `buyget`.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of rule attributes.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.listRuleAttributes("rules", "standard")
|
||||
* .then(({ attributes }) => {
|
||||
* console.log(attributes)
|
||||
* })
|
||||
*/
|
||||
async listRuleAttributes(
|
||||
ruleType: string,
|
||||
promotionType?: string,
|
||||
@@ -159,6 +423,26 @@ export class Promotion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all potential values for promotion rules and target and buy rules based on the specified rule attribute and type.
|
||||
* For example, if you provide the ID of the `currency_code` rule attribute, and set `rule_type` to rules,
|
||||
* a list of currencies are retrieved in label-value pairs.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [List Rule Values API Route](https://docs.medusajs.com/api/admin#promotions_getpromotionsrulevalueoptionsrule_typerule_attribute_id)
|
||||
*
|
||||
* @param ruleType - The type of rules to retrieve the values for. Can be `rules`, `buy-rules`, or `target-rules`.
|
||||
* @param ruleValue - The ID of the rule attribute to retrieve the values for.
|
||||
* @param query - Configure the fields to retrieve in the rule values.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of rule values.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.promotion.listRuleValues("rules", "attr_123")
|
||||
* .then(({ values }) => {
|
||||
* console.log(values)
|
||||
* })
|
||||
*/
|
||||
async listRuleValues(
|
||||
ruleType: string,
|
||||
ruleValue: string,
|
||||
|
||||
@@ -14,6 +14,54 @@ export class RefundReason {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of refund reasons. It sends a request to the
|
||||
* [List Refund Reasons](https://docs.medusajs.com/api/admin#refund-reasons_getrefundreasons)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The paginated list of refund reasons.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of refund reasons:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.refundReason.list()
|
||||
* .then(({ refund_reasons, count, limit, offset }) => {
|
||||
* console.log(refund_reasons)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.refundReason.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ refund_reasons, count, limit, offset }) => {
|
||||
* console.log(refund_reasons)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each refund reason:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.refundReason.list({
|
||||
* fields: "id,name"
|
||||
* })
|
||||
* .then(({ refund_reasons, count, limit, offset }) => {
|
||||
* console.log(refund_reasons)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*
|
||||
*/
|
||||
async list(query?: HttpTypes.RefundReasonFilters, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.RefundReasonsResponse>(
|
||||
`/admin/refund-reasons`,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
FindParams,
|
||||
HttpTypes,
|
||||
PaginatedResponse,
|
||||
SelectParams,
|
||||
} from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
@@ -19,12 +18,31 @@ export class Region {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a new region. It sends a request to the
|
||||
* [Create Region](https://docs.medusajs.com/api/admin#regions_postregions)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the region to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the region.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The created region's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.region.create({
|
||||
* name: "United States",
|
||||
* currency_code: "usd",
|
||||
* })
|
||||
* .then(({ region }) => {
|
||||
* console.log(region)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateRegion,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<{ region: HttpTypes.AdminRegion }>(
|
||||
return await this.client.fetch<HttpTypes.AdminRegionResponse>(
|
||||
`/admin/regions`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -35,13 +53,32 @@ export class Region {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a region. It sends a request to the
|
||||
* [Update Region](https://docs.medusajs.com/api/admin#regions_postregionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the region to update.
|
||||
* @param body - The details of the region to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the region.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The updated region's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.region.update("region_123", {
|
||||
* name: "United States",
|
||||
* })
|
||||
* .then(({ region }) => {
|
||||
* console.log(region)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateRegion,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<{ region: HttpTypes.AdminRegion }>(
|
||||
return await this.client.fetch<HttpTypes.AdminRegionResponse>(
|
||||
`/admin/regions/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -52,20 +89,101 @@ export class Region {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of regions. It sends a request to the
|
||||
* [List Regions](https://docs.medusajs.com/api/admin#regions_getregions)
|
||||
* API route.
|
||||
*
|
||||
* @param queryParams - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The paginated list of regions.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of regions:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.region.list()
|
||||
* .then(({ regions, count, limit, offset }) => {
|
||||
* console.log(regions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.region.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ regions, count, limit, offset }) => {
|
||||
* console.log(regions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each region:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.region.list({
|
||||
* fields: "id,*countries"
|
||||
* })
|
||||
* .then(({ regions, count, limit, offset }) => {
|
||||
* console.log(regions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
queryParams?: FindParams & HttpTypes.AdminRegionFilters,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<
|
||||
PaginatedResponse<{ regions: HttpTypes.AdminRegion[] }>
|
||||
>(`/admin/regions`, {
|
||||
query: queryParams,
|
||||
headers,
|
||||
})
|
||||
return await this.client.fetch<HttpTypes.AdminRegionListResponse>(
|
||||
`/admin/regions`,
|
||||
{
|
||||
query: queryParams,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a region by ID. It sends a request to the
|
||||
* [Get Region](https://docs.medusajs.com/api/admin#regions_getregionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the region to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the region.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The region's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a region by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.region.retrieve("region_123")
|
||||
* .then(({ region }) => {
|
||||
* console.log(region)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.region.retrieve("region_123", {
|
||||
* fields: "id,*countries"
|
||||
* })
|
||||
* .then(({ region }) => {
|
||||
* console.log(region)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<{ region: HttpTypes.AdminRegion }>(
|
||||
return await this.client.fetch<HttpTypes.AdminRegionResponse>(
|
||||
`/admin/regions/${id}`,
|
||||
{
|
||||
query,
|
||||
@@ -74,6 +192,21 @@ export class Region {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a region by ID. It sends a request to the
|
||||
* [Delete Region](https://docs.medusajs.com/api/admin#regions_deleteregionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the region to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.region.delete("region_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminRegionDeleteResponse>(
|
||||
`/admin/regions/${id}`,
|
||||
|
||||
@@ -14,6 +14,39 @@ class Reservation {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a reservation by ID. It sends a request to the
|
||||
* [Get Reservation](https://docs.medusajs.com/api/admin#reservations_getreservationsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The reservation's ID.
|
||||
* @param query - Configure the fields and relations to retrieve in the reservation.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The reservation's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a reservation by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.reservation.retrieve("res_123")
|
||||
* .then(({ reservation }) => {
|
||||
* console.log(reservation)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.reservation.retrieve("res_123", {
|
||||
* fields: "id,name"
|
||||
* })
|
||||
* .then(({ reservation }) => {
|
||||
* console.log(reservation)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminReservationParams,
|
||||
@@ -29,6 +62,53 @@ class Reservation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of reservations. It sends a request to the
|
||||
* [List Reservations](https://docs.medusajs.com/api/admin#reservations_getreservations)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of reservations.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of reservations:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.reservation.list()
|
||||
* .then(({ reservations, count, limit, offset }) => {
|
||||
* console.log(reservations)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.reservation.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ reservations, count, limit, offset }) => {
|
||||
* console.log(reservations)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each reservation:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.reservation.list({
|
||||
* fields: "id,*inventory_item"
|
||||
* })
|
||||
* .then(({ reservations, count, limit, offset }) => {
|
||||
* console.log(reservations)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -43,6 +123,26 @@ class Reservation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a reservation. It sends a request to the
|
||||
* [Create Reservation](https://docs.medusajs.com/api/admin#reservations_postreservations)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the reservation to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the reservation.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The reservation's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.reservation.create({
|
||||
* inventory_item_id: "iitem_123",
|
||||
* location_id: "sloc_123",
|
||||
* quantity: 10,
|
||||
* })
|
||||
* .then(({ reservation }) => {
|
||||
* console.log(reservation)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateReservation,
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
@@ -59,6 +159,25 @@ class Reservation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a reservation. It sends a request to the
|
||||
* [Update Reservation](https://docs.medusajs.com/api/admin#reservations_postreservationsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The reservation's ID.
|
||||
* @param body - The details of the reservation to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the reservation.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The reservation's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.reservation.update("res_123", {
|
||||
* quantity: 20,
|
||||
* })
|
||||
* .then(({ reservation }) => {
|
||||
* console.log(reservation)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateReservation,
|
||||
@@ -76,6 +195,21 @@ class Reservation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a reservation by ID. It sends a request to the
|
||||
* [Delete Reservation](https://docs.medusajs.com/api/admin#reservations_deletereservationsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The reservation's ID.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.reservation.delete("res_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationDeleteResponse>(
|
||||
`/admin/reservations/${id}`,
|
||||
|
||||
@@ -15,6 +15,53 @@ export class ReturnReason {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of return reasons. It sends a request to the
|
||||
* [List Return Reasons](https://docs.medusajs.com/api/admin#return-reasons_returnreason_schema)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The paginated list of return reasons.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of return reasons:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.returnReason.list()
|
||||
* .then(({ return_reasons, count, limit, offset }) => {
|
||||
* console.log(return_reasons)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.returnReason.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ return_reasons, count, limit, offset }) => {
|
||||
* console.log(return_reasons)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each return reason:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.returnReason.list({
|
||||
* fields: "id,value"
|
||||
* })
|
||||
* .then(({ return_reasons, count, limit, offset }) => {
|
||||
* console.log(return_reasons)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminReturnReasonListParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -28,6 +75,39 @@ export class ReturnReason {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a return reason by ID. It sends a request to the
|
||||
* [Get Return Reason](https://docs.medusajs.com/api/admin#return-reasons_getreturnreasonsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The return reason's ID.
|
||||
* @param query - Configure the fields and relations to retrieve in the return reason.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return reason's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a return reason by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.returnReason.retrieve("ret_123")
|
||||
* .then(({ return_reason }) => {
|
||||
* console.log(return_reason)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.returnReason.retrieve("ret_123", {
|
||||
* fields: "id,value"
|
||||
* })
|
||||
* .then(({ return_reason }) => {
|
||||
* console.log(return_reason)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminReturnReasonParams,
|
||||
@@ -42,6 +122,25 @@ export class ReturnReason {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a return reason. It sends a request to the
|
||||
* [Create Return Reason](https://docs.medusajs.com/api/admin#return-reasons_postreturnreasons)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the return reason to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the return reason.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return reason's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.returnReason.create({
|
||||
* value: "refund",
|
||||
* label: "Refund",
|
||||
* })
|
||||
* .then(({ return_reason }) => {
|
||||
* console.log(return_reason)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateReturnReason,
|
||||
query?: HttpTypes.AdminReturnReasonParams,
|
||||
@@ -58,6 +157,26 @@ export class ReturnReason {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a return reason. It sends a request to the
|
||||
* [Update Return Reason](https://docs.medusajs.com/api/admin#return-reasons_postreturnreasonsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The return reason's ID.
|
||||
* @param body - The details of the return reason to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the return reason.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return reason's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.returnReason.update("ret_123", {
|
||||
* value: "refund",
|
||||
* label: "Refund",
|
||||
* })
|
||||
* .then(({ return_reason }) => {
|
||||
* console.log(return_reason)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateReturnReason,
|
||||
@@ -75,6 +194,22 @@ export class ReturnReason {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a return reason. It sends a request to the
|
||||
* [Delete Return Reason](https://docs.medusajs.com/api/admin#return-reasons_deletereturnreasonsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The return reason's ID.
|
||||
* @param query - Query parameters to pass to the request.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.returnReason.delete("ret_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminReturnReasonParams,
|
||||
|
||||
@@ -15,6 +15,53 @@ export class Return {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of returns. It sends a request to the
|
||||
* [List Returns](https://docs.medusajs.com/api/admin#returns_getreturns)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of returns.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of returns:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.return.list()
|
||||
* .then(({ returns, count, limit, offset }) => {
|
||||
* console.log(returns)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.return.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ returns, count, limit, offset }) => {
|
||||
* console.log(returns)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each return:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.return.list({
|
||||
* fields: "id,*items"
|
||||
* })
|
||||
* .then(({ returns, count, limit, offset }) => {
|
||||
* console.log(returns)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(query?: HttpTypes.AdminReturnFilters, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnsResponse>(
|
||||
`/admin/returns`,
|
||||
@@ -25,6 +72,39 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a return by ID. It sends a request to the
|
||||
* [Get Return](https://docs.medusajs.com/api/admin#returns_getreturnsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a return by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.return.retrieve("return_123")
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.return.retrieve("return_123", {
|
||||
* fields: "id,*items"
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminReturnResponse>(
|
||||
`/admin/returns/${id}`,
|
||||
@@ -35,6 +115,24 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initiates a return request by creating a return. It sends a request to the
|
||||
* [Create Return](https://docs.medusajs.com/api/admin#returns_postreturns)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the return to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.initiateRequest({
|
||||
* order_id: "order_123",
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async initiateRequest(
|
||||
body: HttpTypes.AdminInitiateReturnRequest,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -51,6 +149,22 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method cancels a return. It sends a request to the
|
||||
* [Cancel Return](https://docs.medusajs.com/api/admin#returns_postreturnsidcancel)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to cancel.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.cancel("return_123")
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async cancel(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -66,6 +180,22 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method cancels a return request. It sends a request to the
|
||||
* [Cancel Return Request](https://docs.medusajs.com/api/admin#returns_deletereturnsidrequest)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to cancel.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.cancelRequest("return_123")
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async cancelRequest(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -81,6 +211,26 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds an item to a return request. It sends a request to the
|
||||
* [Add Return Item](https://docs.medusajs.com/api/admin#returns_postreturnsidrequestitems)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to add the item to.
|
||||
* @param body - The details of the item to add to the return.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.addReturnItem("return_123", {
|
||||
* id: "orlitem_123",
|
||||
* quantity: 1,
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async addReturnItem(
|
||||
id: string,
|
||||
body: HttpTypes.AdminAddReturnItems,
|
||||
@@ -98,6 +248,31 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates an item in a return request by the ID of the item's `RETURN_ITEM` action.
|
||||
* Every item has an `actions` property, whose value is an array of actions. You can check the action's name
|
||||
* using its `action` property, and use the value of the `id` property. For example,
|
||||
* `item.actions.find((action) => action.action === "RETURN_ITEM")?.id` is the ID of an item's `RETURN_ITEM` action.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Update Requested Return Item](https://docs.medusajs.com/api/admin#returns_postreturnsidrequestitemsaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to update the item in.
|
||||
* @param actionId - The ID of the item's `RETURN_ITEM` action.
|
||||
* @param body - The details of the item to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.updateReturnItem("return_123", "orchach_123", {
|
||||
* quantity: 2,
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async updateReturnItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -116,6 +291,29 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes an item from a return request by the ID of the item's `RETURN_ITEM` action.
|
||||
*
|
||||
* Every item has an `actions` property, whose value is an array of actions. You can check the action's name
|
||||
* using its `action` property, and use the value of the `id` property. For example,
|
||||
* `item.actions.find((action) => action.action === "RETURN_ITEM")?.id` is the ID of an item's `RETURN_ITEM` action.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Remove Item from Return](https://docs.medusajs.com/api/admin#returns_deletereturnsidrequestitemsaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to remove the item from.
|
||||
* @param actionId - The ID of the item's `RETURN_ITEM` action.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.removeReturnItem("return_123", "orchach_123")
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async removeReturnItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -132,6 +330,25 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a shipping method to a return request. It sends a request to the
|
||||
* [Add Shipping Method to Return](https://docs.medusajs.com/api/admin#returns_postreturnsidshippingmethod)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to add the shipping method to.
|
||||
* @param body - The details of the shipping method to add to the return.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.addReturnShipping("return_123", {
|
||||
* shipping_option_id: "so_123",
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async addReturnShipping(
|
||||
id: string,
|
||||
body: HttpTypes.AdminAddReturnShipping,
|
||||
@@ -149,6 +366,34 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a shipping method in a return request by the ID of the shipping method's `SHIPPING_ADD` action.
|
||||
*
|
||||
* Every shipping method has an `actions` property, whose value is an array of actions. You can check the action's name
|
||||
* using its `action` property, and use the value of the `id` property.
|
||||
*
|
||||
* For example, `shipping_method.actions.find((action) => action.action === "SHIPPING_ADD")?.id` is
|
||||
* the ID of a shipping method's `SHIPPING_ADD` action.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Update Shipping Method in Return](https://docs.medusajs.com/api/admin#returns_postreturnsidshippingmethodaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to update the shipping method in.
|
||||
* @param actionId - The ID of the shipping method's `SHIPPING_ADD` action.
|
||||
* @param body - The details of the shipping method to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.updateReturnShipping("return_123", "orchach_123", {
|
||||
* custom_amount: 100,
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async updateReturnShipping(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -167,6 +412,31 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes a shipping method from a return request by the ID of the shipping method's `SHIPPING_ADD` action.
|
||||
*
|
||||
* Every shipping method has an `actions` property, whose value is an array of actions. You can check the action's name
|
||||
* using its `action` property, and use the value of the `id` property.
|
||||
*
|
||||
* For example, `shipping_method.actions.find((action) => action.action === "SHIPPING_ADD")?.id` is
|
||||
* the ID of a shipping method's `SHIPPING_ADD` action.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Remove Shipping Method from Return](https://docs.medusajs.com/api/admin#returns_deletereturnsidshippingmethodaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to remove the shipping method from.
|
||||
* @param actionId - The ID of the shipping method's `SHIPPING_ADD` action.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.deleteReturnShipping("return_123", "orchach_123")
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async deleteReturnShipping(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -183,6 +453,25 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a return request. It sends a request to the
|
||||
* [Update Return](https://docs.medusajs.com/api/admin#returns_postreturnsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to update.
|
||||
* @param body - The details of the return to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.updateRequest("return_123", {
|
||||
* location_id: "sloc_123",
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async updateRequest(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateReturnRequest,
|
||||
@@ -200,6 +489,30 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method confirms a return request. The return's changes are applied on the inventory quantity of the return
|
||||
* items and the order only after the return has been confirmed as received using the
|
||||
* [Confirm Return Receival](https://docs.medusajs.com/api/admin#returns_postreturnsidreceiveconfirm)
|
||||
* API route.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Confirm Return Request](https://docs.medusajs.com/api/admin#returns_postreturnsidrequest)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to confirm.
|
||||
* @param body - The details of the return to confirm.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.confirmRequest("return_123", {
|
||||
* no_notification: true,
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async confirmRequest(
|
||||
id: string,
|
||||
body: HttpTypes.AdminConfirmReturnRequest,
|
||||
@@ -217,6 +530,25 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method starts the return receival process. It sends a request to the
|
||||
* [Start Return Receival](https://docs.medusajs.com/api/admin#returns_postreturnsidreceive)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to start the receival process.
|
||||
* @param body - The details of the return to start the receival process.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.initiateReceive("return_123", {
|
||||
* internal_note: "Return received by the customer",
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async initiateReceive(
|
||||
id: string,
|
||||
body: HttpTypes.AdminInitiateReceiveReturn,
|
||||
@@ -234,6 +566,29 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds received items to a return. These items will have the action `RECEIVE_RETURN_ITEM`.
|
||||
*
|
||||
* The method sends a request to the
|
||||
* [Add Received Items](https://docs.medusajs.com/api/admin#returns_postreturnsidreceiveitems)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to add the received items to.
|
||||
* @param body - The details of the received items to add to the return.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.receiveItems("return_123", {
|
||||
* items: [
|
||||
* { id: "item_123", quantity: 1 },
|
||||
* ],
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async receiveItems(
|
||||
id: string,
|
||||
body: HttpTypes.AdminReceiveItems,
|
||||
@@ -251,6 +606,34 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a received item in the return by the ID of the item's `RECEIVE_RETURN_ITEM` action.
|
||||
*
|
||||
* Every item has an `actions` property, whose value is an array of actions. You can check the action's name
|
||||
* using its `action` property, and use the value of the `id` property.
|
||||
*
|
||||
* For example, `received_item.actions.find((action) => action.action === "RECEIVE_RETURN_ITEM")?.id` is
|
||||
* the ID of a received item's `RECEIVE_RETURN_ITEM` action.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Update Received Item](https://docs.medusajs.com/api/admin#returns_postreturnsidreceiveitemsaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to update the received item in.
|
||||
* @param actionId - The ID of the received item's `RECEIVE_RETURN_ITEM` action.
|
||||
* @param body - The details of the received item to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.updateReceiveItem("return_123", "orchach_123", {
|
||||
* quantity: 2,
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async updateReceiveItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -269,6 +652,31 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes a received item from the return by the ID of the item's `RECEIVE_RETURN_ITEM` action.
|
||||
*
|
||||
* Every item has an `actions` property, whose value is an array of actions. You can check the action's name
|
||||
* using its `action` property, and use the value of the `id` property.
|
||||
*
|
||||
* For example, `received_item.actions.find((action) => action.action === "RECEIVE_RETURN_ITEM")?.id` is
|
||||
* the ID of a received item's `RECEIVE_RETURN_ITEM` action.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Remove Received Item](https://docs.medusajs.com/api/admin#returns_deletereturnsidreceiveitemsaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to remove the received item from.
|
||||
* @param actionId - The ID of the received item's `RECEIVE_RETURN_ITEM` action.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.removeReceiveItem("return_123", "orchach_123")
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async removeReceiveItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -285,6 +693,32 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds damaged items to the return. These items will have the action `RECEIVE_DAMAGED_RETURN_ITEM`.
|
||||
*
|
||||
* A damaged item's quantity is not added back to the associated inventory item's quantity in the
|
||||
* stock location where the return is initiated from.
|
||||
*
|
||||
* The method sends a request to the
|
||||
* [Add Damaged Items](https://docs.medusajs.com/api/admin#returns_postreturnsiddismissitems)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to add the damaged items to.
|
||||
* @param body - The details of the damaged items to add to the return.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.dismissItems("return_123", {
|
||||
* items: [
|
||||
* { id: "orli_123", quantity: 1 },
|
||||
* ],
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async dismissItems(
|
||||
id: string,
|
||||
body: HttpTypes.AdminDismissItems,
|
||||
@@ -302,6 +736,34 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a damaged item in the return by the ID of the item's `RECEIVE_DAMAGED_RETURN_ITEM` action.
|
||||
*
|
||||
* Every item has an `actions` property, whose value is an array of actions. You can check the action's name
|
||||
* using its `action` property, and use the value of the `id` property.
|
||||
*
|
||||
* For example, `item.actions.find((action) => action.action === "RECEIVE_DAMAGED_RETURN_ITEM")?.id` is
|
||||
* the ID of a damaged item's `RECEIVE_DAMAGED_RETURN_ITEM` action.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Update Damaged Item](https://docs.medusajs.com/api/admin#returns_postreturnsiddismissitemsaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to update the damaged item in.
|
||||
* @param actionId - The ID of the damaged item's `RECEIVE_DAMAGED_RETURN_ITEM` action.
|
||||
* @param body - The details of the damaged item to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.updateDismissItem("return_123", "orchach_123", {
|
||||
* quantity: 2,
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async updateDismissItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -320,6 +782,31 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes a damaged item from the return by the ID of the item's `RECEIVE_DAMAGED_RETURN_ITEM` action.
|
||||
*
|
||||
* Every item has an `actions` property, whose value is an array of actions. You can check the action's name
|
||||
* using its `action` property, and use the value of the `id` property.
|
||||
*
|
||||
* For example, `item.actions.find((action) => action.action === "RECEIVE_DAMAGED_RETURN_ITEM")?.id` is
|
||||
* the ID of a damaged item's `RECEIVE_DAMAGED_RETURN_ITEM` action.
|
||||
*
|
||||
* This method sends a request to the
|
||||
* [Remove Damaged Item](https://docs.medusajs.com/api/admin#returns_deletereturnsiddismissitemsaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to remove the damaged item from.
|
||||
* @param actionId - The ID of the damaged item's `RECEIVE_DAMAGED_RETURN_ITEM` action.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.removeDismissItem("return_123", "orchach_123")
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async removeDismissItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -336,6 +823,25 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method confirms the return receival. It sends a request to the
|
||||
* [Confirm Return Receival](https://docs.medusajs.com/api/admin#returns_postreturnsidreceiveconfirm)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to confirm the receival of.
|
||||
* @param body - The details of the receival confirmation.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.confirmReceive("return_123", {
|
||||
* no_notification: true,
|
||||
* })
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async confirmReceive(
|
||||
id: string,
|
||||
body: HttpTypes.AdminConfirmReceiveReturn,
|
||||
@@ -353,6 +859,22 @@ export class Return {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method cancels a return receival. It sends a request to the
|
||||
* [Cancel Return Receival](https://docs.medusajs.com/api/admin#returns_deletereturnsidreceive)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the return to cancel the receival of.
|
||||
* @param query - Configure the fields and relations to retrieve in the return.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The return's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.return.cancelReceive("return_123")
|
||||
* .then(({ return }) => {
|
||||
* console.log(return)
|
||||
* })
|
||||
*/
|
||||
async cancelReceive(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
|
||||
@@ -14,6 +14,24 @@ export class SalesChannel {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a new sales channel. It sends a request to the
|
||||
* [Create Sales Channel](https://docs.medusajs.com/api/admin#sales-channels_postsaleschannels)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the sales channel to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the sales channel.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The sales channel's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.salesChannel.create({
|
||||
* name: "Storefront",
|
||||
* })
|
||||
* .then(({ salesChannel }) => {
|
||||
* console.log(salesChannel)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateSalesChannel,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -30,6 +48,28 @@ export class SalesChannel {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a sales channel. It sends a request to the
|
||||
* [Update Sales Channel](https://docs.medusajs.com/api/admin#sales-channels_postsaleschannelsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the sales channel to update.
|
||||
* @param body - The details of the sales channel to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the sales channel.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The sales channel's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.salesChannel.update(
|
||||
* "sc_123",
|
||||
* {
|
||||
* name: "Storefront",
|
||||
* }
|
||||
* )
|
||||
* .then(({ salesChannel }) => {
|
||||
* console.log(salesChannel)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateSalesChannel,
|
||||
@@ -47,6 +87,21 @@ export class SalesChannel {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a sales channel. It sends a request to the
|
||||
* [Delete Sales Channel](https://docs.medusajs.com/api/admin#sales-channels_deletesaleschannelsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the sales channel to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.salesChannel.delete("sc_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminSalesChannelDeleteResponse>(
|
||||
`/admin/sales-channels/${id}`,
|
||||
@@ -57,6 +112,39 @@ export class SalesChannel {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a sales channel. It sends a request to the
|
||||
* [Retrieve Sales Channel](https://docs.medusajs.com/api/admin#sales-channels_getsaleschannelsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the sales channel to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the sales channel.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The sales channel's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a sales channel by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.salesChannel.retrieve("sc_123")
|
||||
* .then(({ sales_channel }) => {
|
||||
* console.log(sales_channel)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.salesChannel.retrieve("sc_123", {
|
||||
* fields: "id,*products"
|
||||
* })
|
||||
* .then(({ sales_channel }) => {
|
||||
* console.log(sales_channel)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -72,6 +160,53 @@ export class SalesChannel {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of sales channels. It sends a request to the
|
||||
* [List Sales Channels](https://docs.medusajs.com/api/admin#sales-channels_getsaleschannels)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of sales channels.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of sales channels:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.salesChannel.list()
|
||||
* .then(({ sales_channels, count, limit, offset }) => {
|
||||
* console.log(sales_channels)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.salesChannel.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ sales_channels, count, limit, offset }) => {
|
||||
* console.log(sales_channels)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each sales channel:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.salesChannel.list({
|
||||
* fields: "id,*products"
|
||||
* })
|
||||
* .then(({ sales_channels, count, limit, offset }) => {
|
||||
* console.log(sales_channels)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminSalesChannelListParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -86,6 +221,25 @@ export class SalesChannel {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method manages the products in a sales channel to add or remove them. It sends a request to the
|
||||
* [Manage Products in Sales Channel](https://docs.medusajs.com/api/admin#sales-channels_postsaleschannelsidproducts)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the sales channel to manage the products for.
|
||||
* @param body - The details of the products to add or remove from the sales channel.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The sales channel's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.salesChannel.updateProducts("sc_123", {
|
||||
* add: ["prod_123", "prod_456"],
|
||||
* remove: ["prod_789"]
|
||||
* })
|
||||
* .then(({ sales_channel }) => {
|
||||
* console.log(sales_channel)
|
||||
* })
|
||||
*/
|
||||
async updateProducts(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateSalesChannelProducts,
|
||||
@@ -101,6 +255,25 @@ export class SalesChannel {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method manages the products in a sales channel to add or remove them. It sends a request to the
|
||||
* [Manage Products in Sales Channel](https://docs.medusajs.com/api/admin#sales-channels_postsaleschannelsidproducts)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the sales channel to manage the products for.
|
||||
* @param body - The details of the products to add or remove from the sales channel.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The sales channel's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.salesChannel.batchProducts("sc_123", {
|
||||
* add: ["prod_123", "prod_456"],
|
||||
* remove: ["prod_789"]
|
||||
* })
|
||||
* .then(({ sales_channel }) => {
|
||||
* console.log(sales_channel)
|
||||
* })
|
||||
*/
|
||||
async batchProducts(
|
||||
id: string,
|
||||
body: HttpTypes.AdminBatchLink,
|
||||
|
||||
@@ -13,7 +13,25 @@ export class ShippingOption {
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a shipping option. It sends a request to the
|
||||
* [Create Shipping Option](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptions)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the shipping option to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the shipping option.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The shipping option's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.shippingOption.create({
|
||||
* name: "Standard Shipping",
|
||||
* profile_id: "shp_123",
|
||||
* })
|
||||
* .then(({ shipping_option }) => {
|
||||
* console.log(shipping_option)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateShippingOption,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -30,6 +48,39 @@ export class ShippingOption {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a shipping option. It sends a request to the
|
||||
* [Get Shipping Option](https://docs.medusajs.com/api/admin#shipping-options_getshippingoptionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the shipping option to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the shipping option.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The shipping option's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a shipping option by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingOption.retrieve("so_123")
|
||||
* .then(({ shipping_option }) => {
|
||||
* console.log(shipping_option)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingOption.retrieve("so_123", {
|
||||
* fields: "id,*service_zone"
|
||||
* })
|
||||
* .then(({ shipping_option }) => {
|
||||
* console.log(shipping_option)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -45,6 +96,25 @@ export class ShippingOption {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a shipping option. It sends a request to the
|
||||
* [Update Shipping Option](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the shipping option to update.
|
||||
* @param body - The details of the shipping option to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the shipping option.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The shipping option's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.shippingOption.update("so_123", {
|
||||
* name: "Standard Shipping",
|
||||
* })
|
||||
* .then(({ shipping_option }) => {
|
||||
* console.log(shipping_option)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateShippingOption,
|
||||
@@ -62,6 +132,21 @@ export class ShippingOption {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a shipping option. It sends a request to the
|
||||
* [Delete Shipping Option](https://docs.medusajs.com/api/admin#shipping-options_deleteshippingoptionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the shipping option to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.shippingOption.delete("so_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminShippingOptionDeleteResponse>(
|
||||
`/admin/shipping-options/${id}`,
|
||||
@@ -72,6 +157,53 @@ export class ShippingOption {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of shipping options. It sends a request to the
|
||||
* [List Shipping Options](https://docs.medusajs.com/api/admin#shipping-options_getshippingoptions)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of shipping options.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of shipping options:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingOption.list()
|
||||
* .then(({ shipping_options, count, limit, offset }) => {
|
||||
* console.log(shipping_options)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingOption.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ shipping_options, count, limit, offset }) => {
|
||||
* console.log(shipping_options)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each shipping option:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingOption.list({
|
||||
* fields: "id,*service_zone"
|
||||
* })
|
||||
* .then(({ shipping_options, count, limit, offset }) => {
|
||||
* console.log(shipping_options)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminShippingOptionListParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -86,6 +218,24 @@ export class ShippingOption {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method manages the rules of a shipping option to create, update, or remove them. It sends a request to the
|
||||
* [Manage Rules of a Shipping Option](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptionsidrulesbatch)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the shipping option to manage the rules for.
|
||||
* @param body - The details of the shipping option rules to manage.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The shipping option's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.shippingOption.updateRules("so_123", {
|
||||
* create: [{ attribute: "enabled_in_store", operator: "eq", value: "true" }],
|
||||
* })
|
||||
* .then(({ shipping_option }) => {
|
||||
* console.log(shipping_option)
|
||||
* })
|
||||
*/
|
||||
async updateRules(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateShippingOptionRules,
|
||||
|
||||
@@ -14,6 +14,24 @@ export class ShippingProfile {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a new shipping profile. It sends a request to the
|
||||
* [Create Shipping Profile](https://docs.medusajs.com/api/admin#shipping-profiles_postshippingprofiles)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the shipping profile to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the shipping profile.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The shipping profile's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.shippingProfile.create({
|
||||
* name: "Default Shipping Profile",
|
||||
* })
|
||||
* .then(({ shipping_profile }) => {
|
||||
* console.log(shipping_profile)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateShippingProfile,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -30,6 +48,25 @@ export class ShippingProfile {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a shipping profile. It sends a request to the
|
||||
* [Update Shipping Profile](https://docs.medusajs.com/api/admin#shipping-profiles_postshippingprofilesid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the shipping profile to update.
|
||||
* @param body - The details of the shipping profile to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the shipping profile.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The shipping profile's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.shippingProfile.update("sp_123", {
|
||||
* name: "Updated Shipping Profile",
|
||||
* })
|
||||
* .then(({ shipping_profile }) => {
|
||||
* console.log(shipping_profile)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateShippingProfile,
|
||||
@@ -47,6 +84,21 @@ export class ShippingProfile {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a shipping profile. It sends a request to the
|
||||
* [Delete Shipping Profile](https://docs.medusajs.com/api/admin#shipping-profiles_deleteshippingprofilesid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the shipping profile to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.shippingProfile.delete("sp_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminShippingProfileDeleteResponse>(
|
||||
`/admin/shipping-profiles/${id}`,
|
||||
@@ -57,6 +109,53 @@ export class ShippingProfile {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of shipping profiles. It sends a request to the
|
||||
* [List Shipping Profiles](https://docs.medusajs.com/api/admin#shipping-profiles_getshippingprofiles)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of shipping profiles.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of shipping profiles:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingProfile.list()
|
||||
* .then(({ shipping_profiles, count, limit, offset }) => {
|
||||
* console.log(shipping_profiles)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingProfile.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ shipping_profiles, count, limit, offset }) => {
|
||||
* console.log(shipping_profiles)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each shipping profile:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingProfile.list({
|
||||
* fields: "id,name"
|
||||
* })
|
||||
* .then(({ shipping_profiles, count, limit, offset }) => {
|
||||
* console.log(shipping_profiles)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminShippingProfileListParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -71,6 +170,39 @@ export class ShippingProfile {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a shipping profile. It sends a request to the
|
||||
* [Get Shipping Profile](https://docs.medusajs.com/api/admin#shipping-profiles_getshippingprofilesid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the shipping profile to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the shipping profile.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The shipping profile's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a shipping profile by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingProfile.retrieve("sp_123")
|
||||
* .then(({ shipping_profile }) => {
|
||||
* console.log(shipping_profile)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.shippingProfile.retrieve("sp_123", {
|
||||
* fields: "id,name"
|
||||
* })
|
||||
* .then(({ shipping_profile }) => {
|
||||
* console.log(shipping_profile)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
|
||||
@@ -14,6 +14,25 @@ export class StockLocation {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a new stock location. It sends a request to the
|
||||
* [Create Stock Location](https://docs.medusajs.com/api/admin#stock-locations_poststocklocations)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the stock location to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the stock location.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The stock location's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.stockLocation.create({
|
||||
* name: "Main Warehouse",
|
||||
* address_id: "addr_123",
|
||||
* })
|
||||
* .then(({ stock_location }) => {
|
||||
* console.log(stock_location)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateStockLocation,
|
||||
query?: SelectParams,
|
||||
@@ -30,6 +49,25 @@ export class StockLocation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a stock location. It sends a request to the
|
||||
* [Update Stock Location](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the stock location to update.
|
||||
* @param body - The details of the stock location to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the stock location.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The stock location's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.stockLocation.update("sloc_123", {
|
||||
* name: "European Warehouse",
|
||||
* })
|
||||
* .then(({ stock_location }) => {
|
||||
* console.log(stock_location)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateStockLocation,
|
||||
@@ -47,6 +85,21 @@ export class StockLocation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a stock location. It sends a request to the
|
||||
* [Delete Stock Location](https://docs.medusajs.com/api/admin#stock-locations_deletestocklocationsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the stock location to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.stockLocation.delete("sloc_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminStockLocationDeleteResponse>(
|
||||
`/admin/stock-locations/${id}`,
|
||||
@@ -57,6 +110,39 @@ export class StockLocation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a stock location. It sends a request to the
|
||||
* [Get Stock Location](https://docs.medusajs.com/api/admin#stock-locations_getstocklocationsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the stock location to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the stock location.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The stock location's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a stock location by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.stockLocation.retrieve("sloc_123")
|
||||
* .then(({ stock_location }) => {
|
||||
* console.log(stock_location)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.stockLocation.retrieve("sloc_123", {
|
||||
* fields: "id,*sales_channels"
|
||||
* })
|
||||
* .then(({ stock_location }) => {
|
||||
* console.log(stock_location)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminStockLocationResponse>(
|
||||
`/admin/stock-locations/${id}`,
|
||||
@@ -68,6 +154,53 @@ export class StockLocation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of stock locations. It sends a request to the
|
||||
* [List Stock Locations](https://docs.medusajs.com/api/admin#stock-locations_getstocklocations)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of stock locations.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of stock locations:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.stockLocation.list()
|
||||
* .then(({ stock_locations, count, limit, offset }) => {
|
||||
* console.log(stock_locations)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.stockLocation.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ stock_locations, count, limit, offset }) => {
|
||||
* console.log(stock_locations)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each stock location:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.stockLocation.list({
|
||||
* fields: "id,*sales_channels"
|
||||
* })
|
||||
* .then(({ stock_locations, count, limit, offset }) => {
|
||||
* console.log(stock_locations)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminStockLocationListParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -82,6 +215,25 @@ export class StockLocation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method manages the sales channels of a stock location by adding or removing them. It sends a request to the
|
||||
* [Manage Stock Location Sales Channels](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsidsaleschannels)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the stock location to update the sales channels for.
|
||||
* @param body - The details of the sales channels to update.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The stock location's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.stockLocation.updateSalesChannels("sloc_123", {
|
||||
* add: ["sc_123"],
|
||||
* remove: ["sc_456"],
|
||||
* })
|
||||
* .then(({ stock_location }) => {
|
||||
* console.log(stock_location)
|
||||
* })
|
||||
*/
|
||||
async updateSalesChannels(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateStockLocationSalesChannels,
|
||||
@@ -97,6 +249,25 @@ export class StockLocation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a new fulfillment set to a stock location. It sends a request to the
|
||||
* [Add Fulfillment Set to Stock Location](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsidfulfillmentsets)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the stock location to add the fulfillment set to.
|
||||
* @param body - The details of the fulfillment set to add.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The stock location's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.stockLocation.createFulfillmentSet("sloc_123", {
|
||||
* name: "Shipping",
|
||||
* type: "shipping",
|
||||
* })
|
||||
* .then(({ stock_location }) => {
|
||||
* console.log(stock_location)
|
||||
* })
|
||||
*/
|
||||
async createFulfillmentSet(
|
||||
id: string,
|
||||
body: HttpTypes.AdminCreateStockLocationFulfillmentSet,
|
||||
@@ -112,6 +283,25 @@ export class StockLocation {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method manages the fulfillment providers of a stock location by adding or removing them. It sends a request to the
|
||||
* [Manage Fulfillment Providers of Stock Location](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsidfulfillmentproviders)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the stock location to manage the fulfillment providers for.
|
||||
* @param body - The details of the fulfillment providers to manage.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The stock location's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.stockLocation.updateFulfillmentProviders("sloc_123", {
|
||||
* add: ["fp_manual_manual"],
|
||||
* remove: ["fp_shipstation_shipstation"],
|
||||
* })
|
||||
* .then(({ stock_location }) => {
|
||||
* console.log(stock_location)
|
||||
* })
|
||||
*/
|
||||
async updateFulfillmentProviders(
|
||||
id: string,
|
||||
body: HttpTypes.AdminBatchLink,
|
||||
|
||||
@@ -14,6 +14,39 @@ export class Store {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a store by its ID. It sends a request to the
|
||||
* [Get Store](https://docs.medusajs.com/api/admin#stores_getstoresid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the store to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the store.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The store's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a store by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.store.retrieve("store_123")
|
||||
* .then(({ store }) => {
|
||||
* console.log(store)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.store.retrieve("store_123", {
|
||||
* fields: "id,*supported_currencies"
|
||||
* })
|
||||
* .then(({ store }) => {
|
||||
* console.log(store)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminStoreParams,
|
||||
@@ -29,6 +62,53 @@ export class Store {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of stores. It sends a request to the
|
||||
* [List Stores](https://docs.medusajs.com/api/admin#stores_getstores)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of stores.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of stores:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.store.list()
|
||||
* .then(({ stores, count, limit, offset }) => {
|
||||
* console.log(stores)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.store.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ stores, count, limit, offset }) => {
|
||||
* console.log(stores)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each store:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.store.list({
|
||||
* fields: "id,*supported_currencies"
|
||||
* })
|
||||
* .then(({ stores, count, limit, offset }) => {
|
||||
* console.log(stores)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(query?: HttpTypes.AdminStoreListParams, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminStoreListResponse>(
|
||||
`/admin/stores`,
|
||||
@@ -40,6 +120,25 @@ export class Store {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a store. It sends a request to the
|
||||
* [Update Store](https://docs.medusajs.com/api/admin#stores_poststoresid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the store to update.
|
||||
* @param body - The details of the store to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the store.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The store's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.store.update("store_123", {
|
||||
* name: "My Store",
|
||||
* })
|
||||
* .then(({ store }) => {
|
||||
* console.log(store)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateStore,
|
||||
|
||||
@@ -16,6 +16,27 @@ export class TaxRate {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a tax rate. It sends a request to the
|
||||
* [Create Tax Rate](https://docs.medusajs.com/api/admin#tax-rates_posttaxrates)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the tax rate to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the tax rate.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The tax rate's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.taxRate.create({
|
||||
* name: "VAT",
|
||||
* tax_region_id: "txreg_123",
|
||||
* code: "VAT",
|
||||
* rate: 2, // 2%
|
||||
* })
|
||||
* .then(({ tax_rate }) => {
|
||||
* console.log(tax_rate)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateTaxRate,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -29,6 +50,26 @@ export class TaxRate {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a tax rate. It sends a request to the
|
||||
* [Update Tax Rate](https://docs.medusajs.com/api/admin#tax-rates_posttaxratesid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the tax rate to update.
|
||||
* @param body - The details of the tax rate to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the tax rate.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The tax rate's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.taxRate.update("txrat_123", {
|
||||
* name: "VAT",
|
||||
* code: "VAT",
|
||||
* })
|
||||
* .then(({ tax_rate }) => {
|
||||
* console.log(tax_rate)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateTaxRate,
|
||||
@@ -46,6 +87,21 @@ export class TaxRate {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a tax rate. It sends a request to the
|
||||
* [Delete Tax Rate](https://docs.medusajs.com/api/admin#tax-rates_deletetaxratesid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the tax rate to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.taxRate.delete("txrat_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRateDeleteResponse>(
|
||||
`${taxRateUrl}/${id}`,
|
||||
@@ -56,6 +112,39 @@ export class TaxRate {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a tax rate. It sends a request to the
|
||||
* [Get Tax Rate](https://docs.medusajs.com/api/admin#tax-rates_gettaxratesid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the tax rate to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the tax rate.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The tax rate's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a tax rate by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRate.retrieve("txrat_123")
|
||||
* .then(({ tax_rate }) => {
|
||||
* console.log(tax_rate)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRate.retrieve("txrat_123", {
|
||||
* fields: "id,*tax_region"
|
||||
* })
|
||||
* .then(({ tax_rate }) => {
|
||||
* console.log(tax_rate)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -71,6 +160,53 @@ export class TaxRate {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of tax rates. It sends a request to the
|
||||
* [List Tax Rates](https://docs.medusajs.com/api/admin#tax-rates_gettaxrates)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of tax rates.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of tax rates:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRate.list()
|
||||
* .then(({ tax_rates, count, limit, offset }) => {
|
||||
* console.log(tax_rates)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRate.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ tax_rates, count, limit, offset }) => {
|
||||
* console.log(tax_rates)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each tax rate:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRate.list({
|
||||
* fields: "id,*tax_region"
|
||||
* })
|
||||
* .then(({ tax_rates, count, limit, offset }) => {
|
||||
* console.log(tax_rates)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminTaxRateListParams,
|
||||
headers?: ClientHeaders
|
||||
|
||||
@@ -4,7 +4,11 @@ import { ClientHeaders } from "../types"
|
||||
|
||||
const taxRegionUrl = "/admin/tax-regions"
|
||||
|
||||
// TODO: Add support for updating a tax region
|
||||
/**
|
||||
* @privateRemarks
|
||||
*
|
||||
* TODO: Add support for updating a tax region
|
||||
*/
|
||||
export class TaxRegion {
|
||||
/**
|
||||
* @ignore
|
||||
@@ -17,6 +21,31 @@ export class TaxRegion {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a tax region. It sends a request to the
|
||||
* [Create Tax Region](https://docs.medusajs.com/api/admin#tax-regions_posttaxregions)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the tax region to create.
|
||||
* @param query - Configure the fields and relations to retrieve in the tax region.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The tax region's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.taxRegion.create({
|
||||
* country_code: "us",
|
||||
* province_code: "ca",
|
||||
* default_tax_rate: {
|
||||
* code: "VAT",
|
||||
* name: "VAT",
|
||||
* rate: 20, // 20%
|
||||
* is_combinable: true,
|
||||
* },
|
||||
* })
|
||||
* .then(({ tax_region }) => {
|
||||
* console.log(tax_region)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateTaxRegion,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -33,6 +62,21 @@ export class TaxRegion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a tax region. It sends a request to the
|
||||
* [Delete Tax Region](https://docs.medusajs.com/api/admin#tax-regions_deletetaxregionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the tax region to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.taxRegion.delete("txreg_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRegionDeleteResponse>(
|
||||
`${taxRegionUrl}/${id}`,
|
||||
@@ -43,6 +87,39 @@ export class TaxRegion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a tax region. It sends a request to the
|
||||
* [Get Tax Region](https://docs.medusajs.com/api/admin#tax-regions_gettaxregionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the tax region to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the tax region.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The tax region's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a tax region by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRegion.retrieve("txreg_123")
|
||||
* .then(({ tax_region }) => {
|
||||
* console.log(tax_region)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRegion.retrieve("txreg_123", {
|
||||
* fields: "id,*tax_rates"
|
||||
* })
|
||||
* .then(({ tax_region }) => {
|
||||
* console.log(tax_region)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -58,6 +135,53 @@ export class TaxRegion {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of tax regions. It sends a request to the
|
||||
* [List Tax Regions](https://docs.medusajs.com/api/admin#tax-regions_gettaxregions)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of tax regions.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of tax regions:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRegion.list()
|
||||
* .then(({ tax_regions, count, limit, offset }) => {
|
||||
* console.log(tax_regions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRegion.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ tax_regions, count, limit, offset }) => {
|
||||
* console.log(tax_regions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each tax region:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.taxRegion.list({
|
||||
* fields: "id,*tax_rates"
|
||||
* })
|
||||
* .then(({ tax_regions, count, limit, offset }) => {
|
||||
* console.log(tax_regions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminTaxRegionListParams,
|
||||
headers?: ClientHeaders
|
||||
|
||||
@@ -14,7 +14,38 @@ export class Upload {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
// Note: The creation/upload flow be made more advanced, with support for streaming and progress, but for now we keep it simple
|
||||
/**
|
||||
* This method creates a new upload. It sends a request to the
|
||||
* [Upload Files](https://docs.medusajs.com/api/admin#uploads_postuploads)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the files to upload.
|
||||
* @param query - Configure the fields and relations to retrieve in the uploaded files.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The upload files' details.
|
||||
*
|
||||
* @privateRemarks
|
||||
*
|
||||
* Note: The creation/upload flow be made more advanced, with support for streaming and progress, but for now we keep it simple
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.upload.create(
|
||||
* {
|
||||
* files: [
|
||||
* // file uploaded as a base64 string
|
||||
* {
|
||||
* name: "test.txt",
|
||||
* content: "test", // Should be the base64 content of the file
|
||||
* },
|
||||
* // file uploaded as a File object
|
||||
* new File(["test"], "test.txt", { type: "text/plain" })
|
||||
* ],
|
||||
* }
|
||||
* )
|
||||
* .then(({ files }) => {
|
||||
* console.log(files)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminUploadFile,
|
||||
query?: SelectParams,
|
||||
@@ -39,7 +70,7 @@ export class Upload {
|
||||
})
|
||||
}
|
||||
|
||||
return this.client.fetch<{ files: HttpTypes.AdminFile[] }>(
|
||||
return this.client.fetch<HttpTypes.AdminFileListResponse>(
|
||||
`/admin/uploads`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -54,8 +85,24 @@ export class Upload {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a file's details by its ID. It sends a request to the
|
||||
* [Get File](https://docs.medusajs.com/api/admin#uploads_getuploadsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the file to retrieve.
|
||||
* @param query - Query parameters to pass in the request.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The file's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.upload.retrieve("test.txt")
|
||||
* .then(({ file }) => {
|
||||
* console.log(file)
|
||||
* })
|
||||
*/
|
||||
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
|
||||
return this.client.fetch<{ file: HttpTypes.AdminFile }>(
|
||||
return this.client.fetch<HttpTypes.AdminFileResponse>(
|
||||
`/admin/uploads/${id}`,
|
||||
{
|
||||
query,
|
||||
@@ -64,6 +111,21 @@ export class Upload {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a file by its ID from the configured File Module Provider. It sends a request to the
|
||||
* [Delete File](https://docs.medusajs.com/api/admin#uploads_deleteuploadsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the file to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.upload.delete("test.txt")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return this.client.fetch<HttpTypes.AdminFileDeleteResponse>(
|
||||
`/admin/uploads/${id}`,
|
||||
|
||||
@@ -14,6 +14,26 @@ export class User {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a user. It sends a request to the
|
||||
* [Update User](https://docs.medusajs.com/api/admin#users_postusersid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the user to update.
|
||||
* @param body - The details of the user to update.
|
||||
* @param query - Configure the fields and relations to retrieve in the tax region.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The user's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.user.update("user_123", {
|
||||
* first_name: "John",
|
||||
* last_name: "Doe",
|
||||
* })
|
||||
* .then(({ user }) => {
|
||||
* console.log(user)
|
||||
* })
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateUser,
|
||||
@@ -31,6 +51,53 @@ export class User {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of users. It sends a request to the
|
||||
* [List Users](https://docs.medusajs.com/api/admin#users_getusers)
|
||||
* API route.
|
||||
*
|
||||
* @param queryParams - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of users.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of users:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.user.list()
|
||||
* .then(({ users, count, limit, offset }) => {
|
||||
* console.log(users)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.user.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ users, count, limit, offset }) => {
|
||||
* console.log(users)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each user:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.user.list({
|
||||
* fields: "id,email"
|
||||
* })
|
||||
* .then(({ users, count, limit, offset }) => {
|
||||
* console.log(users)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
queryParams?: HttpTypes.AdminUserListParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -41,6 +108,39 @@ export class User {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a user. It sends a request to the
|
||||
* [Get User](https://docs.medusajs.com/api/admin#users_getusersid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the user to retrieve.
|
||||
* @param query - Configure the fields and relations to retrieve in the user.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The user's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a user by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.user.retrieve("user_123")
|
||||
* .then(({ user }) => {
|
||||
* console.log(user)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.user.retrieve("user_123", {
|
||||
* fields: "id,email"
|
||||
* })
|
||||
* .then(({ user }) => {
|
||||
* console.log(user)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminUserParams,
|
||||
@@ -55,6 +155,21 @@ export class User {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a user. It sends a request to the
|
||||
* [Delete User](https://docs.medusajs.com/api/admin#users_deleteusersid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the user to delete.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.user.delete("user_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return this.client.fetch<HttpTypes.AdminUserDeleteResponse>(
|
||||
`/admin/users/${id}`,
|
||||
@@ -65,6 +180,38 @@ export class User {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves the currently authenticated user. It sends a request to the
|
||||
* [Get Logged-In User](https://docs.medusajs.com/api/admin#users_getusersme)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Configure the fields and relations to retrieve in the user.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The user's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the currently authenticated user:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.user.me()
|
||||
* .then(({ user }) => {
|
||||
* console.log(user)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.user.me({
|
||||
* fields: "id,email"
|
||||
* })
|
||||
* .then(({ user }) => {
|
||||
* console.log(user)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async me(query?: HttpTypes.AdminUserParams, headers?: ClientHeaders) {
|
||||
return this.client.fetch<HttpTypes.AdminUserResponse>(`/admin/users/me`, {
|
||||
query,
|
||||
|
||||
@@ -14,6 +14,53 @@ export class WorkflowExecution {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a list of workflow executions. It sends a request to the
|
||||
* [List Workflow Executions](https://docs.medusajs.com/api/admin#workflows-executions_getworkflowsexecutions)
|
||||
* API route.
|
||||
*
|
||||
* @param queryParams - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The list of workflow executions.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of workflow executions:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.workflowExecution.list()
|
||||
* .then(({ workflow_executions, count, limit, offset }) => {
|
||||
* console.log(workflow_executions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.workflowExecution.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ workflow_executions, count, limit, offset }) => {
|
||||
* console.log(workflow_executions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each workflow execution:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.workflowExecution.list({
|
||||
* fields: "id,name"
|
||||
* })
|
||||
* .then(({ workflow_executions, count, limit, offset }) => {
|
||||
* console.log(workflow_executions)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/admin#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
queryParams?: HttpTypes.AdminGetWorkflowExecutionsParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -27,6 +74,21 @@ export class WorkflowExecution {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a workflow execution by its ID. It sends a request to the
|
||||
* [Get Workflow Execution](https://docs.medusajs.com/api/admin#workflows-executions_getworkflowsexecutionsworkflow_idtransaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The ID of the workflow execution to retrieve.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The workflow execution's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.workflowExecution.retrieve("wrk_123")
|
||||
* .then(({ workflow_execution }) => {
|
||||
* console.log(workflow_execution)
|
||||
* })
|
||||
*/
|
||||
async retrieve(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminWorkflowExecutionResponse>(
|
||||
`/admin/workflows-executions/${id}`,
|
||||
|
||||
Reference in New Issue
Block a user