Inventory¶
ItemsClient
¶
Source code in src/spyre/inventory.py
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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
create_item(item)
¶
Create a new Inventory Item in Spire.
Sends a POST request to the Inventory/Items endpoint .
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
dict
|
A InventoryItem instace containing the sales order details. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
item |
item
|
The created InventoryItem instance. |
Raises:
| Type | Description |
|---|---|
CreateRequestError
|
If the creation fails or response is invalid. |
Source code in src/spyre/inventory.py
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 | |
create_item_uom(id, uom)
¶
Create a new Unit of Measure (UOM) for a specific inventory item.
Sends a POST request to the Spire API to create a new UOM for the inventory item with the specified ID. If successful, the method retrieves and returns the newly created UOM object. If the creation fails, an exception is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the inventory item for which to create the UOM. |
required |
uom
|
UnitOfMeasure
|
A Pydantic model instance representing the UOM to create. |
required |
Returns:
| Type | Description |
|---|---|
uom
|
List[uom]: A list containing the created |
Raises:
| Type | Description |
|---|---|
CreateRequestError
|
If the API response status is not 201 (Created). |
Source code in src/spyre/inventory.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
create_item_upc(id, upc)
¶
Create a new UPC (upc) for a specific inventory item.
Sends a POST request to the Spire API to create a new upc for the inventory item with the specified ID. If successful, the method retrieves and returns the newly created upc object. If the creation fails, an exception is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the inventory item for which to create the upc. |
required |
upc
|
UPC
|
A Pydantic model instance representing the upc to create. |
required |
Returns:
| Type | Description |
|---|---|
upc
|
List[upc]: A list containing the created |
Raises:
| Type | Description |
|---|---|
CreateRequestError
|
If the API response status is not 201 (Created). |
Source code in src/spyre/inventory.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
delete_item(id)
¶
Delete a inventory_item by its ID.
Sends a DELETE request to the endpoint to remove the specified inventory item from the system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the inventory item to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the item was successfully deleted, False otherwise. |
Source code in src/spyre/inventory.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
delete_uom(item_id, uom_id)
¶
Delete a Unit of Measure (UOM) from a specific inventory item.
Sends a DELETE request to the Spire API to remove a UOM associated with the given item and UOM ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
int
|
The ID of the inventory item. |
required |
uom_id
|
int
|
The ID of the Unit of Measure to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the deletion was successful, otherwise raises an error. |
Source code in src/spyre/inventory.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
delete_upc(item_id, upc_id)
¶
Delete a UPC (upc) from a specific inventory item.
Sends a DELETE request to the Spire API to remove a upc associated with the given item and upc ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
int
|
The ID of the inventory item. |
required |
upc_id
|
int
|
The ID of the Unit of Measure to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the deletion was successful, otherwise raises an error. |
Source code in src/spyre/inventory.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
get_item(id=None, part_no=None, warehouse=None)
¶
Retrieve an inventory item by ID or (part_no + warehouse).
Sends a GET request to the Spire API to fetch inventory item data for the
specified ID, or uses a filtered query with part number and warehouse.
Wraps the result in an item instance, which retains a reference to the
client for further actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the inventory item to retrieve. |
None
|
part_no
|
str
|
The part number of the item to retrieve. |
None
|
warehouse
|
str
|
The warehouse code where the item is located. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
item |
item
|
An |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither ID nor (part_no and warehouse) are provided, or if no matching item is found. |
Source code in src/spyre/inventory.py
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 | |
get_item_uoms(id)
¶
Retrieve all Unit of Measure (UOM) entries for a specific inventory item.
This method sends a GET request to the Spire API to retrieve the unit of measure
records associated with the specified inventory item ID. Each returned record is
wrapped into a uom object, which includes the model and the client reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The unique identifier of the inventory item. |
required |
Returns:
| Type | Description |
|---|---|
List[uom]
|
List[uom]: A list of |
Source code in src/spyre/inventory.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
get_item_upcs(id)
¶
Retrieve all UPC records associated with a specific inventory item.
Sends a GET request to the Spire API to fetch UPCs for the specified item ID,
then constructs and returns a list of upc objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the inventory item. |
required |
Returns:
| Type | Description |
|---|---|
List[upc]
|
List[upc]: A list of |
Source code in src/spyre/inventory.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
get_uom(item_id, uom_id)
¶
Retrieve a specific Unit of Measure (UOM) for a given inventory item.
This method sends a GET request to the Spire API to fetch a single UOM record
associated with a specific inventory item and UOM ID. The response is wrapped
into a uom object that maintains a reference to the API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
int
|
The unique ID of the inventory item. |
required |
uom_id
|
int
|
The unique ID of the UOM to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
uom |
uom
|
A |
Source code in src/spyre/inventory.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
get_upc(item_id, upc_id)
¶
Retrieve a specific UPC (upc) for a given inventory item.
This method sends a GET request to the Spire API to fetch a single upc record
associated with a specific inventory item and upc ID. The response is wrapped
into a upc object that maintains a reference to the API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
int
|
The unique ID of the inventory item. |
required |
upc_id
|
int
|
The unique ID of the upc to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
upc |
upc
|
A |
Source code in src/spyre/inventory.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
query_inventory_items(*, query=None, sort=None, filter=None, all=False, limit=1000, start=0, **extra_params)
¶
Query inventory items with optional full-text search, filtering, multi-field sorting, and pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Full-text search string. |
None
|
sort
|
dict
|
Dictionary of sorting rules (e.g., {"orderDate": "desc", "orderNo": "asc"}). |
None
|
filter
|
dict
|
Dictionary of filters to apply (will be JSON-encoded and URL-safe). |
None
|
all
|
bool
|
If True, retrieves all pages of results. |
False
|
limit
|
int
|
Number of results per page (max 1000). |
1000
|
start
|
int
|
Starting offset for pagination. |
0
|
**extra_params
|
Any
|
Any additional parameters to include in the query. |
{}
|
Returns:
| Type | Description |
|---|---|
List[item]
|
List[item]: List of wrapped sales order resources. |
Source code in src/spyre/inventory.py
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 | |
update_item(id, inventory_item)
¶
Update an existing Inventory Item by ID.
Sends a PUT request to the Inventory/Items endpoint with the provided data
to update the existing record. Returns a wrapped item object containing
the updated information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the item to update. |
required |
inventory_item
|
InventoryItem
|
A InventoryItem instance with the sales order details. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
item |
item
|
An instance of the item wrapper class initialized with the updated data and client session. |
Source code in src/spyre/inventory.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
update_item_uom(item_id, uom_id, uom_record)
¶
Update an existing Unit of Measure (UOM) for a given inventory item.
Sends a PUT request to the Spire API to update the UOM record with the specified
item and UOM ID using the provided uom data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
int
|
The ID of the inventory item. |
required |
uom_id
|
int
|
The ID of the UOM to update. |
required |
uom_record
|
uom
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
uom |
uom
|
The updated |
Source code in src/spyre/inventory.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
update_item_upc(item_id, upc_id, upc_record)
¶
Update an existing UPC (upc) for a given inventory item.
Sends a PUT request to the Spire API to update the upc record with the specified
item and upc ID using the provided upc data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
int
|
The ID of the inventory item. |
required |
upc_id
|
int
|
The ID of the upc to update. |
required |
upc_record
|
upc
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
upc |
upc
|
The updated |
Source code in src/spyre/inventory.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
UpcClient
¶
Source code in src/spyre/inventory.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | |
create_item_upc(upc)
¶
Create a new UPC (upc) for a given id.
Sends a POST request to the Spire API to create a new upc. If successful, the method retrieves and returns the newly created upc object. If the creation fails, an exception is raised. For a successful creation, either the whse and the partNo or the inventory field has to be filled in
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upc
|
UPC
|
A Pydantic model instance representing the upc to create. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
upc |
upc
|
A list containing the created |
Raises:
| Type | Description |
|---|---|
CreateRequestError
|
If the API response status is not 201 (Created). |
Source code in src/spyre/inventory.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | |
delete_upc(upc_id)
¶
Delete a UPC.
Sends a DELETE request to the Spire API to remove a upc associated with the given upc ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upc_id
|
int
|
The ID of the Unit of Measure to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the deletion was successful, otherwise raises an error. |
Source code in src/spyre/inventory.py
598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
get_upc(upc_id)
¶
Retrieve a specific UPC (upc) for given id.
This method sends a GET request to the Spire API to fetch a single upc record
associated with the upc ID. The response is wrapped
into a upc object that maintains a reference to the API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upc_id
|
int
|
The unique ID of the upc to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
upc |
upc
|
A |
Source code in src/spyre/inventory.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
update_item_upc(upc_id, upc_record)
¶
Update an existing UPC.
Sends a PUT request to the Spire API to update the upc record with the specified
upc ID using the provided upc data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upc_id
|
int
|
The ID of the upc to update. |
required |
upc_record
|
upc
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
upc |
upc
|
The updated |
Source code in src/spyre/inventory.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | |
item
¶
Bases: APIResource[InventoryItem]
Source code in src/spyre/inventory.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
add_uom(uom_record)
¶
Add a new Unit of Measure (UOM) to the current inventory item.
Sends a POST request to the Spire API to create a new UOM record using the provided
UnitOfMeasure model. If the creation is successful (HTTP 201), it retrieves
and returns the created UOM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uom_record
|
UnitOfMeasure
|
The UnitOfMeasure Pydantic model to be created. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
uom |
uom
|
The newly created Unit of measure as a |
Raises:
| Type | Description |
|---|---|
CreateRequestError
|
If the API returns a non-201 status code during creation. |
Source code in src/spyre/inventory.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
add_upc(upc_record)
¶
Add a new UPC to the current inventory item.
Sends a POST request to the Spire API to create a new UPC record using the provided UPC model. If the creation is successful (HTTP 201), it retrieves and returns the created UPC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upc_record
|
UPC
|
The UPC Pydantic model to be created. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
upc |
upc
|
The newly created UPC as a |
Raises:
| Type | Description |
|---|---|
CreateRequestError
|
If the API returns a non-201 status code during creation. |
Source code in src/spyre/inventory.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
delete()
¶
Cancels or deletes the item.
Sends a DELETE request to the API to remove the inventory item with the current ID.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the order was successfully deleted (HTTP 204 or 200), False otherwise. |
Source code in src/spyre/inventory.py
381 382 383 384 385 386 387 388 389 390 391 | |
get_uoms()
¶
Retrieve all Unit of Measure (UOM) records for the current inventory item.
This method sends a GET request to the Spire API and returns all UOMs associated with this item's ID.
Returns:
| Type | Description |
|---|---|
List[uom]
|
List[uom]: A list of |
Source code in src/spyre/inventory.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
get_upcs()
¶
Retrieve all UPC records for the current inventory item.
This method sends a GET request to the Spire API and returns all UPCs associated with this item's ID.
Returns:
| Type | Description |
|---|---|
List[upc]
|
List[upc]: A list of |
Source code in src/spyre/inventory.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | |
update(inventory_item=None)
¶
Update the inventory item.
If no item object is provided, updates the current instance on the server. If an item object is provided, updates the item using the given data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_item
|
item
|
An optional item instance to use for the update. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
item |
item
|
The updated item object reflecting the new status. |
Source code in src/spyre/inventory.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
uom
¶
Bases: APIResource[UnitOfMeasure]
Source code in src/spyre/inventory.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
delete()
¶
Cancels or deletes the uom.
Sends a DELETE request to the API to remove the uom with the current ID.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the uom was successfully deleted (HTTP 204 or 200), False otherwise. |
Source code in src/spyre/inventory.py
515 516 517 518 519 520 521 522 523 524 525 | |
update(_uom=None)
¶
Update the uom.
If no uom object is provided, updates the current instance on the server. If an uom object is provided, updates the item using the given data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_uom
|
uom
|
An optional uom instance to use for the update. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
uom |
uom
|
The updated uom object reflecting the new status. |
Source code in src/spyre/inventory.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
upc
¶
Bases: APIResource[UPC]
Source code in src/spyre/inventory.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |
delete()
¶
Cancels or deletes the upc.
Sends a DELETE request to the API to remove the upc with the current ID.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the upc was successfully deleted (HTTP 204 or 200), False otherwise. |
Source code in src/spyre/inventory.py
644 645 646 647 648 649 650 651 652 653 654 | |
update(_upc=None)
¶
Update the upc.
If no upc object is provided, updates the current instance on the server. If an upc object is provided, updates the item using the given data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_upc
|
upc
|
An optional upc instance to use for the update. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
upc |
upc
|
The updated upc object reflecting the new status. |
Source code in src/spyre/inventory.py
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |