Skip to content

Commit 9cd8ba0

Browse files
dougborgDoug Borgclaude
authored
fix(client): align P3 OpenAPI schemas with Katana official API (#267)
Align priority 3 resource schemas with Katana's official API spec: Materials: - Add custom_field_collection_id to CreateMaterialRequest Sales Order Shipping Fee: - Add tax_rate_id to updateSalesOrderShippingFee PATCH endpoint Webhook Logs Export: - Replace start_date/end_date with created_at_min/created_at_max - Replace status_filter array with status_code integer - Add event enum filter with all supported webhook event types - Add delivered boolean filter - Remove format field (no longer supported) Closes #261, #262, #263 Co-authored-by: Doug Borg <dougborg@apple.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ca346ff commit 9cd8ba0

9 files changed

Lines changed: 271 additions & 146 deletions

docs/katana-openapi.yaml

Lines changed: 90 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3532,6 +3532,12 @@ components:
35323532
description: Material configuration options for creating variants
35333533
items:
35343534
$ref: "#/components/schemas/MaterialConfig"
3535+
custom_field_collection_id:
3536+
type:
3537+
- integer
3538+
- "null"
3539+
maximum: 2147483647
3540+
description: ID of the custom field collection to associate with this material
35353541
variants:
35363542
type: array
35373543
minItems: 1
@@ -6539,40 +6545,89 @@ components:
65396545
properties:
65406546
webhook_id:
65416547
type: integer
6542-
description: |-
6543-
Filter logs to specific webhook subscription (optional - if not provided, exports all webhook logs)
6544-
start_date:
6548+
description: Filter logs to specific webhook subscription (optional - if not provided, exports all webhook logs)
6549+
event:
65456550
type: string
6546-
format: date-time
6547-
description: Start date for log export range (ISO 8601 format)
6548-
end_date:
6551+
description: Filter logs by event type
6552+
enum:
6553+
- sales_order.created
6554+
- sales_order.packed
6555+
- sales_order.delivered
6556+
- sales_order.updated
6557+
- sales_order.deleted
6558+
- sales_order.availability_updated
6559+
- purchase_order.created
6560+
- purchase_order.updated
6561+
- purchase_order.deleted
6562+
- purchase_order.partially_received
6563+
- purchase_order.received
6564+
- purchase_order_row.created
6565+
- purchase_order_row.received
6566+
- purchase_order_row.updated
6567+
- purchase_order_row.deleted
6568+
- outsourced_purchase_order.created
6569+
- outsourced_purchase_order.updated
6570+
- outsourced_purchase_order.deleted
6571+
- outsourced_purchase_order.received
6572+
- outsourced_purchase_order_row.created
6573+
- outsourced_purchase_order_row.updated
6574+
- outsourced_purchase_order_row.deleted
6575+
- outsourced_purchase_order_row.received
6576+
- outsourced_purchase_order_recipe_row.created
6577+
- outsourced_purchase_order_recipe_row.updated
6578+
- outsourced_purchase_order_recipe_row.deleted
6579+
- manufacturing_order.created
6580+
- manufacturing_order.updated
6581+
- manufacturing_order.deleted
6582+
- manufacturing_order.in_progress
6583+
- manufacturing_order.blocked
6584+
- manufacturing_order.done
6585+
- manufacturing_order_recipe_row.created
6586+
- manufacturing_order_recipe_row.updated
6587+
- manufacturing_order_recipe_row.deleted
6588+
- manufacturing_order_recipe_row.ingredients_in_stock
6589+
- manufacturing_order_operation_row.created
6590+
- manufacturing_order_operation_row.updated
6591+
- manufacturing_order_operation_row.deleted
6592+
- manufacturing_order_operation_row.in_progress
6593+
- manufacturing_order_operation_row.paused
6594+
- manufacturing_order_operation_row.blocked
6595+
- manufacturing_order_operation_row.completed
6596+
- current_inventory.product_updated
6597+
- current_inventory.material_updated
6598+
- current_inventory.product_out_of_stock
6599+
- current_inventory.material_out_of_stock
6600+
- product.created
6601+
- product.updated
6602+
- product.deleted
6603+
- material.created
6604+
- material.updated
6605+
- material.deleted
6606+
- variant.created
6607+
- variant.updated
6608+
- variant.deleted
6609+
- product_recipe_row.created
6610+
- product_recipe_row.deleted
6611+
- product_recipe_row.updated
6612+
status_code:
6613+
type: integer
6614+
description: Filter logs by HTTP status code
6615+
delivered:
6616+
type: boolean
6617+
description: Filter logs by delivery status (true for successful deliveries)
6618+
created_at_min:
65496619
type: string
6550-
format: date-time
6551-
description: End date for log export range (ISO 8601 format)
6552-
status_filter:
6553-
type: array
6554-
description: Filter logs by delivery status (success, failure, retry)
6555-
items:
6556-
type: string
6557-
enum:
6558-
- success
6559-
- failure
6560-
- retry
6561-
format:
6620+
description: Minimum creation date for log export range (ISO 8601 format)
6621+
created_at_max:
65626622
type: string
6563-
enum:
6564-
- csv
6565-
- json
6566-
default: csv
6567-
description: Export file format preference
6623+
description: Maximum creation date for log export range (ISO 8601 format)
65686624
example:
65696625
webhook_id: 1
6570-
start_date: "2024-01-10T00:00:00Z"
6571-
end_date: "2024-01-15T23:59:59Z"
6572-
status_filter:
6573-
- failure
6574-
- retry
6575-
format: csv
6626+
event: sales_order.created
6627+
status_code: 200
6628+
delivered: true
6629+
created_at_min: "2024-01-10T00:00:00Z"
6630+
created_at_max: "2024-01-15T23:59:59Z"
65766631
WebhookLogsExport:
65776632
type: object
65786633
description: Webhook log export result containing downloadable data for debugging and monitoring webhook delivery
@@ -20043,14 +20098,15 @@ paths:
2004320098
type: object
2004420099
additionalProperties: false
2004520100
properties:
20046-
amount:
20047-
type: number
20048-
format: float
20049-
description: Shipping fee amount
20050-
minimum: 0
2005120101
description:
2005220102
type: string
2005320103
description: Shipping fee description
20104+
amount:
20105+
type: integer
20106+
description: Shipping fee amount
20107+
tax_rate_id:
20108+
type: integer
20109+
description: ID of the tax rate to apply to the shipping fee
2005420110
responses:
2005520111
"200":
2005620112
description: Sales order shipping fee updated successfully

katana_public_api_client/api/webhook_logs/export_webhook_logs.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ def sync_detailed(
8989
9090
Args:
9191
body (WebhookLogsExportRequest): Request parameters for exporting webhook delivery logs
92-
for analysis and debugging Example: {'webhook_id': 1, 'start_date':
93-
'2024-01-10T00:00:00Z', 'end_date': '2024-01-15T23:59:59Z', 'status_filter': ['failure',
94-
'retry'], 'format': 'csv'}.
92+
for analysis and debugging Example: {'webhook_id': 1, 'event': 'sales_order.created',
93+
'status_code': 200, 'delivered': True, 'created_at_min': '2024-01-10T00:00:00Z',
94+
'created_at_max': '2024-01-15T23:59:59Z'}.
9595
9696
Raises:
9797
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -126,9 +126,9 @@ def sync(
126126
127127
Args:
128128
body (WebhookLogsExportRequest): Request parameters for exporting webhook delivery logs
129-
for analysis and debugging Example: {'webhook_id': 1, 'start_date':
130-
'2024-01-10T00:00:00Z', 'end_date': '2024-01-15T23:59:59Z', 'status_filter': ['failure',
131-
'retry'], 'format': 'csv'}.
129+
for analysis and debugging Example: {'webhook_id': 1, 'event': 'sales_order.created',
130+
'status_code': 200, 'delivered': True, 'created_at_min': '2024-01-10T00:00:00Z',
131+
'created_at_max': '2024-01-15T23:59:59Z'}.
132132
133133
Raises:
134134
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -158,9 +158,9 @@ async def asyncio_detailed(
158158
159159
Args:
160160
body (WebhookLogsExportRequest): Request parameters for exporting webhook delivery logs
161-
for analysis and debugging Example: {'webhook_id': 1, 'start_date':
162-
'2024-01-10T00:00:00Z', 'end_date': '2024-01-15T23:59:59Z', 'status_filter': ['failure',
163-
'retry'], 'format': 'csv'}.
161+
for analysis and debugging Example: {'webhook_id': 1, 'event': 'sales_order.created',
162+
'status_code': 200, 'delivered': True, 'created_at_min': '2024-01-10T00:00:00Z',
163+
'created_at_max': '2024-01-15T23:59:59Z'}.
164164
165165
Raises:
166166
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -193,9 +193,9 @@ async def asyncio(
193193
194194
Args:
195195
body (WebhookLogsExportRequest): Request parameters for exporting webhook delivery logs
196-
for analysis and debugging Example: {'webhook_id': 1, 'start_date':
197-
'2024-01-10T00:00:00Z', 'end_date': '2024-01-15T23:59:59Z', 'status_filter': ['failure',
198-
'retry'], 'format': 'csv'}.
196+
for analysis and debugging Example: {'webhook_id': 1, 'event': 'sales_order.created',
197+
'status_code': 200, 'delivered': True, 'created_at_min': '2024-01-10T00:00:00Z',
198+
'created_at_max': '2024-01-15T23:59:59Z'}.
199199
200200
Raises:
201201
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

katana_public_api_client/models/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,7 @@
535535
from .webhook_list_response import WebhookListResponse
536536
from .webhook_logs_export import WebhookLogsExport
537537
from .webhook_logs_export_request import WebhookLogsExportRequest
538-
from .webhook_logs_export_request_format import WebhookLogsExportRequestFormat
539-
from .webhook_logs_export_request_status_filter_item import (
540-
WebhookLogsExportRequestStatusFilterItem,
541-
)
538+
from .webhook_logs_export_request_event import WebhookLogsExportRequestEvent
542539

543540
__all__ = (
544541
"AdditionalCost",
@@ -906,6 +903,5 @@
906903
"WebhookListResponse",
907904
"WebhookLogsExport",
908905
"WebhookLogsExportRequest",
909-
"WebhookLogsExportRequestFormat",
910-
"WebhookLogsExportRequestStatusFilterItem",
906+
"WebhookLogsExportRequestEvent",
911907
)

katana_public_api_client/models/create_material_request.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Mapping
4-
from typing import TYPE_CHECKING, Any, TypeVar
4+
from typing import TYPE_CHECKING, Any, TypeVar, cast
55

66
from attrs import define as _attrs_define
77

@@ -40,6 +40,7 @@ class CreateMaterialRequest:
4040
purchase_uom: str | Unset = UNSET
4141
purchase_uom_conversion_rate: float | Unset = UNSET
4242
configs: list[MaterialConfig] | Unset = UNSET
43+
custom_field_collection_id: int | None | Unset = UNSET
4344

4445
def to_dict(self) -> dict[str, Any]:
4546
name = self.name
@@ -72,6 +73,12 @@ def to_dict(self) -> dict[str, Any]:
7273
configs_item = configs_item_data.to_dict()
7374
configs.append(configs_item)
7475

76+
custom_field_collection_id: int | None | Unset
77+
if isinstance(self.custom_field_collection_id, Unset):
78+
custom_field_collection_id = UNSET
79+
else:
80+
custom_field_collection_id = self.custom_field_collection_id
81+
7582
field_dict: dict[str, Any] = {}
7683

7784
field_dict.update(
@@ -98,6 +105,8 @@ def to_dict(self) -> dict[str, Any]:
98105
field_dict["purchase_uom_conversion_rate"] = purchase_uom_conversion_rate
99106
if configs is not UNSET:
100107
field_dict["configs"] = configs
108+
if custom_field_collection_id is not UNSET:
109+
field_dict["custom_field_collection_id"] = custom_field_collection_id
101110

102111
return field_dict
103112

@@ -141,6 +150,17 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
141150

142151
configs.append(configs_item)
143152

153+
def _parse_custom_field_collection_id(data: object) -> int | None | Unset:
154+
if data is None:
155+
return data
156+
if isinstance(data, Unset):
157+
return data
158+
return cast(int | None | Unset, data)
159+
160+
custom_field_collection_id = _parse_custom_field_collection_id(
161+
d.pop("custom_field_collection_id", UNSET)
162+
)
163+
144164
create_material_request = cls(
145165
name=name,
146166
variants=variants,
@@ -153,6 +173,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
153173
purchase_uom=purchase_uom,
154174
purchase_uom_conversion_rate=purchase_uom_conversion_rate,
155175
configs=configs,
176+
custom_field_collection_id=custom_field_collection_id,
156177
)
157178

158179
return create_material_request

katana_public_api_client/models/update_sales_order_shipping_fee_body.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,42 @@
1212

1313
@_attrs_define
1414
class UpdateSalesOrderShippingFeeBody:
15-
amount: float | Unset = UNSET
1615
description: str | Unset = UNSET
16+
amount: int | Unset = UNSET
17+
tax_rate_id: int | Unset = UNSET
1718

1819
def to_dict(self) -> dict[str, Any]:
20+
description = self.description
21+
1922
amount = self.amount
2023

21-
description = self.description
24+
tax_rate_id = self.tax_rate_id
2225

2326
field_dict: dict[str, Any] = {}
2427

2528
field_dict.update({})
26-
if amount is not UNSET:
27-
field_dict["amount"] = amount
2829
if description is not UNSET:
2930
field_dict["description"] = description
31+
if amount is not UNSET:
32+
field_dict["amount"] = amount
33+
if tax_rate_id is not UNSET:
34+
field_dict["tax_rate_id"] = tax_rate_id
3035

3136
return field_dict
3237

3338
@classmethod
3439
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
3540
d = dict(src_dict)
41+
description = d.pop("description", UNSET)
42+
3643
amount = d.pop("amount", UNSET)
3744

38-
description = d.pop("description", UNSET)
45+
tax_rate_id = d.pop("tax_rate_id", UNSET)
3946

4047
update_sales_order_shipping_fee_body = cls(
41-
amount=amount,
4248
description=description,
49+
amount=amount,
50+
tax_rate_id=tax_rate_id,
4351
)
4452

4553
return update_sales_order_shipping_fee_body

0 commit comments

Comments
 (0)