Generated the following references: - `entities` - `inventory` - `js-client` - `pricing` - `product` - `services` - `stock-location` - `workflows` Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
1149 lines
35 KiB
Plaintext
1149 lines
35 KiB
Plaintext
---
|
|
displayed_sidebar: jsClientSidebar
|
|
slug: /references/js-client/AdminReservationsResource
|
|
---
|
|
|
|
import ParameterTypes from "@site/src/components/ParameterTypes"
|
|
|
|
# AdminReservationsResource
|
|
|
|
This class is used to send requests to [Admin Reservation API Routes](https://docs.medusajs.com/api/admin#reservations). To use these API Routes, make sure to install the
|
|
[@medusajs/inventory](https://docs.medusajs.com/modules/multiwarehouse/install-modules#inventory-module) module in your Medusa backend.
|
|
|
|
All methods in this class require [user authentication](AdminAuthResource.mdx#createsession). The methods
|
|
are available in the JS Client under the `medusa.admin.reservations` property.
|
|
|
|
Reservations, provided by the [Inventory Module](https://docs.medusajs.com/modules/multiwarehouse/inventory-module), are quantities of an item that are reserved, typically when an order is placed but not yet fulfilled.
|
|
Reservations can be associated with any resources, but commonly with line items of an order.
|
|
|
|
Related Guide: [How to manage item allocations in orders](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-item-allocations-in-orders).
|
|
|
|
## Methods
|
|
|
|
#### create
|
|
|
|
Create a reservation which can be associated with any resource, such as an order's line item.
|
|
|
|
##### Example
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.reservations
|
|
.create({
|
|
line_item_id: "item_123",
|
|
location_id: "loc_123",
|
|
inventory_item_id: "iitem_123",
|
|
quantity: 1,
|
|
})
|
|
.then(({ reservation }) => {
|
|
console.log(reservation.id)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "payload",
|
|
"type": "[AdminPostReservationsReq](../internal/classes/internal.AdminPostReservationsReq.mdx)",
|
|
"description": "The reservation to be created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "description",
|
|
"type": "`string`",
|
|
"description": "The reservation's description.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "inventory_item_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the inventory item the reservation is associated with.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "line_item_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the line item of the reservation.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "location_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the location of the reservation.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional set of key-value pairs with additional information.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "`number`",
|
|
"description": "The quantity to reserve.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
##### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[AdminReservationsRes](../internal/types/internal.AdminReservationsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the reservation's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminReservationsRes",
|
|
"type": "`object`",
|
|
"description": "The reservation's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "reservation",
|
|
"type": "[ReservationItemDTO](../internal/types/internal.ReservationItemDTO.mdx)",
|
|
"description": "Reservation details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "created_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_by",
|
|
"type": "`string` \\| `null`",
|
|
"description": "UserId of user who created the reservation item",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`string` \\| `Date` \\| `null`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "description",
|
|
"type": "`string` \\| `null`",
|
|
"description": "Description of the reservation item",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The id of the reservation item",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "inventory_item_id",
|
|
"type": "`string`",
|
|
"description": "The id of the inventory item the reservation relates to",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "line_item_id",
|
|
"type": "`string` \\| `null`",
|
|
"description": "",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "location_id",
|
|
"type": "`string`",
|
|
"description": "The id of the location of the reservation",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>` \\| `null`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "`number`",
|
|
"description": "The id of the reservation item",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
#### delete
|
|
|
|
Delete a reservation. Associated resources, such as the line item, will not be deleted.
|
|
|
|
##### Example
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.reservations
|
|
.delete(reservationId)
|
|
.then(({ id, object, deleted }) => {
|
|
console.log(id)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The ID of the reservation.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
##### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[DeleteResponse](../internal/interfaces/internal.DeleteResponse.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the deletion operation's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "deleted",
|
|
"type": "`boolean`",
|
|
"description": "Whether the item was deleted successfully.",
|
|
"optional": false,
|
|
"defaultValue": "true",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The ID of the deleted item.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "object",
|
|
"type": "`string`",
|
|
"description": "The type of the deleted item.",
|
|
"optional": false,
|
|
"defaultValue": "product-collection",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
#### list
|
|
|
|
Retrieve a list of reservations. The reservations can be filtered by fields such as `location_id` or `quantity` passed in the `query` parameter. The reservations can also be paginated.
|
|
|
|
##### Example
|
|
|
|
To list reservations:
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.reservations
|
|
.list()
|
|
.then(({ reservations, count, limit, offset }) => {
|
|
console.log(reservations.length)
|
|
})
|
|
```
|
|
|
|
To specify relations that should be retrieved within the reservations:
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.reservations
|
|
.list({
|
|
expand: "location",
|
|
})
|
|
.then(({ reservations, count, limit, offset }) => {
|
|
console.log(reservations.length)
|
|
})
|
|
```
|
|
|
|
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.reservations
|
|
.list({
|
|
expand: "location",
|
|
limit,
|
|
offset,
|
|
})
|
|
.then(({ reservations, count, limit, offset }) => {
|
|
console.log(reservations.length)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "query",
|
|
"type": "[AdminGetReservationsParams](../internal/classes/internal.AdminGetReservationsParams.mdx)",
|
|
"description": "Filters and pagination parameters to apply on the retrieved reservations.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "created_at",
|
|
"type": "[DateComparisonOperator](../internal/classes/internal.DateComparisonOperator.mdx)",
|
|
"description": "Date filters to apply on the reservations' `created_at` field.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "gt",
|
|
"type": "`Date`",
|
|
"description": "The filtered date must be greater than this value.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gte",
|
|
"type": "`Date`",
|
|
"description": "The filtered date must be greater than or equal to this value.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "lt",
|
|
"type": "`Date`",
|
|
"description": "The filtered date must be less than this value.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "lte",
|
|
"type": "`Date`",
|
|
"description": "The filtered date must be less than or equal to this value.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "created_by",
|
|
"type": "`string`[]",
|
|
"description": "\"Create by\" user IDs to filter reservations by.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "description",
|
|
"type": "`string` \\| [StringComparisonOperator](../internal/classes/internal.StringComparisonOperator.mdx)",
|
|
"description": "String filters tp apply on the reservations' `description` field.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "expand",
|
|
"type": "`string`",
|
|
"description": "Comma-separated relations that should be expanded in the returned data.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "fields",
|
|
"type": "`string`",
|
|
"description": "Comma-separated fields that should be included in the returned data.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "inventory_item_id",
|
|
"type": "`string`[]",
|
|
"description": "Inventory item IDs to filter reservations by.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "limit",
|
|
"type": "`number`",
|
|
"description": "Limit the number of items returned in the list.",
|
|
"optional": true,
|
|
"defaultValue": "20",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "line_item_id",
|
|
"type": "`string`[]",
|
|
"description": "Line item IDs to filter reservations by.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "location_id",
|
|
"type": "`string` \\| `string`[]",
|
|
"description": "Location IDs to filter reservations by.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "offset",
|
|
"type": "`number`",
|
|
"description": "The number of items to skip when retrieving a list.",
|
|
"optional": true,
|
|
"defaultValue": "0",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "[NumericalComparisonOperator](../internal/classes/internal.NumericalComparisonOperator.mdx)",
|
|
"description": "Numerical filters to apply on the reservations' `quantity` field.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "gt",
|
|
"type": "`number`",
|
|
"description": "The filtered number must be greater than this value.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "gte",
|
|
"type": "`number`",
|
|
"description": "The filtered number must be greater than or equal to this value.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "lt",
|
|
"type": "`number`",
|
|
"description": "The filtered number must be less than this value.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "lte",
|
|
"type": "`number`",
|
|
"description": "The filtered number must be less than or equal to this value.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
##### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[AdminReservationsListRes](../internal/types/internal.AdminReservationsListRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the list of reservations with pagination fields.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminReservationsListRes",
|
|
"type": "[PaginatedResponse](../internal/interfaces/internal.PaginatedResponse.mdx) & ``{ reservations: [ReservationItemDTO](../internal/types/internal.ReservationItemDTO.mdx)[] }``",
|
|
"description": "The list of reservations with pagination fields.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "count",
|
|
"type": "`number`",
|
|
"description": "The total number of items available.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "limit",
|
|
"type": "`number`",
|
|
"description": "The maximum number of items that can be returned in the list.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "offset",
|
|
"type": "`number`",
|
|
"description": "The number of items skipped before the returned items in the list.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "reservations",
|
|
"type": "[ReservationItemDTO](../internal/types/internal.ReservationItemDTO.mdx)[]",
|
|
"description": "An array of reservations details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "created_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_by",
|
|
"type": "`string` \\| `null`",
|
|
"description": "UserId of user who created the reservation item",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`string` \\| `Date` \\| `null`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "description",
|
|
"type": "`string` \\| `null`",
|
|
"description": "Description of the reservation item",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The id of the reservation item",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "inventory_item_id",
|
|
"type": "`string`",
|
|
"description": "The id of the inventory item the reservation relates to",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "line_item_id",
|
|
"type": "`string` \\| `null`",
|
|
"description": "",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "location_id",
|
|
"type": "`string`",
|
|
"description": "The id of the location of the reservation",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>` \\| `null`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "`number`",
|
|
"description": "The id of the reservation item",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
#### retrieve
|
|
|
|
Retrieve a reservation's details.
|
|
|
|
##### Example
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.reservations.retrieve(reservationId).then(({ reservation }) => {
|
|
console.log(reservation.id)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The reservation's ID.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
##### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[AdminReservationsRes](../internal/types/internal.AdminReservationsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the reservation's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminReservationsRes",
|
|
"type": "`object`",
|
|
"description": "The reservation's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "reservation",
|
|
"type": "[ReservationItemDTO](../internal/types/internal.ReservationItemDTO.mdx)",
|
|
"description": "Reservation details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "created_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_by",
|
|
"type": "`string` \\| `null`",
|
|
"description": "UserId of user who created the reservation item",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`string` \\| `Date` \\| `null`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "description",
|
|
"type": "`string` \\| `null`",
|
|
"description": "Description of the reservation item",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The id of the reservation item",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "inventory_item_id",
|
|
"type": "`string`",
|
|
"description": "The id of the inventory item the reservation relates to",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "line_item_id",
|
|
"type": "`string` \\| `null`",
|
|
"description": "",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "location_id",
|
|
"type": "`string`",
|
|
"description": "The id of the location of the reservation",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>` \\| `null`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "`number`",
|
|
"description": "The id of the reservation item",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
#### update
|
|
|
|
Update a reservation's details.
|
|
|
|
##### Example
|
|
|
|
```ts
|
|
import Medusa from "@medusajs/medusa-js"
|
|
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
|
|
// must be previously logged in or use api token
|
|
medusa.admin.reservations
|
|
.update(reservationId, {
|
|
quantity: 3,
|
|
})
|
|
.then(({ reservation }) => {
|
|
console.log(reservation.id)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The ID of the reservation.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payload",
|
|
"type": "[AdminPostReservationsReservationReq](../internal/classes/internal.AdminPostReservationsReservationReq.mdx)",
|
|
"description": "The attributes to update in the reservation.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "description",
|
|
"type": "`string`",
|
|
"description": "The reservation's description.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "location_id",
|
|
"type": "`string`",
|
|
"description": "The ID of the location associated with the reservation.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional set of key-value pairs with additional information.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "`number`",
|
|
"description": "The quantity to reserve.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "customHeaders",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "Custom headers to attach to the request.",
|
|
"optional": false,
|
|
"defaultValue": "{}",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
##### Returns
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "ResponsePromise",
|
|
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)<[AdminReservationsRes](../internal/types/internal.AdminReservationsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the reservation's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminReservationsRes",
|
|
"type": "`object`",
|
|
"description": "The reservation's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "reservation",
|
|
"type": "[ReservationItemDTO](../internal/types/internal.ReservationItemDTO.mdx)",
|
|
"description": "Reservation details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "created_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_by",
|
|
"type": "`string` \\| `null`",
|
|
"description": "UserId of user who created the reservation item",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`string` \\| `Date` \\| `null`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "description",
|
|
"type": "`string` \\| `null`",
|
|
"description": "Description of the reservation item",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The id of the reservation item",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "inventory_item_id",
|
|
"type": "`string`",
|
|
"description": "The id of the inventory item the reservation relates to",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "line_item_id",
|
|
"type": "`string` \\| `null`",
|
|
"description": "",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "location_id",
|
|
"type": "`string`",
|
|
"description": "The id of the location of the reservation",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>` \\| `null`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "quantity",
|
|
"type": "`number`",
|
|
"description": "The id of the reservation item",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|