Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions etsy_python/v3/models/Receipt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
from typing import List, Optional
from typing import List, Optional, TypedDict

from etsy_python.v3.models.Request import Request


class CustomsItem(TypedDict):
# HS_code preserves Etsy's spec casing (Harmonized System code); do not snake_case.
country_of_origin: Optional[str]
declared_value: Optional[float]
HS_code: Optional[str]


class CreateReceiptShipmentRequest(Request):
nullable: List[str] = []
# Spec marks these fields nullable: true. Strings + array are added so callers
# can pass empty values to clear them; floats are intentionally excluded so
# legitimate zero values (free label, zero duty) serialize as 0, not null.
nullable: List[str] = [
"mail_class",
"weight_units",
"dimension_units",
"shipping_label_currency",
"revenue_eligibility",
"ship_from_country",
"ship_to_country",
"incoterm",
"customs_data",
"duty_currency",
"ship_date",
]
mandatory: List[str] = []

def __init__(
Expand All @@ -13,11 +35,45 @@ def __init__(
carrier_name: Optional[str] = None,
send_bcc: Optional[bool] = None,
note_to_buyer: Optional[str] = None,
mail_class: Optional[str] = None,
weight: Optional[float] = None,
weight_units: Optional[str] = None,
length: Optional[float] = None,
width: Optional[float] = None,
height: Optional[float] = None,
dimension_units: Optional[str] = None,
shipping_label_cost: Optional[float] = None,
shipping_label_currency: Optional[str] = None,
revenue_eligibility: Optional[str] = None,
ship_from_country: Optional[str] = None,
ship_to_country: Optional[str] = None,
incoterm: Optional[str] = None,
customs_data: Optional[List[CustomsItem]] = None,
duty_amount: Optional[float] = None,
duty_currency: Optional[str] = None,
ship_date: Optional[str] = None,
):
self.tracking_code = tracking_code
self.carrier_name = carrier_name
self.send_bcc = send_bcc
self.note_to_buyer = note_to_buyer
self.mail_class = mail_class
self.weight = weight
self.weight_units = weight_units
self.length = length
self.width = width
self.height = height
self.dimension_units = dimension_units
self.shipping_label_cost = shipping_label_cost
self.shipping_label_currency = shipping_label_currency
self.revenue_eligibility = revenue_eligibility
self.ship_from_country = ship_from_country
self.ship_to_country = ship_to_country
self.incoterm = incoterm
self.customs_data = customs_data
self.duty_amount = duty_amount
self.duty_currency = duty_currency
self.ship_date = ship_date

super().__init__(
nullable=CreateReceiptShipmentRequest.nullable,
Expand Down
Loading
Loading