-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathinventory-item.ts
192 lines (169 loc) · 6.59 KB
/
inventory-item.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import {
AdminGetInventoryItemsParams,
AdminInventoryItemsRes,
AdminPostInventoryItemsInventoryItemReq,
AdminGetInventoryItemsItemLocationLevelsParams,
AdminPostInventoryItemsItemLocationLevelsLevelReq,
AdminInventoryItemsDeleteRes,
AdminGetInventoryItemsItemParams,
AdminInventoryItemsListWithVariantsAndLocationLevelsRes,
AdminInventoryItemsLocationLevelsRes,
AdminPostInventoryItemsItemLocationLevelsReq,
} from "@medusajs/medusa"
import { ResponsePromise } from "../../typings"
import BaseResource from "../base"
import qs from "qs"
class AdminInventoryItemsResource extends BaseResource {
/**
* Retrieve an Inventory Item
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description gets an Inventory Item
* @returns an Inventory Item
*/
retrieve(
inventoryItemId: string,
query?: AdminGetInventoryItemsItemParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsRes> {
let path = `/admin/inventory-items/${inventoryItemId}`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("GET", path, undefined, {}, customHeaders)
}
/**
* Update an Inventory Item
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description updates an Inventory Item
* @returns the updated Inventory Item
*/
update(
inventoryItemId: string,
payload: AdminPostInventoryItemsInventoryItemReq,
query?: AdminGetInventoryItemsItemParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsRes> {
let path = `/admin/inventory-items/${inventoryItemId}`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Delete an Inventory Item
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description deletes an Inventory Item
* @returns the deleted Inventory Item
*/
delete(
inventoryItemId: string,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsDeleteRes> {
const path = `/admin/inventory-items/${inventoryItemId}`
return this.client.request("DELETE", path, undefined, {}, customHeaders)
}
/**
* Retrieve a list of Inventory Items
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description Retrieve a list of Inventory Items
* @returns the list of Inventory Items as well as the pagination properties
*/
list(
query?: AdminGetInventoryItemsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsListWithVariantsAndLocationLevelsRes> {
let path = `/admin/inventory-items`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("GET", path, undefined, {}, customHeaders)
}
/**
* Update an Inventory Item's stock level at a Stock Location
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description updates an Inventory Item
* @returns the updated Inventory Item
*/
updateLocationLevel(
inventoryItemId: string,
locationId: string,
payload: AdminPostInventoryItemsItemLocationLevelsLevelReq,
query?: AdminGetInventoryItemsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsRes> {
let path = `/admin/inventory-items/${inventoryItemId}/location-levels/${locationId}`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Create stock for an Inventory Item at a Stock Location
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description creates stock levle for an Inventory Item
* @returns the Inventory Item
*/
createLocationLevel(
inventoryItemId: string,
payload: AdminPostInventoryItemsItemLocationLevelsReq,
query?: AdminGetInventoryItemsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsRes> {
let path = `/admin/inventory-items/${inventoryItemId}/location-levels`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("POST", path, payload, {}, customHeaders)
}
/**
* Removes an Inventory Item from a Stock Location. This erases trace of any quantity currently at the location.
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description deletes a location level of an Inventory Item
* @returns the Inventory Item
*/
deleteLocationLevel(
inventoryItemId: string,
locationId: string,
query?: AdminGetInventoryItemsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsRes> {
let path = `/admin/inventory-items/${inventoryItemId}/location-levels/${locationId}`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("DELETE", path, undefined, {}, customHeaders)
}
/**
* Retrieve a list of Inventory Levels related to an Inventory Item across Stock Locations
* @experimental This feature is under development and may change in the future.
* To use this feature please install @medusajs/inventory
* @description Retrieve a list of location levels related to an Inventory Item
* @returns the list of inventory levels related to an Inventory Item as well as the pagination properties
*/
listLocationLevels(
inventoryItemId: string,
query?: AdminGetInventoryItemsItemLocationLevelsParams,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminInventoryItemsLocationLevelsRes> {
let path = `/admin/inventory-items/${inventoryItemId}`
if (query) {
const queryString = qs.stringify(query)
path += `?${queryString}`
}
return this.client.request("GET", path, undefined, {}, customHeaders)
}
}
export default AdminInventoryItemsResource