diff --git a/packages/core/js-sdk/src/admin/customer-group.ts b/packages/core/js-sdk/src/admin/customer-group.ts index 2f9fa17223c54..b797cb7b8052a 100644 --- a/packages/core/js-sdk/src/admin/customer-group.ts +++ b/packages/core/js-sdk/src/admin/customer-group.ts @@ -14,6 +14,38 @@ export class CustomerGroup { this.client = client } + /** + * This method retrieves a customer group by its ID. It sends a request to the + * [Get Customer Group](https://docs.medusajs.com/v2/api/admin#customer-groups_getcustomergroupsid) API route. + * + * @param id - The customer group's ID. + * @param query - Configure the fields to retrieve in the customer group. + * @param headers - Headers to pass in the request + * @returns The group's details. + * + * @example + * To retrieve a customer group by its ID: + * + * ```ts + * sdk.admin.customerGroup.retrieve("cusgroup_123") + * .then(({ customer_group }) => { + * console.log(customer_group) + * }) + * ``` + * + * To specify the fields and relations to retrieve: + * + * ```ts + * sdk.admin.customerGroup.retrieve("cusgroup_123", { + * fields: "id,*customer" + * }) + * .then(({ customer_group }) => { + * console.log(customer_group) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async retrieve( id: string, query?: HttpTypes.AdminGetCustomerGroupParams, @@ -29,6 +61,53 @@ export class CustomerGroup { ) } + /** + * This method retrieves a paginated list of customer groups. It sends a request to the + * [List Customer Groups](https://docs.medusajs.com/v2/api/admin#customer-groups_getcustomergroups) + * API route. + * + * @param query - Filters and pagination configurations. + * @param headers - Headers to pass in the request. + * @returns The paginated list of customer groups. + * + * @example + * To retrieve the list of customer groups: + * + * ```ts + * sdk.admin.customerGroup.list() + * .then(({ customer_groups, count, limit, offset }) => { + * console.log(customer_groups) + * }) + * ``` + * + * 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.customerGroup.list({ + * limit: 10, + * offset: 10 + * }) + * .then(({ customer_groups, count, limit, offset }) => { + * console.log(customer_groups) + * }) + * ``` + * + * Using the `fields` query parameter, you can specify the fields and relations to retrieve + * in each customer group: + * + * ```ts + * sdk.admin.customerGroup.list({ + * fields: "id,*customer" + * }) + * .then(({ customer_groups, count, limit, offset }) => { + * console.log(customer_groups) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async list( query?: HttpTypes.AdminGetCustomerGroupsParams, headers?: ClientHeaders @@ -43,9 +122,27 @@ export class CustomerGroup { ) } + /** + * This method creates a customer group. It sends a request to the + * [Create Customer Group](https://docs.medusajs.com/v2/api/admin#customer-groups_postcustomergroups) + * API route. + * + * @param body - The customer group's details. + * @param query - Configure the fields to retrieve in the customer group. + * @param headers - Headers to pass in the request. + * @returns The customer group's details. + * + * @example + * sdk.admin.customerGroup.create({ + * name: "VIP" + * }) + * .then(({ customer_group }) => { + * console.log(customer_group) + * }) + */ async create( body: HttpTypes.AdminCreateCustomerGroup, - query?: HttpTypes.AdminGetCustomerGroupsParams, + query?: HttpTypes.AdminGetCustomerGroupParams, headers?: ClientHeaders ) { return await this.client.fetch( @@ -59,10 +156,29 @@ export class CustomerGroup { ) } + /** + * This method updates a customer group's details. It sends a request to the + * [Update Customer](https://docs.medusajs.com/v2/api/admin#customer-groups_postcustomergroupsid) + * API route. + * + * @param id - The customer group's ID. + * @param body - The details to update in the group. + * @param query - Configure the fields to retrieve in the customer group. + * @param headers - Headers to pass in the request. + * @returns The customer group's details. + * + * @example + * sdk.admin.customerGroup.update("cusgroup_123", { + * name: "VIP" + * }) + * .then(({ customer_group }) => { + * console.log(customer_group) + * }) + */ async update( id: string, body: HttpTypes.AdminUpdateCustomerGroup, - query?: HttpTypes.AdminGetCustomerGroupsParams, + query?: HttpTypes.AdminGetCustomerGroupParams, headers?: ClientHeaders ) { return await this.client.fetch( @@ -76,6 +192,21 @@ export class CustomerGroup { ) } + /** + * This method deletes a customer group. This method sends a request to the + * [Delete Customer Group](https://docs.medusajs.com/v2/api/admin#customer-groups_deletecustomergroupsid) + * API route. + * + * @param id - The customer group's ID. + * @param headers - Headers to pass in the request + * @returns The deletion's details. + * + * @example + * sdk.admin.customerGroup.delete("cusgroup_123") + * .then(({ deleted }) => { + * console.log(deleted) + * }) + */ async delete(id: string, headers?: ClientHeaders) { return await this.client.fetch( `/admin/customer-groups/${id}`, @@ -86,6 +217,25 @@ export class CustomerGroup { ) } + /** + * This method manages customers of a group to add or remove them from the group. + * It sends a request to the [Manage Customers](https://docs.medusajs.com/v2/api/admin#customer-groups_postcustomergroupsidcustomers) + * API route. + * + * @param id - The group's ID. + * @param body - The customers to add or remove from the group. + * @param headers - Headers to pass in the request + * @returns The customer group's details. + * + * @example + * sdk.admin.customerGroup.batchCustomers("cusgroup_123", { + * add: ["cus_123"], + * remove: ["cus_321"] + * }) + * .then(({ customer_group }) => { + * console.log(customer_group) + * }) + */ async batchCustomers( id: string, body: HttpTypes.AdminBatchLink, diff --git a/packages/core/js-sdk/src/admin/customer.ts b/packages/core/js-sdk/src/admin/customer.ts index 0c657ab1508d3..36174e7471e79 100644 --- a/packages/core/js-sdk/src/admin/customer.ts +++ b/packages/core/js-sdk/src/admin/customer.ts @@ -1,7 +1,5 @@ import { - FindParams, HttpTypes, - PaginatedResponse, SelectParams, } from "@medusajs/types" import { Client } from "../client" @@ -19,14 +17,31 @@ export class Customer { this.client = client } + /** + * This method creates a customer. It sends a request to the + * [Create Customer](https://docs.medusajs.com/v2/api/admin#customers_postcustomers) API route. + * + * @param body - The customer's details. + * @param query - Configure the fields to retrieve in the customer. + * @param headers - Headers to pass in the request. + * @returns The customer's details. + * + * @example + * sdk.admin.customer.create({ + * email: "customer@gmail.com" + * }) + * .then(({ customer }) => { + * console.log(customer) + * }) + */ async create( body: HttpTypes.AdminCreateCustomer, query?: SelectParams, headers?: ClientHeaders ) { - return this.client.fetch<{ - customer: HttpTypes.AdminCustomer - }>(`/admin/customers`, { + return this.client.fetch< + HttpTypes.AdminCustomerResponse + >(`/admin/customers`, { method: "POST", headers, body, @@ -34,13 +49,31 @@ export class Customer { }) } + /** + * This method updates a customer's details. It sends a request to the + * [Update Customer](https://docs.medusajs.com/v2/api/admin#customers_postcustomersid) API route. + * + * @param id - The customer's ID. + * @param body - The details to update of the customer. + * @param query - Configure the fields to retrieve in the customer. + * @param headers - Headers to pass in the request. + * @returns The customer's details. + * + * @example + * sdk.admin.customer.update("cus_123", { + * first_name: "John" + * }) + * .then(({ customer }) => { + * console.log(customer) + * }) + */ async update( id: string, body: HttpTypes.AdminUpdateCustomer, query?: SelectParams, headers?: ClientHeaders ) { - return this.client.fetch<{ customer: HttpTypes.AdminCustomer }>( + return this.client.fetch( `/admin/customers/${id}`, { method: "POST", @@ -51,20 +84,100 @@ export class Customer { ) } + /** + * This method retrieves a paginated list of customers. It sends a request to the + * [List Customers](https://docs.medusajs.com/v2/api/admin#customers_getcustomers) + * API route. + * + * @param queryParams - Filters and pagination configurations. + * @param headers - Headers to pass in the request. + * @returns The paginated list of customers. + * + * @example + * To retrieve the list of customers: + * + * ```ts + * sdk.admin.customer.list() + * .then(({ customers, count, limit, offset }) => { + * console.log(customers) + * }) + * ``` + * + * 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.customer.list({ + * limit: 10, + * offset: 10 + * }) + * .then(({ customers, count, limit, offset }) => { + * console.log(customers) + * }) + * ``` + * + * Using the `fields` query parameter, you can specify the fields and relations to retrieve + * in each customer: + * + * ```ts + * sdk.admin.customer.list({ + * fields: "id,*groups" + * }) + * .then(({ customers, count, limit, offset }) => { + * console.log(customers) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async list( - queryParams?: FindParams & HttpTypes.AdminCustomerFilters, + queryParams?: HttpTypes.AdminCustomerFilters, headers?: ClientHeaders ) { return this.client.fetch< - PaginatedResponse<{ customers: HttpTypes.AdminCustomer[] }> + HttpTypes.AdminCustomerListResponse >(`/admin/customers`, { headers, query: queryParams, }) } + /** + * This method retrieves a customer by its ID. It sends a request to the + * [Get Customer](https://docs.medusajs.com/v2/api/admin#customers_getcustomersid) + * API route. + * + * @param id - The customer's ID. + * @param query - Configure the fields to retrieve in the customer. + * @param headers - Headers to pass in the request. + * @returns The customer's details. + * + * @example + * To retrieve a customer by its ID: + * + * ```ts + * sdk.admin.customer.retrieve("cus_123") + * .then(({ customer }) => { + * console.log(customer) + * }) + * ``` + * + * To specify the fields and relations to retrieve: + * + * ```ts + * sdk.admin.customer.retrieve("cus_123", { + * fields: "id,*groups" + * }) + * .then(({ customer }) => { + * console.log(customer) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) { - return this.client.fetch<{ customer: HttpTypes.AdminCustomer }>( + return this.client.fetch( `/admin/customers/${id}`, { query, @@ -73,6 +186,21 @@ export class Customer { ) } + /** + * This method deletes a customer by its ID. It sends a request to the + * [Delete Customer](https://docs.medusajs.com/v2/api/admin#customers_deletecustomersid) + * API route. + * + * @param id - The customer's ID. + * @param headers - Headers to pass in the request. + * @returns The deletion's details. + * + * @example + * sdk.admin.customer.delete("cus_123") + * .then(({ deleted }) => { + * console.log(deleted) + * }) + */ async delete(id: string, headers?: ClientHeaders) { return this.client.fetch( `/admin/customers/${id}`, diff --git a/packages/core/js-sdk/src/admin/exchange.ts b/packages/core/js-sdk/src/admin/exchange.ts index 151f720062e3a..69c5b5323d4b1 100644 --- a/packages/core/js-sdk/src/admin/exchange.ts +++ b/packages/core/js-sdk/src/admin/exchange.ts @@ -1,4 +1,4 @@ -import { HttpTypes } from "@medusajs/types" +import { HttpTypes, SelectParams } from "@medusajs/types" import { Client } from "../client" import { ClientHeaders } from "../types" @@ -15,6 +15,53 @@ export class Exchange { this.client = client } + /** + * This method retrieves a paginated list of exchanges. It sends a request to the + * [List Exchanges](https://docs.medusajs.com/v2/api/admin#exchanges_getexchanges) + * API route. + * + * @param query - Filters and pagination configurations. + * @param headers - Headers to pass in the request. + * @returns The paginated list of exchanges. + * + * @example + * To retrieve the list of exchanges: + * + * ```ts + * sdk.admin.exchange.list() + * .then(({ exchanges, count, limit, offset }) => { + * console.log(exchanges) + * }) + * ``` + * + * 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.exchange.list({ + * limit: 10, + * offset: 10 + * }) + * .then(({ exchanges, count, limit, offset }) => { + * console.log(exchanges) + * }) + * ``` + * + * Using the `fields` query parameter, you can specify the fields and relations to retrieve + * in each exchange: + * + * ```ts + * sdk.admin.exchange.list({ + * fields: "id,*order" + * }) + * .then(({ exchanges, count, limit, offset }) => { + * console.log(exchanges) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async list( query?: HttpTypes.AdminExchangeListParams, headers?: ClientHeaders @@ -28,9 +75,42 @@ export class Exchange { ) } + /** + * This method retrieves an exchange by its ID. It sends a request to the + * [Get Exchange](https://docs.medusajs.com/v2/api/admin#exchanges_getexchangesid) + * API route. + * + * @param id - The exchange's ID. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request. + * @returns The exchange's details. + * + * @example + * To retrieve an exchange by its ID: + * + * ```ts + * sdk.admin.exchange.retrieve("exchange_123") + * .then(({ exchange }) => { + * console.log(exchange) + * }) + * ``` + * + * To specify the fields and relations to retrieve: + * + * ```ts + * sdk.admin.exchange.retrieve("exchange_123", { + * fields: "id,*order" + * }) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async retrieve( id: string, - query?: HttpTypes.AdminExchangeParams, + query?: SelectParams, headers?: ClientHeaders ) { return await this.client.fetch( @@ -42,6 +122,23 @@ export class Exchange { ) } + /** + * This method creates an admin exchange. It sends a request to the + * [Create Exchange](https://docs.medusajs.com/v2/api/admin#exchanges_postexchanges) API route. + * + * @param body - The exchange's details. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request. + * @returns The exchange's details. + * + * @example + * sdk.admin.exchange.create({ + * order_id: "order_123" + * }) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async create( body: HttpTypes.AdminCreateExchange, query?: HttpTypes.SelectParams, @@ -58,6 +155,21 @@ export class Exchange { ) } + /** + * This method cancels an exchange. It sends a request to the + * [Cancel Exchange](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidcancel) API route. + * + * @param id - The exchange's ID. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request. + * @returns The exchange's details. + * + * @example + * sdk.admin.exchange.cancel("exchange_123") + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async cancel( id: string, query?: HttpTypes.SelectParams, @@ -73,13 +185,37 @@ export class Exchange { ) } + /** + * This method adds inbound (or return) items to an exchange. These inbound items will + * have the action `RETURN_ITEM`. + * + * This method sends a request to the [Add Inbound Items](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidinbounditems) + * API route. + * + * @param id - The exchange's ID. + * @param body - The items to add. + * @param query - Configure the fields to retrieve in the return. + * @param headers - Headers to pass in the request. + * @returns The details of the return associated with the exchange, with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.addInboundItems("exchange_123", { + * items: [{ + * id: "orli_123", + * quantity: 1 + * }] + * }) + * .then(({ return: returnData }) => { + * console.log(returnData) + * }) + */ async addInboundItems( id: string, body: HttpTypes.AdminAddExchangeInboundItems, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/inbound/items`, { method: "POST", @@ -90,6 +226,35 @@ export class Exchange { ) } + /** + * This method updates an inbound (or return) item from an exchange using 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. + * + * This method sends a request to the [Update Inbound Item](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidinbounditemsaction_id) + * API route. + * + * @param id - The exchange's ID. + * @param actionId - The id of the return item's `RETURN_ITEM` action. + * @param body - The details to update. + * @param query - Configure the fields to retrieve in the return. + * @param headers - Headers to pass in the request. + * @returns The details of the return associated with the exchange, with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.updateInboundItem( + * "exchange_123", + * "ordchact_123", + * { + * quantity: 1 + * } + * ) + * .then(({ return: returnData }) => { + * console.log(returnData) + * }) + */ async updateInboundItem( id: string, actionId: string, @@ -97,7 +262,7 @@ export class Exchange { query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/inbound/items/${actionId}`, { method: "POST", @@ -108,13 +273,38 @@ export class Exchange { ) } + /** + * This method removes an inbound (or return) item from an exchange using 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. + * + * This method sends a request to the [Remove Inbound Item](https://docs.medusajs.com/v2/api/admin#exchanges_deleteexchangesidinbounditemsaction_id) + * API route. + * + * @param id - The exchange's ID. + * @param actionId - The id of the return item's `RETURN_ITEM` action. + * @param query - Configure the fields to retrieve in the return. + * @param headers - Headers to pass in the request. + * @returns The details of the return associated with the exchange, with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.removeInboundItem( + * "exchange_123", + * "ordchact_123", + * ) + * .then(({ return: returnData }) => { + * console.log(returnData) + * }) + */ async removeInboundItem( id: string, actionId: string, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/inbound/items/${actionId}`, { method: "DELETE", @@ -124,13 +314,37 @@ export class Exchange { ) } + /** + * This method adds an inbound (or return) shipping method to an exchange. + * The inbound shipping method will have a `SHIPPING_ADD` action. + * + * This method sends a request to the [Add Inbound Shipping](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidinboundshippingmethod) + * API route. + * + * This method sends a request to the [Add Inbound Shipping](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidinboundshippingmethod) + * API route. + * + * @param id - The exchange's ID. + * @param body - The shipping method's details. + * @param query - Configure the fields to retrieve in the return. + * @param headers - Headers to pass in the request. + * @returns The details of the return associated with the exchange, with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.addInboundShipping("exchange_123", { + * shipping_option_id: "so_123" + * }) + * .then(({ return: returnData }) => { + * console.log(returnData) + * }) + */ async addInboundShipping( id: string, body: HttpTypes.AdminExchangeAddInboundShipping, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/inbound/shipping-method`, { method: "POST", @@ -141,6 +355,35 @@ export class Exchange { ) } + /** + * This method updates the shipping method for returning items in the exchange using the ID + * of the 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. + * + * This method sends a request to the [Update Inbound Shipping](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidinboundshippingmethodaction_id) + * API route. + * + * @param id - The exchange's ID. + * @param actionId - The id of the shipping method's `SHIPPING_ADD` action. + * @param body - The details to update. + * @param query - Configure the fields to retrieve in the return. + * @param headers - Headers to pass in the request. + * @returns The details of the return associated with the exchange, with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.updateInboundShipping( + * "exchange_123", + * "ordchact_123", + * { + * custom_amount: 10 + * } + * ) + * .then(({ return: returnData }) => { + * console.log(returnData) + * }) + */ async updateInboundShipping( id: string, actionId: string, @@ -148,7 +391,7 @@ export class Exchange { query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/inbound/shipping-method/${actionId}`, { method: "POST", @@ -159,13 +402,38 @@ export class Exchange { ) } + /** + * This method removes the shipping method for returning items in the exchange using the ID + * of the 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. + * + * This method sends a request to the [Remove Inbound Shipping](https://docs.medusajs.com/v2/api/admin#exchanges_deleteexchangesidinboundshippingmethodaction_id) + * API route. + * + * @param id - The exchange's ID. + * @param actionId - The id of the shipping method's `SHIPPING_ADD` action. + * @param query - Configure the fields to retrieve in the return. + * @param headers - Headers to pass in the request. + * @returns The details of the return associated with the exchange, with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.deleteInboundShipping( + * "exchange_123", + * "ordchact_123", + * ) + * .then(({ return: returnData }) => { + * console.log(returnData) + * }) + */ async deleteInboundShipping( id: string, actionId: string, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/inbound/shipping-method/${actionId}`, { method: "DELETE", @@ -175,13 +443,37 @@ export class Exchange { ) } + /** + * This method adds outbound (or new) items to an exchange. + * These outbound items will have the action `ITEM_ADD`. + * + * This method sends a request to the [Add Outbound Items](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidoutbounditems) + * API route. + * + * @param id - The exchange's ID. + * @param body - The items to add. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request + * @returns The exchange's details with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.addOutboundItems("exchange_123", { + * items: [{ + * id: "variant_123", + * quantity: 1 + * }] + * }) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async addOutboundItems( id: string, body: HttpTypes.AdminAddExchangeOutboundItems, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/outbound/items`, { method: "POST", @@ -192,6 +484,35 @@ export class Exchange { ) } + /** + * This method updates an outbound (or new) item from an exchange using the ID + * of the item's `ITEM_ADD` 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. + * + * This method sends a request to the [Update Inbound Item](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidoutbounditemsaction_id) + * API route. + * + * @param id - The exchange's ID. + * @param actionId - The id of the new exchange item's `ITEM_ADD` action. + * @param body - The item's details to update. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request + * @returns The exchange's details with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.updateOutboundItem( + * "exchange_123", + * "ordchact_123", + * { + * quantity: 1 + * } + * ) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async updateOutboundItem( id: string, actionId: string, @@ -199,7 +520,7 @@ export class Exchange { query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/outbound/items/${actionId}`, { method: "POST", @@ -210,13 +531,38 @@ export class Exchange { ) } + /** + * This method removes an outbound (or new) item from an exchange using the ID + * of the item's `ITEM_ADD` 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. + * + * This method sends a request to the [Update Outbound Item](https://docs.medusajs.com/v2/api/admin#exchanges_deleteexchangesidoutbounditemsaction_id) + * API route. + * + * @param id - The exchange's ID. + * @param actionId - The id of the new exchange item's `ITEM_ADD` action. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request + * @returns The exchange's details with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.removeOutboundItem( + * "exchange_123", + * "ordchact_123", + * ) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async removeOutboundItem( id: string, actionId: string, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/outbound/items/${actionId}`, { method: "DELETE", @@ -226,13 +572,34 @@ export class Exchange { ) } + /** + * This method adds an outbound shipping method to an exchange. The outbound shipping method + * will have a `SHIPPING_ADD` action. + * + * This method sends a request to the [Add Outbound Shipping](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidoutboundshippingmethod) + * API route. + * + * @param id - The exchange's ID. + * @param body - The shipping method's details. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request + * @returns The exchange's details with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.addOutboundShipping("exchange_123", { + * shipping_option_id: "so_123" + * }) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async addOutboundShipping( id: string, body: HttpTypes.AdminExchangeAddOutboundShipping, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/outbound/shipping-method`, { method: "POST", @@ -243,6 +610,35 @@ export class Exchange { ) } + /** + * This method updates the shipping method for delivering outbound items in the exchange using + * the ID of the 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. + * + * This method sends a request to the [Update Outbound Shipping](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidoutboundshippingmethodaction_id) + * API route. + * + * @param id - The exchange's ID. + * @param actionId - The id of the shipping method's `SHIPPING_ADD` action. + * @param body - The details to update. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request + * @returns The exchange's details with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.updateOutboundShipping( + * "exchange_123", + * "ordchact_123", + * { + * custom_amount: 10 + * } + * ) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async updateOutboundShipping( id: string, actionId: string, @@ -250,7 +646,7 @@ export class Exchange { query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/outbound/shipping-method/${actionId}`, { method: "POST", @@ -261,13 +657,38 @@ export class Exchange { ) } + /** + * This method removes the shipping method for delivering outbound items in the exchange using + * the ID of the 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. + * + * This method sends a request to the [Remove Outbound Shipping](https://docs.medusajs.com/v2/api/admin#exchanges_deleteexchangesidoutboundshippingmethodaction_id) + * API route. + * + * @param id - The exchange's ID. + * @param actionId - The id of the shipping method's `SHIPPING_ADD` action. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request + * @returns The exchange's details with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.deleteOutboundShipping( + * "exchange_123", + * "ordchact_123", + * ) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async deleteOutboundShipping( id: string, actionId: string, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/outbound/shipping-method/${actionId}`, { method: "DELETE", @@ -277,13 +698,31 @@ export class Exchange { ) } + /** + * This method confirms an exchange request, applying its changes on the associated order. + * + * This method sends a request to the [Confirm Exchange](https://docs.medusajs.com/v2/api/admin#exchanges_postexchangesidrequest) + * API route. + * + * @param id - The exchange's ID. + * @param body - The confirmation's details. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request + * @returns The exchange and associated return's details with a preview of the order when the exchange is applied. + * + * @example + * sdk.admin.exchange.request("exchange_123", {}) + * .then(({ exchange }) => { + * console.log(exchange) + * }) + */ async request( id: string, body: HttpTypes.AdminRequestExchange, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/request`, { method: "POST", @@ -294,12 +733,28 @@ export class Exchange { ) } + /** + * This method cancels an exchange request. It sends a request to the + * [Cancel Exchange Request](https://docs.medusajs.com/v2/api/admin#exchanges_deleteexchangesidrequest) + * API route. + * + * @param id - The exchange's ID. + * @param query - Configure the fields to retrieve in the exchange. + * @param headers - Headers to pass in the request + * @returns The cancelation's details. + * + * @example + * sdk.admin.exchange.cancel("exchange_123") + * .then(({ deleted }) => { + * console.log(deleted) + * }) + */ async cancelRequest( id: string, query?: HttpTypes.SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch( + return await this.client.fetch( `/admin/exchanges/${id}/request`, { method: "DELETE", diff --git a/packages/core/js-sdk/src/admin/fulfillment-provider.ts b/packages/core/js-sdk/src/admin/fulfillment-provider.ts index 906c5f97bd498..9f33e2d5ab8ce 100644 --- a/packages/core/js-sdk/src/admin/fulfillment-provider.ts +++ b/packages/core/js-sdk/src/admin/fulfillment-provider.ts @@ -14,6 +14,53 @@ export class FulfillmentProvider { this.client = client } + /** + * This method retrieves a paginated list of fulfillment providers. It sends a request to the + * [List Fulfillment Providers](https://docs.medusajs.com/v2/api/admin#fulfillment-providers_getfulfillmentproviders) + * API route. + * + * @param query - Filters and pagination configurations. + * @param headers - Headers to pass in the request. + * @returns The paginated list of providers. + * + * @example + * To retrieve the list of fulfillment providers: + * + * ```ts + * sdk.admin.fulfillmentProvider.list() + * .then(({ fulfillment_providers, count, limit, offset }) => { + * console.log(fulfillment_providers) + * }) + * ``` + * + * 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.fulfillmentProvider.list({ + * limit: 10, + * offset: 10 + * }) + * .then(({ fulfillment_providers, count, limit, offset }) => { + * console.log(fulfillment_providers) + * }) + * ``` + * + * Using the `fields` query parameter, you can specify the fields and relations to retrieve + * in each fulfillment provider: + * + * ```ts + * sdk.admin.fulfillmentProvider.list({ + * fields: "id" + * }) + * .then(({ fulfillment_providers, count, limit, offset }) => { + * console.log(fulfillment_providers) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async list( query?: HttpTypes.AdminFulfillmentProviderListParams, headers?: ClientHeaders diff --git a/packages/core/types/src/http/customer-group/admin/entities.ts b/packages/core/types/src/http/customer-group/admin/entities.ts index a47270f877bd6..6bee178aabbad 100644 --- a/packages/core/types/src/http/customer-group/admin/entities.ts +++ b/packages/core/types/src/http/customer-group/admin/entities.ts @@ -2,5 +2,8 @@ import { AdminCustomer } from "../../customer/admin" import { BaseCustomerGroup } from "../common" export interface AdminCustomerGroup extends BaseCustomerGroup { + /** + * The customers in the group. + */ customers: AdminCustomer[] } diff --git a/packages/core/types/src/http/customer-group/admin/payloads.ts b/packages/core/types/src/http/customer-group/admin/payloads.ts index ab837ca7e687b..2baef67980761 100644 --- a/packages/core/types/src/http/customer-group/admin/payloads.ts +++ b/packages/core/types/src/http/customer-group/admin/payloads.ts @@ -1,9 +1,21 @@ export interface AdminCreateCustomerGroup { + /** + * The customer group's name. + */ name: string + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } export interface AdminUpdateCustomerGroup { + /** + * The customer group's name. + */ name?: string + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } diff --git a/packages/core/types/src/http/customer-group/admin/queries.ts b/packages/core/types/src/http/customer-group/admin/queries.ts index 46b0907eee146..1bda3a4348c1e 100644 --- a/packages/core/types/src/http/customer-group/admin/queries.ts +++ b/packages/core/types/src/http/customer-group/admin/queries.ts @@ -2,34 +2,89 @@ import { BaseFilterable, OperatorMap } from "../../../dal" import { FindParams, SelectParams } from "../../common" export interface AdminCustomerInGroupFilters { + /** + * Filter by customer ID(s). + */ id?: string | string[] + /** + * Filter by email(s). + */ email?: string | string[] | OperatorMap + /** + * Filter by IDs of default billing addresses to retrieve + * their associated customers. + */ default_billing_address_id?: string | string[] + /** + * Filter by IDs of default shipping addresses to retrieve + * their associated customers. + */ default_shipping_address_id?: string | string[] + /** + * Filter by company name(s). + */ company_name?: string | string[] + /** + * Filter by first name(s). + */ first_name?: string | string[] + /** + * Filter by last name(s). + */ last_name?: string | string[] + /** + * Filter by user IDs to retrieve the customers they created. + */ created_by?: string | string[] + /** + * Apply filters on the customer's creation date. + */ created_at?: OperatorMap + /** + * Apply filters on the customer's update date. + */ updated_at?: OperatorMap + /** + * Apply filters on the customer's deletion date. + */ deleted_at?: OperatorMap } export interface AdminGetCustomerGroupsParams extends FindParams, BaseFilterable { - limit?: number - offset?: number + /** + * Query or keywords to search the customer group's searchable fields. + */ q?: string + /** + * Filter by customer group ID(s). + */ id?: string | string[] + /** + * Filter by name(s). + */ name?: string | string[] + /** + * Filter by customers to retrieve their associated groups. + */ customers?: string | string[] | AdminCustomerInGroupFilters + /** + * Filter by IDs of users to retrieve the groups they created. + */ created_by?: string | string[] + /** + * Apply filters on the group's creation date. + */ created_at?: OperatorMap + /** + * Apply filters on the group's update date. + */ updated_at?: OperatorMap + /** + * Apply filters on the group's deletion date. + */ deleted_at?: OperatorMap - $and?: AdminGetCustomerGroupsParams[] - $or?: AdminGetCustomerGroupsParams[] } export interface AdminGetCustomerGroupParams extends SelectParams {} diff --git a/packages/core/types/src/http/customer-group/admin/responses.ts b/packages/core/types/src/http/customer-group/admin/responses.ts index 586eb02e3a08d..ffcbb51e074c9 100644 --- a/packages/core/types/src/http/customer-group/admin/responses.ts +++ b/packages/core/types/src/http/customer-group/admin/responses.ts @@ -2,9 +2,15 @@ import { PaginatedResponse } from "../../common" import { AdminCustomerGroup } from "./entities" export interface AdminCustomerGroupResponse { + /** + * The customer group's details. + */ customer_group: AdminCustomerGroup } export type AdminCustomerGroupListResponse = PaginatedResponse<{ + /** + * The list of customer groups. + */ customer_groups: AdminCustomerGroup[] }> diff --git a/packages/core/types/src/http/customer-group/common.ts b/packages/core/types/src/http/customer-group/common.ts index 9797711821a1c..fb85f92937472 100644 --- a/packages/core/types/src/http/customer-group/common.ts +++ b/packages/core/types/src/http/customer-group/common.ts @@ -1,10 +1,28 @@ import { BaseCustomer } from "../customer/common" export interface BaseCustomerGroup { + /** + * The customer group's ID. + */ id: string + /** + * The customer group's name. + */ name: string | null + /** + * The customers in the group. + */ customers: BaseCustomer[] + /** + * Key-value pairs of custom data. + */ metadata: Record | null + /** + * The date the customer group was created. + */ created_at: string + /** + * The date the customer group was updated. + */ updated_at: string } diff --git a/packages/core/types/src/http/customer/admin/entities.ts b/packages/core/types/src/http/customer/admin/entities.ts index c3c25b4e98770..5acd1a5c34052 100644 --- a/packages/core/types/src/http/customer/admin/entities.ts +++ b/packages/core/types/src/http/customer/admin/entities.ts @@ -2,8 +2,17 @@ import { AdminCustomerGroup } from "../../customer-group" import { BaseCustomer, BaseCustomerAddress } from "../common" export interface AdminCustomer extends BaseCustomer { + /** + * Whether the customer is a guest. + */ has_account: boolean + /** + * The groups the customer is in. + */ groups?: AdminCustomerGroup[] + /** + * The customer's addresses. + */ addresses: AdminCustomerAddress[] } export interface AdminCustomerAddress extends BaseCustomerAddress {} diff --git a/packages/core/types/src/http/customer/admin/queries.ts b/packages/core/types/src/http/customer/admin/queries.ts index a05d44e73546f..2aae956cd053a 100644 --- a/packages/core/types/src/http/customer/admin/queries.ts +++ b/packages/core/types/src/http/customer/admin/queries.ts @@ -5,7 +5,13 @@ import { } from "../common" export interface AdminCustomerFilters extends BaseCustomerFilters { + /** + * Apply customer group filters to retrieve their customers. + */ groups?: CustomerGroupInCustomerFilters | string[] | string + /** + * Filter by whether the customer is registered. + */ has_account?: boolean } export interface AdminCustomerAddressFilters diff --git a/packages/core/types/src/http/customer/admin/responses.ts b/packages/core/types/src/http/customer/admin/responses.ts index 2844a27c7c0b5..66b20b6246fe7 100644 --- a/packages/core/types/src/http/customer/admin/responses.ts +++ b/packages/core/types/src/http/customer/admin/responses.ts @@ -6,10 +6,16 @@ import { import { AdminCustomer, AdminCustomerAddress } from "./entities" export interface AdminCustomerResponse { + /** + * The customer's details. + */ customer: AdminCustomer } export type AdminCustomerListResponse = PaginatedResponse<{ + /** + * The list of customers. + */ customers: AdminCustomer[] }> diff --git a/packages/core/types/src/http/customer/common.ts b/packages/core/types/src/http/customer/common.ts index 9264b9ea8ccd0..ac3179a862f7a 100644 --- a/packages/core/types/src/http/customer/common.ts +++ b/packages/core/types/src/http/customer/common.ts @@ -28,7 +28,7 @@ export interface BaseCustomerAddress { */ is_default_billing: boolean /** - * The ID of the customer that the address belongs to. + * The ID of the customer this address belongs to. */ customer_id: string /** @@ -71,7 +71,7 @@ export interface BaseCustomerAddress { */ postal_code: string | null /** - * The address's phone. + * The address's phone number. */ phone: string | null /** @@ -148,25 +148,70 @@ export interface BaseCustomer { } export interface CustomerGroupInCustomerFilters { + /** + * Filter by customer group ID(s). + */ id: string[] | string + /** + * Filter by name(s). + */ name: string[] | string + /** + * Apply filters on the group's creation date. + */ created_at: OperatorMap + /** + * Apply filters on the group's update date. + */ updated_at: OperatorMap + /** + * Apply filters on the group's deletion date. + */ deleted_at: OperatorMap } export interface BaseCustomerFilters extends FindParams, BaseFilterable { + /** + * Query or keywords to apply on the customer's searchable fields. + */ q?: string + /** + * Filter by customer ID(s). + */ id?: string[] | string | OperatorMap + /** + * Filter by email(s). + */ email?: string[] | string | OperatorMap + /** + * Filter by company name(s). + */ company_name?: string[] | string | OperatorMap + /** + * Filter by first name(s). + */ first_name?: string[] | string | OperatorMap + /** + * Filter by last name(s). + */ last_name?: string[] | string | OperatorMap + /** + * Filter by user ID(s) to retrieve the customers they created. + */ created_by?: string[] | string | OperatorMap + /** + * Apply filters on the customer's creation date. + */ created_at?: OperatorMap + /** + * Apply filters on the customer's update date. + */ updated_at?: OperatorMap + /** + * Apply filters on the customer's deletion date. + */ deleted_at?: OperatorMap } @@ -216,7 +261,7 @@ export interface BaseCreateCustomer { */ last_name?: string /** - * The customer's phone. + * The customer's phone number. */ phone?: string /** @@ -239,7 +284,7 @@ export interface BaseUpdateCustomer { */ last_name?: string /** - * The customer's phone. + * The customer's phone number. */ phone?: string /** diff --git a/packages/core/types/src/http/exchange/admin/payloads.ts b/packages/core/types/src/http/exchange/admin/payloads.ts index c28511586ab12..7ce8db8162712 100644 --- a/packages/core/types/src/http/exchange/admin/payloads.ts +++ b/packages/core/types/src/http/exchange/admin/payloads.ts @@ -6,41 +6,108 @@ enum ExchangeReason { } interface AdminExchangeAddItems { + /** + * The items to add to the exchange. + */ items: { + /** + * If you're adding an inbound item, this is the ID of the order item returned. + * If you're adding an outbound item, this is the ID of the variant to add. + */ id: string + /** + * The item's quantity. + */ quantity: number + /** + * The reason the item is being returned / sent to the customer. + */ reason?: ExchangeReason + /** + * The item's description. + */ description?: string + /** + * An internal note viewed by admin users only. + */ internal_note?: string }[] } interface AdminExchangeUpdateItem { + /** + * The item's quantity. + */ quantity?: number + /** + * The ID of the associated return reason. + */ reason_id?: string | null + /** + * The item's description. + */ description?: string + /** + * An internal note viewed by admin users only. + */ internal_note?: string | null } interface AdminExchangeAddShippingMethod { + /** + * The ID of the shipping option the method is created from. + */ shipping_option_id: string + /** + * A custom amount for the shipping method. If not specified, + * the shipping option's amount is used. + */ custom_amount?: number + /** + * The shipping method's description. + */ description?: string + /** + * An internal note viewed by admin users only. + */ internal_note?: string + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } interface AdminExchangeUpdateShippingMethod { + /** + * A custom amount for the shipping method. + */ custom_amount?: number | null + /** + * An internal note viewed by admin users only. + */ internal_note?: string + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } export interface AdminCreateExchange { - type: "refund" | "replace" + /** + * The ID of the order the exchange is created for. + */ order_id: string + /** + * The exchange's description. + */ description?: string + /** + * An internal note viewed by admin users only. + */ internal_note?: string + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } @@ -63,6 +130,9 @@ export interface AdminExchangeUpdateOutboundShipping extends AdminExchangeUpdateShippingMethod {} export interface AdminRequestExchange { + /** + * Whether to send the customer a notification. + */ no_notification?: boolean } diff --git a/packages/core/types/src/http/exchange/admin/queries.ts b/packages/core/types/src/http/exchange/admin/queries.ts index 47373e0528d83..6e403f025a4be 100644 --- a/packages/core/types/src/http/exchange/admin/queries.ts +++ b/packages/core/types/src/http/exchange/admin/queries.ts @@ -1,15 +1,9 @@ -import { BaseFilterable, OperatorMap } from "../../../dal" +import { OperatorMap } from "../../../dal" import { SelectParams } from "../../common" -import { BaseExchangeListParams } from "../common" -export interface AdminExchangeListParams - extends BaseExchangeListParams, - BaseFilterable { - deleted_at?: OperatorMap -} - -export interface AdminExchangeParams extends SelectParams { +export interface AdminExchangeListParams extends SelectParams { id?: string | string[] + order_id?: string | string[] status?: string | string[] created_at?: OperatorMap updated_at?: OperatorMap diff --git a/packages/core/types/src/http/exchange/admin/responses.ts b/packages/core/types/src/http/exchange/admin/responses.ts index 0343a63989139..6fef61da627ca 100644 --- a/packages/core/types/src/http/exchange/admin/responses.ts +++ b/packages/core/types/src/http/exchange/admin/responses.ts @@ -5,10 +5,16 @@ import { AdminReturn } from "../../return" import { AdminExchange } from "./entities" export interface AdminExchangeResponse { + /** + * The exchange's details. + */ exchange: AdminExchange } export type AdminExchangeListResponse = PaginatedResponse<{ + /** + * This list of exchanges. + */ exchanges: AdminExchange[] }> @@ -18,17 +24,32 @@ export interface AdminExchangeOrderResponse { } export interface AdminExchangePreviewResponse { + /** + * The preview of the order when the exchange is applied. + */ order_preview: AdminOrderPreview + /** + * The exchange's details. + */ exchange: AdminExchange } export interface AdminExchangeRequestResponse extends AdminExchangePreviewResponse { + /** + * The return associated with the exchange. + */ return: AdminReturn } export interface AdminExchangeReturnResponse { + /** + * A preview of the order when the exchange is confirmed. + */ order_preview: AdminOrderPreview + /** + * The return associated with the exchange. + */ return: AdminReturn } diff --git a/packages/core/types/src/http/exchange/common.ts b/packages/core/types/src/http/exchange/common.ts index 3367298318154..f514f2763664a 100644 --- a/packages/core/types/src/http/exchange/common.ts +++ b/packages/core/types/src/http/exchange/common.ts @@ -8,45 +8,154 @@ import { import { AdminReturn, AdminReturnItem } from "../return" export interface BaseExchangeItem { + /** + * The exchange item's ID. + */ id: string + /** + * The ID of the exchange this item belongs to. + */ exchange_id: string + /** + * The ID of the associated order. + */ order_id: string + /** + * The ID of the order item, which is added + * to the order when the exchange is confirmed. + */ item_id: string + /** + * The item's quantity. + */ quantity: number + /** + * Key-value pairs of custom data. + */ metadata?: Record + /** + * The date the exchange item was created. + */ created_at: string | null + /** + * The date the exchange item was updated. + */ updated_at: string | null } export interface BaseExchange { + /** + * The exchange's ID. + */ id: string + /** + * The ID of the order this exchange is created for. + */ order_id: string + /** + * The ID of the associated return. + */ return_id?: string + /** + * The exchange's display ID. + */ display_id?: string + /** + * The version of the order when the exchange is applied. + */ order_version?: string + /** + * The ID of the user that created the exchange. + */ created_by?: string + /** + * The date the exchange was created. + */ created_at: Date | string + /** + * The date the exchange was updated. + */ updated_at: Date | string + /** + * The date the exchange was canceled. + */ canceled_at: Date | string + /** + * The date the exchange was deleted. + */ deleted_at: Date | string + /** + * The exchange's new (outbound) items. + */ additional_items: BaseExchangeItem[] + /** + * The exchange's returned (inbound) items. + */ return_items: AdminReturnItem[] + /** + * Whether to notify the customer about changes in the exchange. + */ no_notification?: boolean + /** + * The exchange's difference amount due, either to the customer or the merchant. + * + * If the value is positive, the customer owes the merchant additional payment of this amount. + * If negative, the merchant owes the customer a refund of this amount. + */ difference_due?: number + /** + * The associated return. + */ return?: AdminReturn + /** + * The associated order. + */ order?: BaseOrder + /** + * Whether out-of-stock variants can be added as new items. + */ allow_backorder?: boolean + /** + * The shipping methods used to send the outbound items. + */ shipping_methods?: BaseOrderShippingMethod[] + /** + * The exchange's transactions. + */ transactions?: BaseOrderTransaction[] + /** + * Key-value pairs of custom data. + */ metadata?: Record } export interface BaseExchangeListParams extends FindParams { + /** + * Query or keywords to search the exchange's searchable fields. + */ q?: string + /** + * Filter by exchange ID(s). + */ id?: string | string[] + /** + * Filter by order IDs to retrieve their exchanges. + */ order_id?: string | string[] + /** + * Filter by status(es). + */ status?: string | string[] + /** + * Apply filters on the exchange's creation date. + */ created_at?: OperatorMap + /** + * Apply filters on the exchange's update date. + */ updated_at?: OperatorMap + /** + * Apply filters on the exchange's deletion date. + */ deleted_at?: OperatorMap } diff --git a/packages/core/types/src/http/fulfillment-provider/admin/queries.ts b/packages/core/types/src/http/fulfillment-provider/admin/queries.ts index 89705dcbfe677..7c25733a3e28f 100644 --- a/packages/core/types/src/http/fulfillment-provider/admin/queries.ts +++ b/packages/core/types/src/http/fulfillment-provider/admin/queries.ts @@ -1,8 +1,21 @@ import { FindParams } from "../../common" export interface AdminFulfillmentProviderListParams extends FindParams { + /** + * Filter by provider ID(s). + */ id?: string | string[] + /** + * Query or keywords to filter the provider's searchable fields. + */ q?: string + /** + * Filter by whether the provider is enabled. + */ is_enabled?: boolean + /** + * Filter by stock location ID(s) to retrieve their associated + * fulfillment providers. + */ stock_location_id?: string | string[] } diff --git a/packages/core/types/src/http/fulfillment-provider/admin/responses.ts b/packages/core/types/src/http/fulfillment-provider/admin/responses.ts index fc4c58ad82431..6d88a194c304d 100644 --- a/packages/core/types/src/http/fulfillment-provider/admin/responses.ts +++ b/packages/core/types/src/http/fulfillment-provider/admin/responses.ts @@ -3,5 +3,8 @@ import { AdminFulfillmentProvider } from "./entities" export interface AdminFulfillmentProviderListResponse extends PaginatedResponse<{ + /** + * The list of fulfillment providers. + */ fulfillment_providers: AdminFulfillmentProvider[] }> {} diff --git a/packages/core/types/src/http/fulfillment-provider/common.ts b/packages/core/types/src/http/fulfillment-provider/common.ts index 2ef57ed389445..a89e79175c6ce 100644 --- a/packages/core/types/src/http/fulfillment-provider/common.ts +++ b/packages/core/types/src/http/fulfillment-provider/common.ts @@ -1,4 +1,10 @@ export interface BaseFulfillmentProvider { + /** + * The fulfillment provider's ID. + */ id: string + /** + * Whether the fulfillment provider is enabled. + */ is_enabled: boolean }