|
13 | 13 | from .common import ImportResource
|
14 | 14 |
|
15 | 15 | if typing.TYPE_CHECKING:
|
16 |
| - from .common import Address, CustomerGroupKeyReference, StoreKeyReference |
| 16 | + from .common import CustomerGroupKeyReference, StoreKeyReference |
17 | 17 | from .customfields import Custom
|
18 | 18 |
|
19 |
| -__all__ = ["CustomerImport"] |
| 19 | +__all__ = ["CustomerAddress", "CustomerImport"] |
| 20 | + |
| 21 | + |
| 22 | +class CustomerAddress(_BaseType): |
| 23 | + """Different from Address in that `key` is required and `id` is not supported.""" |
| 24 | + |
| 25 | + #: User-defined identifier for the address. |
| 26 | + #: It must follow the pattern [a-zA-Z0-9_\-]{2,256}, and unique per customer. |
| 27 | + key: str |
| 28 | + title: typing.Optional[str] |
| 29 | + salutation: typing.Optional[str] |
| 30 | + first_name: typing.Optional[str] |
| 31 | + last_name: typing.Optional[str] |
| 32 | + street_name: typing.Optional[str] |
| 33 | + street_number: typing.Optional[str] |
| 34 | + additional_street_info: typing.Optional[str] |
| 35 | + postal_code: typing.Optional[str] |
| 36 | + city: typing.Optional[str] |
| 37 | + region: typing.Optional[str] |
| 38 | + state: typing.Optional[str] |
| 39 | + #: A two-digit country code as per [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). |
| 40 | + country: str |
| 41 | + company: typing.Optional[str] |
| 42 | + department: typing.Optional[str] |
| 43 | + building: typing.Optional[str] |
| 44 | + apartment: typing.Optional[str] |
| 45 | + p_o_box: typing.Optional[str] |
| 46 | + phone: typing.Optional[str] |
| 47 | + mobile: typing.Optional[str] |
| 48 | + email: typing.Optional[str] |
| 49 | + fax: typing.Optional[str] |
| 50 | + additional_address_info: typing.Optional[str] |
| 51 | + external_id: typing.Optional[str] |
| 52 | + |
| 53 | + def __init__( |
| 54 | + self, |
| 55 | + *, |
| 56 | + key: str, |
| 57 | + title: typing.Optional[str] = None, |
| 58 | + salutation: typing.Optional[str] = None, |
| 59 | + first_name: typing.Optional[str] = None, |
| 60 | + last_name: typing.Optional[str] = None, |
| 61 | + street_name: typing.Optional[str] = None, |
| 62 | + street_number: typing.Optional[str] = None, |
| 63 | + additional_street_info: typing.Optional[str] = None, |
| 64 | + postal_code: typing.Optional[str] = None, |
| 65 | + city: typing.Optional[str] = None, |
| 66 | + region: typing.Optional[str] = None, |
| 67 | + state: typing.Optional[str] = None, |
| 68 | + country: str, |
| 69 | + company: typing.Optional[str] = None, |
| 70 | + department: typing.Optional[str] = None, |
| 71 | + building: typing.Optional[str] = None, |
| 72 | + apartment: typing.Optional[str] = None, |
| 73 | + p_o_box: typing.Optional[str] = None, |
| 74 | + phone: typing.Optional[str] = None, |
| 75 | + mobile: typing.Optional[str] = None, |
| 76 | + email: typing.Optional[str] = None, |
| 77 | + fax: typing.Optional[str] = None, |
| 78 | + additional_address_info: typing.Optional[str] = None, |
| 79 | + external_id: typing.Optional[str] = None |
| 80 | + ): |
| 81 | + self.key = key |
| 82 | + self.title = title |
| 83 | + self.salutation = salutation |
| 84 | + self.first_name = first_name |
| 85 | + self.last_name = last_name |
| 86 | + self.street_name = street_name |
| 87 | + self.street_number = street_number |
| 88 | + self.additional_street_info = additional_street_info |
| 89 | + self.postal_code = postal_code |
| 90 | + self.city = city |
| 91 | + self.region = region |
| 92 | + self.state = state |
| 93 | + self.country = country |
| 94 | + self.company = company |
| 95 | + self.department = department |
| 96 | + self.building = building |
| 97 | + self.apartment = apartment |
| 98 | + self.p_o_box = p_o_box |
| 99 | + self.phone = phone |
| 100 | + self.mobile = mobile |
| 101 | + self.email = email |
| 102 | + self.fax = fax |
| 103 | + self.additional_address_info = additional_address_info |
| 104 | + self.external_id = external_id |
| 105 | + super().__init__() |
| 106 | + |
| 107 | + @classmethod |
| 108 | + def deserialize(cls, data: typing.Dict[str, typing.Any]) -> "CustomerAddress": |
| 109 | + from ._schemas.customers import CustomerAddressSchema |
| 110 | + |
| 111 | + return CustomerAddressSchema().load(data) |
| 112 | + |
| 113 | + def serialize(self) -> typing.Dict[str, typing.Any]: |
| 114 | + from ._schemas.customers import CustomerAddressSchema |
| 115 | + |
| 116 | + return CustomerAddressSchema().dump(self) |
20 | 117 |
|
21 | 118 |
|
22 | 119 | class CustomerImport(ImportResource):
|
@@ -61,7 +158,7 @@ class CustomerImport(ImportResource):
|
61 | 158 | #: import operation state is set to `Unresolved`.
|
62 | 159 | customer_group: typing.Optional["CustomerGroupKeyReference"]
|
63 | 160 | #: Maps to `Customer.addresses`.
|
64 |
| - addresses: typing.Optional[typing.List["Address"]] |
| 161 | + addresses: typing.List["CustomerAddress"] |
65 | 162 | #: The index of the address in the addresses array. The `defaultBillingAddressId` of the customer will be set to the ID of that address.
|
66 | 163 | default_billing_address: typing.Optional[int]
|
67 | 164 | #: The indices of the billing addresses in the addresses array. The `billingAddressIds` of the customer will be set to the IDs of that addresses.
|
@@ -94,7 +191,7 @@ def __init__(
|
94 | 191 | vat_id: typing.Optional[str] = None,
|
95 | 192 | is_email_verified: typing.Optional[bool] = None,
|
96 | 193 | customer_group: typing.Optional["CustomerGroupKeyReference"] = None,
|
97 |
| - addresses: typing.Optional[typing.List["Address"]] = None, |
| 194 | + addresses: typing.List["CustomerAddress"], |
98 | 195 | default_billing_address: typing.Optional[int] = None,
|
99 | 196 | billing_addresses: typing.Optional[typing.List["int"]] = None,
|
100 | 197 | default_shipping_address: typing.Optional[int] = None,
|
|
0 commit comments