Skip to content

feat(order): add typed request dataclasses for items, shipment, payer, integration_data and transaction_security - #137

Merged
Diego Barajas (barajas-d) merged 12 commits into
masterfrom
feature/order-fields-sdk
Aug 11, 2026
Merged

feat(order): add typed request dataclasses for items, shipment, payer, integration_data and transaction_security#137
Diego Barajas (barajas-d) merged 12 commits into
masterfrom
feature/order-fields-sdk

Conversation

@barajas-d

Copy link
Copy Markdown
Contributor

Descripción

Agrega dataclasses tipadas para el Orders API. Order.create() acepta tanto dict (ruta existente) como instancias de OrderCreateRequest.

Campos agregados (39)

Raíz del Order

description, marketplace, marketplace_fee, expiration_time, checkout_available_at, integration_data

transactions.payments[]

expiration_time, date_of_expiration, payment_method.statement_descriptor

payer

phone.area_code, phone.number, address.zip_code, address.street_name, address.street_number, address.neighborhood, address.state, address.city, address.complement

items[] (completo)

title, unit_price, quantity, description, external_code, picture_url, category_id, type, warranty, event_date

shipment.address

street_name, street_number, zip_code, city, state

integration_data

integrator_id, platform_id, corporation_id, sponsor.id

config.transaction_security

validation, liability_shift

Nuevas clases

OrderItemRequest, OrderPayerPhone, OrderPayerAddress, OrderShipmentRequest, OrderShipmentAddress, OrderShipmentFreeMethod, OrderIntegrationData, OrderSponsor, OrderTransactionSecurity

Compatibilidad

Order.create(dict) funciona igual. Todos los campos Optional con default None.

…er address/phone, transaction_security)

Additive changes; dict path unchanged (backward compatible):
- New dataclasses: OrderItemRequest, OrderShipmentRequest (+OrderShipmentAddress, OrderShipmentFreeMethod),
  OrderPayerPhone, OrderPayerAddress, OrderTransactionSecurity (nested under config.online)
- OrderCreateRequest: adds missing root fields (description, marketplace, marketplace_fee,
  expiration_time, checkout_available_at) and completes payer with phone + address
- order_request_to_dict() helper: recursive asdict() with None-filtering (DD-3)
- order.create() dual-accepts dict or dataclass (converts via order_request_to_dict)
- README: promotes Orders API and references AP example; legacy Payments demoted

All snake_case keys per canonical reference (sdk-go + sdk-dotnet).
16 new offline tests; existing dict path unaffected.

Closes: orders-sdk-typed-request-classes
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…lasses

Order request dataclasses (OrderCreateRequest, OrderPayerRequest,
OrderPayerAddress, OrderShipmentAddress, OrderItemRequest) model
the Orders API contract verbatim — their attribute count is
determined by the API, not by internal design. Added inline
pylint disable with explanatory comment on each affected class.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Line 52 exceeded the 100-char pylint limit enforced by tests/.pylintrc.
Wrapped the parameter list across two lines; no logic change.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ete typed AP chain

Introduces OrderPaymentMethodRequest, OrderPaymentRequest, and
OrderTransactionRequest dataclasses so the full typed chain
OrderCreateRequest → OrderTransactionRequest → OrderPaymentRequest →
automatic_payments / stored_credential / subscription_data is available
without raw dicts.

OrderCreateRequest.transactions now accepts Union[OrderTransactionRequest, dict]
— existing dict-based callers are unaffected.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Keep both feature/order-fields-sdk additions (dataclass support in
create() via order_request_to_dict) and master additions (pagination
iterator import for search_auto_paging_iter).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
master added retry_on and backoff_factor params to HttpClient.post()
(ergonomics retry feature). The test stub was missing them, causing
TypeError on all order create tests after the merge.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Matches the same disable already present on HttpClient.post in
http_client.py after adding retry_on and backoff_factor params.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
When the Order API section was added, the Payment example was split into
its own code block losing the request_options that was part of the
original single example in master.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace order_payer.py with payer.py and move OrderPayerRequest and
OrderIdentification out of order_create.py into the same module.
Remove the "Order" prefix so the classes are reusable across APIs:

  OrderPayerPhone    → PayerPhone
  OrderPayerAddress  → PayerAddress
  OrderIdentification → PayerIdentification
  OrderPayerRequest  → PayerRequest  (moved from order_create.py)

OrderCreateRequest.payer now types PayerRequest. Public __init__.py
exports updated accordingly. No behaviour change — 79 unit tests pass.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace order_item.py/order_shipment.py with item.py/shipment.py and
remove the Order prefix from class names to make them reusable across
APIs (items and shipments appear in Preferences API with similar schema):

  OrderItemRequest     → ItemRequest    (item.py)
  OrderShipmentRequest → ShipmentRequest  (shipment.py)
  OrderShipmentAddress → ShipmentAddress
  OrderShipmentFreeMethod → ShipmentFreeMethod

OrderCreateRequest.items and .shipment updated accordingly.
order_transaction.py keeps the Order prefix — PaymentRequest would clash
with the existing Payment resource and the structure is Orders-API-only.
79 unit tests pass.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…om order_create

After moving PayerRequest to payer.py, order_create.py only needs
PayerRequest — the sub-classes are internal to payer.py.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@barajas-d
Diego Barajas (barajas-d) merged commit 4e5dc4f into master Aug 11, 2026
3 checks passed
@barajas-d
Diego Barajas (barajas-d) deleted the feature/order-fields-sdk branch August 11, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants