Sync SDK with Etsy API spec — createReceiptShipment shipping label fields#25
Merged
amitray007 merged 3 commits intomasterfrom May 7, 2026
Merged
Sync SDK with Etsy API spec — createReceiptShipment shipping label fields#25amitray007 merged 3 commits intomasterfrom
amitray007 merged 3 commits intomasterfrom
Conversation
…teReceiptShipment
Adds 17 new optional fields to CreateReceiptShipmentRequest matching the latest
Etsy OAS spec for POST /shops/{shop_id}/receipts/{receipt_id}/tracking:
mail_class, weight, weight_units, length, width, height, dimension_units,
shipping_label_cost, shipping_label_currency, revenue_eligibility,
ship_from_country, ship_to_country, incoterm, customs_data, duty_amount,
duty_currency, ship_date.
customs_data uses List[Dict[str, Any]] following existing SDK pattern for nested
array-of-objects request bodies. Includes test coverage for shipping label,
customs/duty, and exclusion-when-None paths. Updates baseline spec.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… zero-float test Adds CustomsItem TypedDict for customs_data items, giving callers IDE/type-checker completion for the country_of_origin / declared_value / HS_code shape. Plain dicts still work via Union[CustomsItem, dict]. Adds 11 string fields plus customs_data to the nullable list so empty strings/lists serialize to JSON null (matching nullable: true in the OAS spec). Float fields (weight, length, width, height, shipping_label_cost, duty_amount) are intentionally excluded so legitimate zero values (free shipping label, no duty) round-trip as 0 rather than being silently nulled. Adds three tests pinning down the contract: zero-float serialization, empty-string to-null normalization, and CustomsItem TypedDict acceptance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… casing The previous Union[CustomsItem, dict] reduced to dict for type checkers since TypedDict is structurally a dict at runtime, erasing the IDE/mypy benefit CustomsItem was added to provide. List[CustomsItem] gives callers proper completion; plain dict literals matching the shape still work at runtime. Adds a one-line comment noting HS_code preserves Etsy's spec casing (Harmonized System code), so future contributors don't snake_case it. Skipped reviewer suggestion to migrate Optional/List/Union to PEP 604/585 syntax — the rest of the SDK is consistent in the older style, so this would be a project-wide refactor outside this PR's scope. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Test Coverage ReportOverall: 94% (1563/1670 statements covered) Coverage by file
Updated by PR Tests |
There was a problem hiding this comment.
Pull request overview
Syncs the SDK’s create_receipt_shipment request model with the latest Etsy OAS spec by adding new optional shipping-label/tracking fields and validating serialization behavior (notably nullable string normalization vs. preserving numeric zeros).
Changes:
- Extended
CreateReceiptShipmentRequestwith new optional shipping label, routing, dimensions, and customs/duty fields; addedCustomsItemTypedDict. - Updated request nullable-field handling for newly added nullable string/array fields (while intentionally preserving
0.0for numeric fields). - Added regression tests covering inclusion/exclusion rules, nullable empty-string-to-null behavior, zero-float preservation, and
CustomsItemusage. - Updated
specs/baseline.jsonsnapshot to the 2026-05-07 spec.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
etsy_python/v3/models/Receipt.py |
Adds CustomsItem and new CreateReceiptShipmentRequest kwargs + nullable list updates for spec sync. |
tests/test_receipt_models.py |
Adds tests for new request fields and serialization/nullability semantics. |
specs/baseline.json |
Updates the stored OAS baseline snapshot, including the expanded tracking request schema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #24.
Sync SDK with the latest Etsy OAS spec (fetched 2026-05-07). The spec added 17 new optional fields to
POST /shops/{shop_id}/receipts/{receipt_id}/trackingfor shipping labels, customs, dimensions, and routing.CreateReceiptShipmentRequest:mail_class,weight,weight_units,length,width,height,dimension_units,shipping_label_cost,shipping_label_currency,revenue_eligibility,ship_from_country,ship_to_country,incoterm,customs_data,duty_amount,duty_currency,ship_date.CustomsItemTypedDictfor thecustoms_dataarray element shape (country_of_origin,declared_value,HS_code).customs_datato thenullablelist so empty values serialize as JSON null per the spec'snullable: trueannotation. Float fields (weight,length,width,height,shipping_label_cost,duty_amount) are intentionally excluded so legitimate zero values (free label, no duty) round-trip as0rather than being silently nulled.specs/baseline.jsonto the latest spec snapshot.Audit results (informational, no code change)
TransactionVariations.question_idschema addition is response-only; the SDK does not model response objects.Listing.py,Payment.py,ShippingProfile.pyare intentional multi-lineDeprecationWarningstrings using Python's adjacent-string-literal idiom — concatenated correctly at compile time.get_listings_by_listings_ids,get_shop_payment_account_ledger_entry_payments,get_shop_receipt_transaction_by_shop,get_shop_shipping_profile_destination_by_shipping_profile) that emitDeprecationWarningand forward to canonical names.CA_HOLIDAYSenum staleness is a script artifact —update_holiday_preferencesacceptsintdirectly viaUnion[HOLIDAYS, US_HOLIDAYS, CA_HOLIDAYS, int], so all 105 spec IDs are usable.State.REMOVEDis documented as a backward-compat extension over the spec.Test plan
pytest -v— 246 passed (8 new tests intests/test_receipt_models.py).python scripts/audit_sdk.py --spec specs/latest.json— no remaining Request Body Drift.weight=0.0,length=0.0,duty_amount=0.0etc. serialize as0.0(not null).null.CustomsItemTypedDict literals are accepted bycustoms_data.🤖 Generated with Claude Code