|
| 1 | +/** |
| 2 | + * Multi Location Inventory |
| 3 | + */ |
| 4 | +import { LocationsEndpoint } from './mli-locations' |
| 5 | +import { Identifiable, Resource, ResourcePage } from './core' |
| 6 | + |
| 7 | +type StockType = 'stock' |
| 8 | + |
| 9 | +export interface StockMeta { |
| 10 | + timestamps: { |
| 11 | + created_at: string |
| 12 | + updated_at: string |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +export interface StockBaseLocations { |
| 17 | + [key: string]: { |
| 18 | + available: number |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +export interface StockBaseAttributes { |
| 23 | + product_id: string |
| 24 | + locations: StockBaseLocations |
| 25 | +} |
| 26 | + |
| 27 | +export interface StockResponseLocations { |
| 28 | + [key: string]: { |
| 29 | + available: number |
| 30 | + allocated: number |
| 31 | + total: number |
| 32 | + } |
| 33 | +} |
| 34 | +export interface StockResponseAttributes extends StockBaseAttributes { |
| 35 | + allocated: number |
| 36 | + total: number |
| 37 | + locations: StockResponseLocations |
| 38 | +} |
| 39 | + |
| 40 | +export interface StockResponse extends Identifiable, StockMeta { |
| 41 | + type: StockType |
| 42 | + attributes: StockResponseAttributes |
| 43 | +} |
| 44 | + |
| 45 | +/** |
| 46 | + * Multi Location Inventories Endpoints |
| 47 | + */ |
| 48 | +export interface MultiLocationInventoriesEndpoint { |
| 49 | + endpoint: 'inventory' |
| 50 | + |
| 51 | + Locations: LocationsEndpoint |
| 52 | + |
| 53 | + /** |
| 54 | + * Get Stock for all Products |
| 55 | + */ |
| 56 | + All(): Promise<ResourcePage<StockResponse>> |
| 57 | + |
| 58 | + /** |
| 59 | + * Get Stock for Product |
| 60 | + * @param productId The ID of the product. |
| 61 | + */ |
| 62 | + Get(productId: string): Promise<Resource<StockResponse>> |
| 63 | + |
| 64 | + /** |
| 65 | + * Create Stock for Product |
| 66 | + * @param body - The base attributes of the inventory stock. |
| 67 | + */ |
| 68 | + Create(body: StockBaseAttributes): Promise<Resource<StockResponse>> |
| 69 | + |
| 70 | + /** |
| 71 | + * Delete Stock for Product |
| 72 | + * @param productId The ID of the product. |
| 73 | + */ |
| 74 | + Delete(productId: string): Promise<{}> |
| 75 | + |
| 76 | + Limit(value: number): MultiLocationInventoriesEndpoint |
| 77 | + |
| 78 | + Offset(value: number): MultiLocationInventoriesEndpoint |
| 79 | +} |
0 commit comments