Skip to content

Sync SDK with Etsy API spec — createReceiptShipment shipping label fields#25

Merged
amitray007 merged 3 commits intomasterfrom
release/sdk-audit-2026-05-07
May 7, 2026
Merged

Sync SDK with Etsy API spec — createReceiptShipment shipping label fields#25
amitray007 merged 3 commits intomasterfrom
release/sdk-audit-2026-05-07

Conversation

@amitray007
Copy link
Copy Markdown
Owner

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}/tracking for shipping labels, customs, dimensions, and routing.

  • Adds 17 optional kwargs to 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.
  • Introduces CustomsItem TypedDict for the customs_data array element shape (country_of_origin, declared_value, HS_code).
  • Adds 11 string fields plus customs_data to the nullable list so empty values serialize as JSON null per the spec's nullable: true annotation. Float fields (weight, length, width, height, shipping_label_cost, duty_amount) are intentionally excluded so legitimate zero values (free label, no duty) round-trip as 0 rather than being silently nulled.
  • Updates specs/baseline.json to the latest spec snapshot.

Audit results (informational, no code change)

  • TransactionVariations.question_id schema addition is response-only; the SDK does not model response objects.
  • 12 implicit string-concatenation flags on Listing.py, Payment.py, ShippingProfile.py are intentional multi-line DeprecationWarning strings using Python's adjacent-string-literal idiom — concatenated correctly at compile time.
  • 4 "extra SDK methods" are deprecation aliases (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 emit DeprecationWarning and forward to canonical names.
  • CA_HOLIDAYS enum staleness is a script artifact — update_holiday_preferences accepts int directly via Union[HOLIDAYS, US_HOLIDAYS, CA_HOLIDAYS, int], so all 105 spec IDs are usable.
  • State.REMOVED is documented as a backward-compat extension over the spec.

Test plan

  • pytest -v — 246 passed (8 new tests in tests/test_receipt_models.py).
  • python scripts/audit_sdk.py --spec specs/latest.json — no remaining Request Body Drift.
  • Pin-down test asserting weight=0.0, length=0.0, duty_amount=0.0 etc. serialize as 0.0 (not null).
  • Pin-down test asserting empty strings on nullable string fields serialize as JSON null.
  • Pin-down test asserting CustomsItem TypedDict literals are accepted by customs_data.

🤖 Generated with Claude Code

amitray007 and others added 3 commits May 7, 2026 20:43
…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>
Copilot AI review requested due to automatic review settings May 7, 2026 15:24
@amitray007 amitray007 self-assigned this May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Test Coverage Report

Overall: 94% (1563/1670 statements covered)

Coverage by file
File Statements Missing Coverage
etsy_python/v3/auth/OAuth.py 33 33 0%
etsy_python/v3/auth/__init__.py 1 1 0%
etsy_python/v3/enums/Language.py 12 12 0%
etsy_python/v3/models/ProcessingProfile.py 21 10 52%
etsy_python/v3/models/ShopReturnPolicy.py 25 11 56%
etsy_python/v3/resources/ProcessingProfile.py 26 11 58%
etsy_python/v3/models/HolidayPreferences.py 8 2 75%
etsy_python/v3/models/Miscellaneous.py 8 2 75%
etsy_python/v3/common/Utils.py 31 4 87%
etsy_python/v3/exceptions/RequestException.py 8 1 88%
etsy_python/v3/resources/Response.py 9 1 89%
etsy_python/v3/exceptions/BaseAPIException.py 10 1 90%
etsy_python/v3/models/Request.py 22 2 91%
etsy_python/v3/resources/Listing.py 81 6 93%
etsy_python/v3/models/Listing.py 148 9 94%
etsy_python/v3/resources/Session.py 94 1 99%
etsy_python/__init__.py 2 0 100%
etsy_python/_version.py 1 0 100%
etsy_python/v3/common/Env.py 10 0 100%
etsy_python/v3/common/Request.py 3 0 100%
etsy_python/v3/enums/HolidayPreferences.py 29 0 100%
etsy_python/v3/enums/Listing.py 78 0 100%
etsy_python/v3/enums/ListingInventory.py 6 0 100%
etsy_python/v3/enums/ProcessingProfile.py 7 0 100%
etsy_python/v3/enums/ShippingProfile.py 261 0 100%
etsy_python/v3/enums/ShopReceipt.py 12 0 100%
etsy_python/v3/exceptions/__init__.py 2 0 100%
etsy_python/v3/models/FileRequest.py 7 0 100%
etsy_python/v3/models/Product.py 7 0 100%
etsy_python/v3/models/Receipt.py 39 0 100%
etsy_python/v3/models/ShippingProfile.py 85 0 100%
etsy_python/v3/models/Shop.py 24 0 100%
etsy_python/v3/models/Utils.py 19 0 100%
etsy_python/v3/models/__init__.py 10 0 100%
etsy_python/v3/resources/HolidayPreferences.py 19 0 100%
etsy_python/v3/resources/ListingFile.py 22 0 100%
etsy_python/v3/resources/ListingImage.py 22 0 100%
etsy_python/v3/resources/ListingInventory.py 20 0 100%
etsy_python/v3/resources/ListingOffering.py 12 0 100%
etsy_python/v3/resources/ListingProduct.py 12 0 100%
etsy_python/v3/resources/ListingTranslation.py 19 0 100%
etsy_python/v3/resources/ListingVariationImages.py 16 0 100%
etsy_python/v3/resources/ListingVideo.py 22 0 100%
etsy_python/v3/resources/Miscellaneous.py 16 0 100%
etsy_python/v3/resources/Payment.py 23 0 100%
etsy_python/v3/resources/PaymentLedgerEntry.py 15 0 100%
etsy_python/v3/resources/Receipt.py 25 0 100%
etsy_python/v3/resources/ReceiptTransactions.py 27 0 100%
etsy_python/v3/resources/Review.py 16 0 100%
etsy_python/v3/resources/ShippingProfile.py 58 0 100%
etsy_python/v3/resources/Shop.py 23 0 100%
etsy_python/v3/resources/ShopProductionPartner.py 11 0 100%
etsy_python/v3/resources/ShopReturnPolicy.py 28 0 100%
etsy_python/v3/resources/ShopSection.py 25 0 100%
etsy_python/v3/resources/Taxonomy.py 23 0 100%
etsy_python/v3/resources/User.py 14 0 100%
etsy_python/v3/resources/UserAddress.py 19 0 100%
etsy_python/v3/resources/__init__.py 29 0 100%
etsy_python/v3/resources/enums/RateLimit.py 8 0 100%
etsy_python/v3/resources/enums/Request.py 7 0 100%

Updated by PR Tests

@amitray007 amitray007 merged commit 7b6d0bc into master May 7, 2026
8 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CreateReceiptShipmentRequest with new optional shipping label, routing, dimensions, and customs/duty fields; added CustomsItem TypedDict.
  • Updated request nullable-field handling for newly added nullable string/array fields (while intentionally preserving 0.0 for numeric fields).
  • Added regression tests covering inclusion/exclusion rules, nullable empty-string-to-null behavior, zero-float preservation, and CustomsItem usage.
  • Updated specs/baseline.json snapshot 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.

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.

audit: Spec Drift [2026-05-04] — low

2 participants