Helper Methods API Reference¶
Products Helper¶
Products ¶
Bases: Base
Product catalog management.
Provides operations for managing products in StockTrim.
Source code in stocktrim_public_api_client/helpers/base.py
create
async
¶
Create a new product.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product
|
ProductsRequestDto
|
Product data to create. |
required |
Returns:
| Type | Description |
|---|---|
ProductsResponseDto
|
Created ProductsResponseDto object. |
Example
from stocktrim_public_api_client.generated.models import ( ... ProductsRequestDto, ... ) product = await client.products.create( ... ProductsRequestDto(code="WIDGET-001", description="Widget") ... )
Source code in stocktrim_public_api_client/helpers/products.py
delete
async
¶
Delete product(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_id
|
str | Unset
|
Optional product ID to delete. If not provided, may delete all products (use with caution). |
UNSET
|
Example
await client.products.delete(product_id="123")
Source code in stocktrim_public_api_client/helpers/products.py
exists
async
¶
Check if a product with given code exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The product code to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if product exists, False otherwise. |
Example
if await client.products.exists("WIDGET-001"): ... print("Product already exists")
Source code in stocktrim_public_api_client/helpers/products.py
find_by_code
async
¶
Find a single product by exact code match.
This is a convenience method that wraps get_all() and returns the first matching product or None if not found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The exact product code to search for. |
required |
Returns:
| Type | Description |
|---|---|
ProductsResponseDto | None
|
ProductsResponseDto if found, None otherwise. |
Example
product = await client.products.find_by_code("WIDGET-001") if product: ... print(f"Found: {product.description}")
Source code in stocktrim_public_api_client/helpers/products.py
find_by_exact_code
async
¶
Find products by exact code match, returning a list.
This method provides the same functionality as find_by_code() but returns a list for consistency with search patterns. Since the API only supports exact matching, this will return 0 or 1 products.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The exact product code to search for. |
required |
Returns:
| Type | Description |
|---|---|
list[ProductsResponseDto]
|
List containing the matching product (0 or 1 item). |
Example
products = await client.products.find_by_exact_code("WIDGET-001") if products: ... print(f"Found: {products[0].description}")
Source code in stocktrim_public_api_client/helpers/products.py
get_all
async
¶
Get all products, optionally filtered by exact code match or page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str | Unset
|
Optional product code for exact match filtering. The StockTrim API only supports exact code matches, not prefix or partial matching. |
UNSET
|
page_no
|
str | Unset
|
Optional page number for pagination. |
UNSET
|
Returns:
| Type | Description |
|---|---|
list[ProductsResponseDto]
|
List of ProductsResponseDto objects. Returns empty list if no products |
list[ProductsResponseDto]
|
match the filter. |
Example
products = await client.products.get_all() products = await client.products.get_all( ... code="WIDGET-001" ... ) # Exact match only
Source code in stocktrim_public_api_client/helpers/products.py
get_all_paginated
async
¶
Get ALL products by paginating through all pages.
This method automatically handles pagination to fetch the complete product catalog from StockTrim.
Returns:
| Type | Description |
|---|---|
list[ProductsResponseDto]
|
List of all ProductsResponseDto objects across all pages. |
Example
all_products = await client.products.get_all_paginated() print(f"Total products: {len(all_products)}")
Source code in stocktrim_public_api_client/helpers/products.py
Customers Helper¶
Customers ¶
Bases: Base
Customer management.
Provides operations for managing customers in StockTrim.
Source code in stocktrim_public_api_client/helpers/base.py
exists
async
¶
Check if a customer with given code exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The customer code to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if customer exists, False otherwise. |
Example
if await client.customers.exists("CUST-001"): ... print("Customer exists")
Source code in stocktrim_public_api_client/helpers/customers.py
find_or_create
async
¶
Get customer by code, or create if doesn't exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The customer code. |
required |
**defaults
|
Default values to use when creating the customer. |
{}
|
Returns:
| Type | Description |
|---|---|
CustomerDto
|
CustomerDto object (existing or newly created). |
Example
customer = await client.customers.find_or_create( ... "CUST-001", name="New Customer", email="customer@example.com" ... )
Source code in stocktrim_public_api_client/helpers/customers.py
get
async
¶
Get a specific customer by code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The customer code. |
required |
Returns:
| Type | Description |
|---|---|
CustomerDto
|
CustomerDto object. |
Example
customer = await client.customers.get("CUST-001")
Source code in stocktrim_public_api_client/helpers/customers.py
get_all
async
¶
Get all customers.
Returns:
| Type | Description |
|---|---|
list[CustomerDto]
|
List of CustomerDto objects. |
Example
customers = await client.customers.get_all()
Source code in stocktrim_public_api_client/helpers/customers.py
update
async
¶
Update a customer (create or update based on code).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
customer
|
CustomerDto
|
Customer data to update. |
required |
Returns:
| Type | Description |
|---|---|
list[CustomerDto]
|
List of updated CustomerDto objects. |
Example
from stocktrim_public_api_client.generated.models import CustomerDto updated = await client.customers.update( ... CustomerDto(code="CUST-001", name="Updated Name") ... )
Source code in stocktrim_public_api_client/helpers/customers.py
Suppliers Helper¶
Suppliers ¶
Bases: Base
Supplier management.
Provides operations for managing suppliers in StockTrim.
Source code in stocktrim_public_api_client/helpers/base.py
create
async
¶
Create new suppliers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suppliers
|
list[SupplierRequestDto]
|
List of supplier data to create. |
required |
Returns:
| Type | Description |
|---|---|
list[SupplierResponseDto]
|
List of created SupplierResponseDto objects. |
Example
from stocktrim_public_api_client.generated.models import ( ... SupplierRequestDto, ... ) suppliers = await client.suppliers.create( ... [ ... SupplierRequestDto(code="SUP-001", name="Supplier One"), ... SupplierRequestDto(code="SUP-002", name="Supplier Two"), ... ] ... )
Source code in stocktrim_public_api_client/helpers/suppliers.py
create_one
async
¶
Create a single supplier.
This is a convenience wrapper around the batch create() method that accepts a single supplier instead of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
supplier
|
SupplierRequestDto
|
Supplier data to create. |
required |
Returns:
| Type | Description |
|---|---|
SupplierResponseDto | None
|
Created SupplierResponseDto object, or None if creation failed. |
Example
from stocktrim_public_api_client.generated.models import ( ... SupplierRequestDto, ... ) supplier = await client.suppliers.create_one( ... SupplierRequestDto(code="SUP-001", name="New Supplier") ... )
Source code in stocktrim_public_api_client/helpers/suppliers.py
delete
async
¶
Delete supplier(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
supplier_code_or_name
|
str | Unset
|
Supplier code or name to delete. |
UNSET
|
Example
await client.suppliers.delete(supplier_code_or_name="SUP-001")
Source code in stocktrim_public_api_client/helpers/suppliers.py
exists
async
¶
Check if a supplier with given code exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The supplier code to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if supplier exists, False otherwise. |
Example
if await client.suppliers.exists("SUP-001"): ... print("Supplier exists")
Source code in stocktrim_public_api_client/helpers/suppliers.py
find_by_code
async
¶
Find a single supplier by exact code match.
This method handles the API's inconsistent return type (single vs list) and always returns a single object or None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The exact supplier code to search for. |
required |
Returns:
| Type | Description |
|---|---|
SupplierResponseDto | None
|
SupplierResponseDto if found, None otherwise. |
Example
supplier = await client.suppliers.find_by_code("SUP-001") if supplier: ... print(f"Found: {supplier.name}")
Source code in stocktrim_public_api_client/helpers/suppliers.py
get_all
async
¶
Get suppliers, optionally filtered by code.
When code is not provided, uses the bulk endpoint to return all suppliers. When code is provided, uses the single supplier endpoint.
Note: The API has separate endpoints for these operations: - /api/SuppliersBulk returns a list of all suppliers - /api/Suppliers?code=X returns a single supplier
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str | Unset
|
Optional supplier code filter. |
UNSET
|
Returns:
| Type | Description |
|---|---|
SupplierResponseDto | list[SupplierResponseDto]
|
List of SupplierResponseDto when code is not provided, |
SupplierResponseDto | list[SupplierResponseDto]
|
or single SupplierResponseDto when code is provided. |
Example
suppliers = await client.suppliers.get_all() # Returns list supplier = await client.suppliers.get_all( ... code="SUP-001" ... ) # Returns single object
Source code in stocktrim_public_api_client/helpers/suppliers.py
Sales Orders Helper¶
SalesOrders ¶
Bases: Base
Sales order management.
Provides operations for managing sales orders in StockTrim.
Source code in stocktrim_public_api_client/helpers/base.py
create
async
¶
Create a new sales order using the idempotent bulk endpoint.
This method uses PUT /SalesOrdersBulk which is idempotent and safer for retries.
It performs a create or update based on the external_reference_id field of
the line item (SalesOrderRequestDto). The bulk request does not include an
external reference ID at the header level; the API uses the value from the
line item to determine whether to create or update.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
SalesOrderRequestDto
|
Sales order data to create. Include |
required |
Returns:
| Type | Description |
|---|---|
SalesOrderResponseDto
|
Created SalesOrderResponseDto object. |
Example
from datetime import datetime from stocktrim_public_api_client.generated.models import ( ... SalesOrderRequestDto, ... ) order = await client.sales_orders.create( ... SalesOrderRequestDto( ... product_id="WIDGET-001", ... order_date=datetime.now(), ... quantity=10.0, ... external_reference_id="SO-001", ... ) ... )
Source code in stocktrim_public_api_client/helpers/sales_orders.py
delete
async
¶
Delete sales order(s), optionally filtered by product ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_id
|
str | Unset
|
Optional product ID to filter deletions. |
UNSET
|
Example
await client.sales_orders.delete(product_id="123")
Source code in stocktrim_public_api_client/helpers/sales_orders.py
delete_for_product
async
¶
Delete all sales orders for a specific product.
This is a convenience alias for delete() with clearer intent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_id
|
str
|
The product ID to delete orders for. |
required |
Example
await client.sales_orders.delete_for_product("123")
Source code in stocktrim_public_api_client/helpers/sales_orders.py
get_all
async
¶
Get all sales orders, optionally filtered by product ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_id
|
str | Unset
|
Optional product ID to filter by. |
UNSET
|
Returns:
| Type | Description |
|---|---|
list[SalesOrderResponseDto]
|
List of SalesOrderResponseDto objects. |
Example
orders = await client.sales_orders.get_all() orders = await client.sales_orders.get_all(product_id="123")
Source code in stocktrim_public_api_client/helpers/sales_orders.py
get_for_product
async
¶
Get all sales orders for a specific product.
This is a convenience alias for get_all() with clearer intent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_id
|
str
|
The product ID to get orders for. |
required |
Returns:
| Type | Description |
|---|---|
list[SalesOrderResponseDto]
|
List of SalesOrderResponseDto objects for the product. |
Example
orders = await client.sales_orders.get_for_product("123")
Source code in stocktrim_public_api_client/helpers/sales_orders.py
Purchase Orders Helper¶
PurchaseOrders ¶
Bases: Base
Purchase order management.
Provides operations for managing purchase orders in StockTrim.
Source code in stocktrim_public_api_client/helpers/base.py
create
async
¶
Create a new purchase order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
PurchaseOrderRequestDto
|
Purchase order data to create. |
required |
Returns:
| Type | Description |
|---|---|
PurchaseOrderResponseDto
|
Created PurchaseOrderResponseDto object. |
Example
from stocktrim_public_api_client.generated.models import ( ... PurchaseOrderRequestDto, ... ) order = await client.purchase_orders.create( ... PurchaseOrderRequestDto(reference_number="PO-001", ...) ... )
Source code in stocktrim_public_api_client/helpers/purchase_orders.py
delete
async
¶
Delete purchase order(s).
Note: The API returns the deleted PurchaseOrderResponseDto object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_number
|
str | Unset
|
Reference number to delete. |
UNSET
|
Returns:
| Type | Description |
|---|---|
PurchaseOrderResponseDto | None
|
Deleted PurchaseOrderResponseDto object or None. |
Example
deleted = await client.purchase_orders.delete(reference_number="PO-001")
Source code in stocktrim_public_api_client/helpers/purchase_orders.py
exists
async
¶
Check if a purchase order with given reference number exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_number
|
str
|
The reference number to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if order exists, False otherwise. |
Example
if await client.purchase_orders.exists("PO-001"): ... print("Purchase order exists")
Source code in stocktrim_public_api_client/helpers/purchase_orders.py
find_by_reference
async
¶
Find a single purchase order by reference number.
This method handles the API's inconsistent return type (single vs list) and always returns a single object or None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_number
|
str
|
The purchase order reference number. |
required |
Returns:
| Type | Description |
|---|---|
PurchaseOrderResponseDto | None
|
PurchaseOrderResponseDto if found, None otherwise. |
Example
order = await client.purchase_orders.find_by_reference("PO-001") if order: ... print(f"Found order: {order.reference_number}")
Source code in stocktrim_public_api_client/helpers/purchase_orders.py
get_all
async
¶
get_all(
reference_number: str | Unset = UNSET,
) -> (
PurchaseOrderResponseDto
| list[PurchaseOrderResponseDto]
)
Get purchase orders, optionally filtered by reference number.
Note: The API returns a single object when filtered by reference number, but this is inconsistent with other endpoints. We preserve the API's behavior here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_number
|
str | Unset
|
Optional reference number filter. |
UNSET
|
Returns:
| Type | Description |
|---|---|
PurchaseOrderResponseDto | list[PurchaseOrderResponseDto]
|
PurchaseOrderResponseDto or list of PurchaseOrderResponseDto objects. |
Example
orders = await client.purchase_orders.get_all() order = await client.purchase_orders.get_all(reference_number="PO-001")
Source code in stocktrim_public_api_client/helpers/purchase_orders.py
Locations Helper¶
Locations ¶
Bases: Base
Location management.
Provides operations for managing locations in StockTrim.
Source code in stocktrim_public_api_client/helpers/base.py
create
async
¶
Create a new location.
Note: The API returns a single object but it's unclear if it accepts a single object or array. We preserve the API's behavior here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
LocationRequestDto
|
Location data to create. |
required |
Returns:
| Type | Description |
|---|---|
LocationResponseDto
|
Created LocationResponseDto object. |
Example
from stocktrim_public_api_client.generated.models import ( ... LocationRequestDto, ... ) location = await client.locations.create( ... LocationRequestDto(code="LOC-001", name="Warehouse A") ... )
Source code in stocktrim_public_api_client/helpers/locations.py
get_all
async
¶
Get locations, optionally filtered by code.
Note: The API returns a single object when filtered by code, but this is inconsistent with other endpoints. We preserve the API's behavior here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str | Unset
|
Optional location code filter. |
UNSET
|
Returns:
| Type | Description |
|---|---|
LocationResponseDto | list[LocationResponseDto]
|
LocationResponseDto or list of LocationResponseDto objects. |
Example
locations = await client.locations.get_all() location = await client.locations.get_all(code="LOC-001")
Source code in stocktrim_public_api_client/helpers/locations.py
Inventory Helper¶
Inventory ¶
Bases: Base
Inventory management.
Provides operations for managing inventory levels in StockTrim.
Source code in stocktrim_public_api_client/helpers/base.py
set
async
¶
Set stock on hand and stock on order for products.
Note: The API returns PurchaseOrderResponseDto which seems incorrect for an inventory operation, but we preserve the API's behavior here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory
|
SetInventoryRequest
|
Inventory data to set. |
required |
Returns:
| Type | Description |
|---|---|
PurchaseOrderResponseDto
|
PurchaseOrderResponseDto object (API inconsistency). |
Example
from stocktrim_public_api_client.generated.models import ( ... SetInventoryRequest, ... ) result = await client.inventory.set( ... SetInventoryRequest(product_code="WIDGET-001", quantity=100) ... )
Source code in stocktrim_public_api_client/helpers/inventory.py
set_for_product
async
¶
set_for_product(
product_id: str,
stock_on_hand: float | Unset = UNSET,
stock_on_order: float | Unset = UNSET,
location_code: str | None | Unset = UNSET,
location_name: str | None | Unset = UNSET,
) -> PurchaseOrderResponseDto
Set inventory levels for a single product.
This is a convenience method that simplifies setting inventory for a single product by automatically creating the required request structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_id
|
str
|
The product ID to set inventory for. |
required |
stock_on_hand
|
float | Unset
|
Stock on hand quantity. |
UNSET
|
stock_on_order
|
float | Unset
|
Stock on order quantity. |
UNSET
|
location_code
|
str | None | Unset
|
Optional location code. |
UNSET
|
location_name
|
str | None | Unset
|
Optional location name. |
UNSET
|
Returns:
| Type | Description |
|---|---|
PurchaseOrderResponseDto
|
PurchaseOrderResponseDto object (API inconsistency). |
Example
result = await client.inventory.set_for_product( ... product_id="123", ... stock_on_hand=50.0, ... stock_on_order=100.0, ... location_code="WAREHOUSE-A", ... )