Catalog Entries

This section explains how to interact with catalog entries using the Ottimate SDK.

Fetching Catalog Entries

You can retrieve a list of catalog entries for a specific company. It’s also possible to filter these entries or paginate results.

1# main.py
2
3# Fetch catalog entries for a company
4catalog_entries = client.catalog.get_catalog_entries(
5 ottimate_company_id=ottimate_company_id
6)
7
8print(f"Fetched {len(catalog_entries.results)} catalog entries.")
9for entry in catalog_entries.results:
10 print(f" - Catalog Entry: Ottimate ID: {entry.id} | Name: {entry.description}")

Fetching Catalog Entries with Pagination

1# main.py
2
3catalog_entries = client.catalog.get_catalog_entries(
4 ottimate_company_id=ottimate_company_id,
5 page=1,
6 limit=10
7)

Fetching Catalog Entries with Filters

You can filter catalog entries by vendor, search term, or expand related fields.

1# main.py
2
3# Filter by vendor
4catalog_entries = client.catalog.get_catalog_entries(
5 ottimate_company_id=ottimate_company_id,
6 erp_vendor_id="sample-001"
7)
8
9# Search by term
10catalog_entries = client.catalog.get_catalog_entries(
11 ottimate_company_id=ottimate_company_id,
12 search="test"
13)
14
15# Expand related fields
16catalog_entries = client.catalog.get_catalog_entries(
17 ottimate_company_id=ottimate_company_id,
18 expand="prices,allowances"
19)

Creating a Catalog Entry

This example shows how to create a new catalog entry with required fields.

1# main.py
2
3new_catalog_entry = client.catalog.post_catalog_entries(
4 ottimate_company_id=ottimate_company_id,
5 erp_vendor_id=erp_vendor_id,
6 description=f"SDK Catalog Item {time_now}"
7)
8
9print(f"Created catalog entry with ID: {new_catalog_entry.id}")

Fetching a Single Catalog Entry

You can retrieve a specific catalog entry by its ID.

1# main.py
2
3fetched_entry = client.catalog.get_catalog_entries_id(
4 id=catalog_entry_id
5)
6print(f"Fetched catalog entry: {fetched_entry}")

Updating a Catalog Entry

This shows how to update an existing catalog entry, for example, to change its price or description.

1# main.py
2
3updated_entry = client.catalog.patch_catalog_entries_id(
4 id=catalog_entry_id,
5 description=f"Updated Item {time_now}",
6 price=29.99
7)
8print(f"Updated catalog entry price to: {updated_entry.price}")

Bulk Creating Catalog Entries

You can create multiple catalog entries in a single request.

1# main.py
2
3from ottimate.catalog.types.catalog_entry_bulk_create_request_entries_item import CatalogEntryBulkCreateRequestEntriesItem
4
5entries = [
6 CatalogEntryBulkCreateRequestEntriesItem(
7 erp_vendor_id=erp_vendor_id,
8 description=f"Bulk Item 1 {time_now}",
9 catalog_unique_key=f"bulk-1-{time_now}"
10 ),
11 CatalogEntryBulkCreateRequestEntriesItem(
12 erp_vendor_id=erp_vendor_id,
13 description=f"Bulk Item 2 {time_now}",
14 catalog_unique_key=f"bulk-2-{time_now}"
15 ),
16]
17
18bulk_response = client.catalog.post_catalog_entries_bulk(
19 ottimate_company_id=ottimate_company_id,
20 entries=entries
21)
22
23print(f"Bulk created {bulk_response.success_count} catalog entries.")
24
25# Print details of created entries
26if hasattr(bulk_response, "created") and bulk_response.created:
27 print("Created entries:")
28 for entry in bulk_response.created:
29 print(f" - ID: {entry.get('id')}, Description: {entry.get('description')}")
30
31# Print details of updated entries
32if hasattr(bulk_response, "updated") and bulk_response.updated:
33 print("Updated entries:")
34 for entry in bulk_response.updated:
35 print(f" - ID: {entry.get('id')}, Description: {entry.get('description')}")
36
37# Print details of errors
38if hasattr(bulk_response, "errors") and bulk_response.errors:
39 print("Failed entries:")
40 for error in bulk_response.errors:
41 print(f" - Error: {error}")

Bulk Creating Catalog Entries with Prices

1# main.py
2
3from ottimate.catalog.types.catalog_entry_bulk_create_request_entries_item import CatalogEntryBulkCreateRequestEntriesItem
4
5entries = [
6 CatalogEntryBulkCreateRequestEntriesItem(
7 erp_vendor_id=erp_vendor_id,
8 description=f"Bulk Item Prices {time_now}",
9 catalog_unique_key=f"bulk-prices-{time_now}",
10 prices=[
11 {"price": 19.99, "effective_date": "2024-01-01"},
12 {"price": 21.99, "effective_date": "2024-06-01"},
13 ]
14 ),
15]
16
17bulk_response = client.catalog.post_catalog_entries_bulk(
18 ottimate_company_id=ottimate_company_id,
19 entries=entries
20)