chore: fixes to JS SDK TSDocs (#12159)
This commit is contained in:
1 parent
cd66cdd2bb
commit
90f9149735
4 files changed
+46
-72
No files matched your search
@@ -700,7 +700,7 @@ export class Claim {
|
||||
* @returns The details of the claim, with a preview of the order when the claim is applied.
|
||||
*
|
||||
* @example
|
||||
* * sdk.admin.claim.addOutboundShipping(
|
||||
* sdk.admin.claim.addOutboundShipping(
|
||||
* "claim_123",
|
||||
* {
|
||||
* shipping_option_id: "so_123",
|
||||
|
||||
@@ -130,9 +130,6 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To create a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.create({
|
||||
* email: "test@test.com",
|
||||
* items: [
|
||||
@@ -147,7 +144,6 @@ export class DraftOrder {
|
||||
* .then(({ draft_order }) => {
|
||||
* console.log(draft_order)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateDraftOrder,
|
||||
@@ -175,16 +171,12 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To update a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.update("order_123", {
|
||||
* email: "test@test.com",
|
||||
* })
|
||||
* .then(({ draft_order }) => {
|
||||
* console.log(draft_order)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async update(
|
||||
id: string,
|
||||
@@ -212,9 +204,6 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To convert a draft order to an order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.convertToOrder("order_123")
|
||||
* .then(({ order }) => {
|
||||
* console.log(order)
|
||||
@@ -244,9 +233,6 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To add items to a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.addItems("order_123", {
|
||||
* items: [
|
||||
* {
|
||||
@@ -258,7 +244,6 @@ export class DraftOrder {
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async addItems(
|
||||
id: string,
|
||||
@@ -285,16 +270,12 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To update an item that is part of an action in a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.updateActionItem("order_123", "action_123", {
|
||||
* quantity: 2,
|
||||
* })
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async updateActionItem(
|
||||
id: string,
|
||||
@@ -321,14 +302,10 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To remove an item that is part of an action in a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.removeActionItem("order_123", "action_123")
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async removeActionItem(
|
||||
id: string,
|
||||
@@ -352,18 +329,15 @@ export class DraftOrder {
|
||||
* @param itemId - The item ID.
|
||||
* @param body - The data to update the item.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The draft order preview's details.
|
||||
*
|
||||
* @example
|
||||
* To update an item in a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.updateItem("order_123", "item_123", {
|
||||
* quantity: 2,
|
||||
* })
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async updateItem(
|
||||
id: string,
|
||||
@@ -390,16 +364,12 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To add promotions to a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.addPromotions("order_123", {
|
||||
* promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"],
|
||||
* })
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async addPromotions(
|
||||
id: string,
|
||||
@@ -425,13 +395,9 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To remove promotions from a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.removePromotions("order_123", {
|
||||
* promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"],
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async removePromotions(
|
||||
id: string,
|
||||
@@ -457,16 +423,12 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To add a shipping method to a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.addShippingMethod("order_123", {
|
||||
* shipping_option_id: "shipping_option_123",
|
||||
* })
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async addShippingMethod(
|
||||
id: string,
|
||||
@@ -493,16 +455,12 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To update a shipping method in a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.updateShippingMethod("order_123", "action_123", {
|
||||
* shipping_option_id: "shipping_option_123",
|
||||
* })
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async updateActionShippingMethod(
|
||||
id: string,
|
||||
@@ -529,14 +487,10 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To remove a shipping method from a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.removeShippingMethod("order_123", "action_123")
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async removeActionShippingMethod(
|
||||
id: string,
|
||||
@@ -552,6 +506,24 @@ export class DraftOrder {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates a shipping method in a draft order. It sends a request to the
|
||||
* [Update Draft Order Shipping Method](https://docs.medusajs.com/api/admin#draft-orders_postordereditsidshipping-methodsaction_id) API route.
|
||||
*
|
||||
* @param id - The draft order's ID.
|
||||
* @param methodId - The shipping method's ID.
|
||||
* @param body - The data to update the shipping method.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The draft order preview's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.draftOrder.updateShippingMethod("order_123", "sm_123", {
|
||||
* shipping_option_id: "so_123",
|
||||
* })
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
*/
|
||||
async updateShippingMethod(
|
||||
id: string,
|
||||
methodId: string,
|
||||
@@ -575,14 +547,10 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To begin an edit to a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.beginEdit("order_123")
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async beginEdit(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminDraftOrderPreviewResponse>(
|
||||
@@ -602,14 +570,10 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To cancel an edit to a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.cancelEdit("order_123")
|
||||
* .then(({ id, object, deleted }) => {
|
||||
* console.log(id, object, deleted)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async cancelEdit(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<
|
||||
@@ -628,14 +592,10 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To request an edit to a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.requestEdit("order_123")
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async requestEdit(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminDraftOrderPreviewResponse>(
|
||||
@@ -655,14 +615,10 @@ export class DraftOrder {
|
||||
* @param headers - Headers to pass in the request.
|
||||
*
|
||||
* @example
|
||||
* To confirm an edit to a draft order:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.draftOrder.confirmEdit("order_123")
|
||||
* .then(({ draft_order_preview }) => {
|
||||
* console.log(draft_order_preview)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async confirmEdit(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminDraftOrderPreviewResponse>(
|
||||
|
||||
@@ -32,25 +32,20 @@ export class Invite {
|
||||
* @returns The user's details.
|
||||
*
|
||||
* @example
|
||||
* const token = await sdk.auth.register("user", "emailpass", {
|
||||
* await sdk.auth.register("user", "emailpass", {
|
||||
* email: "user@gmail.com",
|
||||
* password: "supersecret"
|
||||
* })
|
||||
*
|
||||
* sdk.admin.invite.accept(
|
||||
* // all subsequent requests will use the token in the header
|
||||
* const { user } = await sdk.admin.invite.accept(
|
||||
* {
|
||||
* email: "user@gmail.com",
|
||||
* first_name: "John",
|
||||
* last_name: "Smith",
|
||||
* invite_token: "12345..."
|
||||
* },
|
||||
* {
|
||||
* Authorization: `Bearer ${token}`
|
||||
* }
|
||||
* )
|
||||
* .then(({ user }) => {
|
||||
* console.log(user)
|
||||
* })
|
||||
*/
|
||||
async accept(
|
||||
input: HttpTypes.AdminAcceptInvite & {
|
||||
|
||||
@@ -501,6 +501,29 @@ export class Order {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a credit line for an order. It sends a request to the
|
||||
* [Create Credit Line](https://docs.medusajs.com/api/admin#orders_postordersidcredit-lines) API route.
|
||||
*
|
||||
* @param orderId - The order's ID.
|
||||
* @param body - The credit line's details.
|
||||
* @param query - Configure the fields to retrieve in the order.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The order's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.order.createCreditLine(
|
||||
* "order_123",
|
||||
* {
|
||||
* amount: 100,
|
||||
* reference: "order",
|
||||
* reference_id: "order_123",
|
||||
* }
|
||||
* )
|
||||
* .then(({ order }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
*/
|
||||
async createCreditLine(
|
||||
orderId: string,
|
||||
body: Omit<CreateOrderCreditLineDTO, "order_id">,
|
||||
|
||||
Reference in new issue
Block a user