shopware-api-client 1.0.101__py3-none-any.whl → 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shopware_api_client/base.py +490 -202
- shopware_api_client/cache.py +157 -0
- shopware_api_client/client.py +2 -2
- shopware_api_client/config.py +4 -3
- shopware_api_client/endpoints/admin/__init__.py +20 -4
- shopware_api_client/endpoints/admin/commercial/b2b_components_role.py +5 -20
- shopware_api_client/endpoints/admin/commercial/b2b_components_shopping_list.py +22 -0
- shopware_api_client/endpoints/admin/commercial/b2b_components_shopping_list_line_item.py +20 -0
- shopware_api_client/endpoints/admin/commercial/b2b_employee.py +5 -27
- shopware_api_client/endpoints/admin/commercial/dynamic_access.py +9 -19
- shopware_api_client/endpoints/admin/core/acl_role.py +5 -19
- shopware_api_client/endpoints/admin/core/api_info.py +11 -12
- shopware_api_client/endpoints/admin/core/app.py +5 -42
- shopware_api_client/endpoints/admin/core/app_script_condition.py +5 -24
- shopware_api_client/endpoints/admin/core/category.py +5 -56
- shopware_api_client/endpoints/admin/core/cms_block.py +5 -34
- shopware_api_client/endpoints/admin/core/cms_page.py +5 -26
- shopware_api_client/endpoints/admin/core/cms_section.py +5 -35
- shopware_api_client/endpoints/admin/core/cms_slot.py +5 -31
- shopware_api_client/endpoints/admin/core/country.py +5 -37
- shopware_api_client/endpoints/admin/core/country_state.py +5 -23
- shopware_api_client/endpoints/admin/core/currency.py +5 -33
- shopware_api_client/endpoints/admin/core/currency_country_rounding.py +5 -20
- shopware_api_client/endpoints/admin/core/custom_entity.py +4 -26
- shopware_api_client/endpoints/admin/core/custom_field.py +4 -14
- shopware_api_client/endpoints/admin/core/customer.py +5 -57
- shopware_api_client/endpoints/admin/core/customer_address.py +6 -33
- shopware_api_client/endpoints/admin/core/customer_group.py +5 -24
- shopware_api_client/endpoints/admin/core/customer_recovery.py +5 -16
- shopware_api_client/endpoints/admin/core/customer_wishlist.py +5 -19
- shopware_api_client/endpoints/admin/core/customer_wishlist_product.py +5 -19
- shopware_api_client/endpoints/admin/core/delivery_time.py +5 -21
- shopware_api_client/endpoints/admin/core/document.py +5 -28
- shopware_api_client/endpoints/admin/core/document_base_config.py +5 -27
- shopware_api_client/endpoints/admin/core/document_base_config_sales_channel.py +7 -20
- shopware_api_client/endpoints/admin/core/document_type.py +5 -19
- shopware_api_client/endpoints/admin/core/integration.py +5 -25
- shopware_api_client/endpoints/admin/core/landing_page.py +5 -28
- shopware_api_client/endpoints/admin/core/language.py +5 -21
- shopware_api_client/endpoints/admin/core/locale.py +5 -20
- shopware_api_client/endpoints/admin/core/main_category.py +5 -19
- shopware_api_client/endpoints/admin/core/media.py +25 -37
- shopware_api_client/endpoints/admin/core/media_default_folder.py +4 -17
- shopware_api_client/endpoints/admin/core/media_folder.py +5 -26
- shopware_api_client/endpoints/admin/core/media_folder_configuration.py +5 -21
- shopware_api_client/endpoints/admin/core/media_thumbnail.py +5 -24
- shopware_api_client/endpoints/admin/core/media_thumbnail_size.py +7 -18
- shopware_api_client/endpoints/admin/core/order.py +12 -48
- shopware_api_client/endpoints/admin/core/order_address.py +6 -34
- shopware_api_client/endpoints/admin/core/order_customer.py +6 -29
- shopware_api_client/endpoints/admin/core/order_delivery.py +5 -30
- shopware_api_client/endpoints/admin/core/order_delivery_position.py +5 -26
- shopware_api_client/endpoints/admin/core/order_line_item.py +7 -44
- shopware_api_client/endpoints/admin/core/order_line_item_download.py +5 -23
- shopware_api_client/endpoints/admin/core/order_transaction.py +5 -25
- shopware_api_client/endpoints/admin/core/order_transaction_capture.py +5 -27
- shopware_api_client/endpoints/admin/core/order_transaction_capture_refund.py +7 -28
- shopware_api_client/endpoints/admin/core/order_transaction_capture_refund_position.py +8 -29
- shopware_api_client/endpoints/admin/core/payment_method.py +5 -52
- shopware_api_client/endpoints/admin/core/product.py +24 -90
- shopware_api_client/endpoints/admin/core/product_configurator_setting.py +5 -26
- shopware_api_client/endpoints/admin/core/product_cross_selling.py +5 -27
- shopware_api_client/endpoints/admin/core/product_cross_selling_assigned_products.py +7 -21
- shopware_api_client/endpoints/admin/core/product_download.py +5 -22
- shopware_api_client/endpoints/admin/core/product_export.py +5 -34
- shopware_api_client/endpoints/admin/core/product_feature_set.py +5 -19
- shopware_api_client/endpoints/admin/core/product_manufacturer.py +5 -23
- shopware_api_client/endpoints/admin/core/product_media.py +5 -22
- shopware_api_client/endpoints/admin/core/product_price.py +5 -24
- shopware_api_client/endpoints/admin/core/product_review.py +5 -29
- shopware_api_client/endpoints/admin/core/product_search_keyword.py +5 -20
- shopware_api_client/endpoints/admin/core/product_stream.py +5 -23
- shopware_api_client/endpoints/admin/core/product_visibility.py +5 -18
- shopware_api_client/endpoints/admin/core/product_warehouse.py +5 -17
- shopware_api_client/endpoints/admin/core/promotion.py +5 -38
- shopware_api_client/endpoints/admin/core/promotion_discount.py +5 -24
- shopware_api_client/endpoints/admin/core/promotion_discount_prices.py +5 -19
- shopware_api_client/endpoints/admin/core/property_group.py +5 -24
- shopware_api_client/endpoints/admin/core/property_group_option.py +5 -23
- shopware_api_client/endpoints/admin/core/rule.py +5 -24
- shopware_api_client/endpoints/admin/core/rule_condition.py +5 -23
- shopware_api_client/endpoints/admin/core/sales_channel.py +6 -53
- shopware_api_client/endpoints/admin/core/sales_channel_domain.py +5 -23
- shopware_api_client/endpoints/admin/core/salutation.py +5 -20
- shopware_api_client/endpoints/admin/core/seo_url.py +5 -30
- shopware_api_client/endpoints/admin/core/shipping_method.py +8 -30
- shopware_api_client/endpoints/admin/core/shipping_method_price.py +20 -0
- shopware_api_client/endpoints/admin/core/state_machine.py +5 -21
- shopware_api_client/endpoints/admin/core/state_machine_history.py +5 -25
- shopware_api_client/endpoints/admin/core/state_machine_state.py +6 -20
- shopware_api_client/endpoints/admin/core/state_machine_transition.py +5 -23
- shopware_api_client/endpoints/admin/core/system_config.py +5 -19
- shopware_api_client/endpoints/admin/core/tag.py +5 -14
- shopware_api_client/endpoints/admin/core/tax.py +5 -21
- shopware_api_client/endpoints/admin/core/tax_rule.py +5 -22
- shopware_api_client/endpoints/admin/core/tax_rule_type.py +5 -21
- shopware_api_client/endpoints/admin/core/unit.py +5 -19
- shopware_api_client/endpoints/admin/core/user.py +5 -31
- shopware_api_client/endpoints/admin/core/warehouse.py +5 -15
- shopware_api_client/endpoints/admin/core/warehouse_group.py +6 -18
- shopware_api_client/endpoints/admin/core/warehouse_group_warehouse.py +6 -18
- shopware_api_client/endpoints/base_fields.py +13 -22
- shopware_api_client/endpoints/relations.py +36 -24
- shopware_api_client/endpoints/store/__init__.py +37 -4
- shopware_api_client/endpoints/store/core/address.py +51 -68
- shopware_api_client/endpoints/store/core/cart.py +39 -85
- shopware_api_client/endpoints/store/core/category.py +16 -0
- shopware_api_client/endpoints/store/core/cms_block.py +10 -0
- shopware_api_client/endpoints/store/core/cms_page.py +12 -0
- shopware_api_client/endpoints/store/core/cms_section.py +12 -0
- shopware_api_client/endpoints/store/core/cms_slot.py +8 -0
- shopware_api_client/endpoints/store/core/context.py +58 -0
- shopware_api_client/endpoints/store/core/country.py +15 -0
- shopware_api_client/endpoints/store/core/country_state.py +19 -0
- shopware_api_client/endpoints/store/core/currency.py +12 -0
- shopware_api_client/endpoints/store/core/customer.py +34 -0
- shopware_api_client/endpoints/store/core/customer_group.py +5 -0
- shopware_api_client/endpoints/store/core/delivery_time.py +5 -0
- shopware_api_client/endpoints/store/core/document.py +15 -0
- shopware_api_client/endpoints/store/core/document_type.py +5 -0
- shopware_api_client/endpoints/store/core/landing_page.py +10 -0
- shopware_api_client/endpoints/store/core/language.py +18 -0
- shopware_api_client/endpoints/store/core/locale.py +5 -0
- shopware_api_client/endpoints/store/core/main_category.py +5 -0
- shopware_api_client/endpoints/store/core/media.py +8 -0
- shopware_api_client/endpoints/store/core/media_thumbnail.py +5 -0
- shopware_api_client/endpoints/store/core/order.py +67 -0
- shopware_api_client/endpoints/store/core/order_address.py +12 -0
- shopware_api_client/endpoints/store/core/order_customer.py +8 -0
- shopware_api_client/endpoints/store/core/order_delivery.py +14 -0
- shopware_api_client/endpoints/store/core/order_delivery_position.py +5 -0
- shopware_api_client/endpoints/store/core/order_line_item.py +14 -0
- shopware_api_client/endpoints/store/core/order_transaction.py +12 -0
- shopware_api_client/endpoints/store/core/order_transaction_capture.py +12 -0
- shopware_api_client/endpoints/store/core/order_transaction_capture_refund.py +12 -0
- shopware_api_client/endpoints/store/core/order_transaction_capture_refund_position.py +11 -0
- shopware_api_client/endpoints/store/core/payment_method.py +8 -0
- shopware_api_client/endpoints/store/core/product.py +60 -0
- shopware_api_client/endpoints/store/core/product_configurator_setting.py +10 -0
- shopware_api_client/endpoints/store/core/product_cross_selling.py +5 -0
- shopware_api_client/endpoints/store/core/product_download.py +10 -0
- shopware_api_client/endpoints/store/core/product_manufacturer.py +8 -0
- shopware_api_client/endpoints/store/core/product_media.py +10 -0
- shopware_api_client/endpoints/store/core/product_review.py +5 -0
- shopware_api_client/endpoints/store/core/product_stream.py +5 -0
- shopware_api_client/endpoints/store/core/property_group.py +8 -0
- shopware_api_client/endpoints/store/core/property_group_option.py +10 -0
- shopware_api_client/endpoints/store/core/rule.py +5 -0
- shopware_api_client/endpoints/store/core/sales_channel.py +23 -0
- shopware_api_client/endpoints/store/core/sales_channel_domain.py +12 -0
- shopware_api_client/endpoints/store/core/salutation.py +12 -0
- shopware_api_client/endpoints/store/core/seo_url.py +5 -0
- shopware_api_client/endpoints/store/core/shipping_method.py +18 -0
- shopware_api_client/endpoints/store/core/shipping_method_price.py +5 -0
- shopware_api_client/endpoints/store/core/state_machine_state.py +5 -0
- shopware_api_client/endpoints/store/core/tag.py +5 -0
- shopware_api_client/endpoints/store/core/tax.py +5 -0
- shopware_api_client/endpoints/store/core/unit.py +5 -0
- shopware_api_client/exceptions.py +21 -1
- shopware_api_client/fieldsets.py +12 -0
- shopware_api_client/models/__init__.py +0 -0
- shopware_api_client/models/acl_role.py +11 -0
- shopware_api_client/models/app.py +33 -0
- shopware_api_client/models/app_script_condition.py +16 -0
- shopware_api_client/models/b2b_components_role.py +12 -0
- shopware_api_client/models/b2b_components_shopping_list.py +13 -0
- shopware_api_client/models/b2b_components_shopping_list_line_item.py +14 -0
- shopware_api_client/models/b2b_employee.py +17 -0
- shopware_api_client/models/category.py +44 -0
- shopware_api_client/models/cms_block.py +23 -0
- shopware_api_client/models/cms_page.py +15 -0
- shopware_api_client/models/cms_section.py +20 -0
- shopware_api_client/models/cms_slot.py +17 -0
- shopware_api_client/models/country.py +27 -0
- shopware_api_client/models/country_state.py +12 -0
- shopware_api_client/models/currency.py +20 -0
- shopware_api_client/models/currency_country_rounding.py +11 -0
- shopware_api_client/models/custom_entity.py +19 -0
- shopware_api_client/models/custom_field.py +8 -0
- shopware_api_client/models/customer.py +47 -0
- shopware_api_client/models/customer_address.py +22 -0
- shopware_api_client/models/customer_group.py +13 -0
- shopware_api_client/models/customer_recovery.py +9 -0
- shopware_api_client/models/customer_wishlist.py +9 -0
- shopware_api_client/models/customer_wishlist_product.py +10 -0
- shopware_api_client/models/delivery_time.py +12 -0
- shopware_api_client/models/document.py +20 -0
- shopware_api_client/models/document_base_config.py +19 -0
- shopware_api_client/models/document_base_config_sales_channel.py +10 -0
- shopware_api_client/models/document_type.py +8 -0
- shopware_api_client/models/dynamic_access.py +9 -0
- shopware_api_client/models/integration.py +15 -0
- shopware_api_client/models/landing_page.py +15 -0
- shopware_api_client/models/language.py +11 -0
- shopware_api_client/models/locale.py +9 -0
- shopware_api_client/models/main_category.py +12 -0
- shopware_api_client/models/media.py +26 -0
- shopware_api_client/models/media_default_folder.py +7 -0
- shopware_api_client/models/media_folder.py +16 -0
- shopware_api_client/models/media_folder_configuration.py +11 -0
- shopware_api_client/models/media_thumbnail.py +15 -0
- shopware_api_client/models/media_thumbnail_size.py +8 -0
- shopware_api_client/models/order.py +36 -0
- shopware_api_client/models/order_address.py +23 -0
- shopware_api_client/models/order_customer.py +18 -0
- shopware_api_client/models/order_delivery.py +19 -0
- shopware_api_client/models/order_delivery_position.py +15 -0
- shopware_api_client/models/order_line_item.py +34 -0
- shopware_api_client/models/order_line_item_download.py +12 -0
- shopware_api_client/models/order_transaction.py +15 -0
- shopware_api_client/models/order_transaction_capture.py +15 -0
- shopware_api_client/models/order_transaction_capture_refund.py +16 -0
- shopware_api_client/models/order_transaction_capture_refund_position.py +15 -0
- shopware_api_client/models/payment_method.py +29 -0
- shopware_api_client/models/product.py +72 -0
- shopware_api_client/models/product_configurator_setting.py +14 -0
- shopware_api_client/models/product_cross_selling.py +17 -0
- shopware_api_client/models/product_cross_selling_assigned_products.py +11 -0
- shopware_api_client/models/product_download.py +11 -0
- shopware_api_client/models/product_export.py +27 -0
- shopware_api_client/models/product_feature_set.py +11 -0
- shopware_api_client/models/product_manufacturer.py +11 -0
- shopware_api_client/models/product_media.py +11 -0
- shopware_api_client/models/product_price.py +15 -0
- shopware_api_client/models/product_review.py +19 -0
- shopware_api_client/models/product_search_keyword.py +13 -0
- shopware_api_client/models/product_stream.py +14 -0
- shopware_api_client/models/product_visibility.py +11 -0
- shopware_api_client/models/product_warehouse.py +10 -0
- shopware_api_client/models/promotion.py +29 -0
- shopware_api_client/models/promotion_discount.py +17 -0
- shopware_api_client/models/promotion_discount_prices.py +10 -0
- shopware_api_client/models/property_group.py +13 -0
- shopware_api_client/models/property_group_option.py +12 -0
- shopware_api_client/models/rule.py +16 -0
- shopware_api_client/models/rule_condition.py +15 -0
- shopware_api_client/models/sales_channel.py +44 -0
- shopware_api_client/models/sales_channel_domain.py +13 -0
- shopware_api_client/models/salutation.py +9 -0
- shopware_api_client/models/seo_url.py +19 -0
- shopware_api_client/models/shipping_method.py +18 -0
- shopware_api_client/models/shipping_method_price.py +15 -0
- shopware_api_client/models/state_machine.py +10 -0
- shopware_api_client/models/state_machine_history.py +18 -0
- shopware_api_client/models/state_machine_state.py +8 -0
- shopware_api_client/models/state_machine_transition.py +11 -0
- shopware_api_client/models/system_config.py +12 -0
- shopware_api_client/models/tag.py +7 -0
- shopware_api_client/models/tax.py +9 -0
- shopware_api_client/models/tax_rule.py +15 -0
- shopware_api_client/models/tax_rule_type.py +11 -0
- shopware_api_client/models/unit.py +8 -0
- shopware_api_client/models/user.py +21 -0
- shopware_api_client/models/warehouse.py +8 -0
- shopware_api_client/models/warehouse_group.py +11 -0
- shopware_api_client/models/warehouse_group_warehouse.py +11 -0
- shopware_api_client/structs/__init__.py +0 -0
- shopware_api_client/structs/absolute_price_definition.py +6 -0
- shopware_api_client/structs/calculated_cheapest_price.py +6 -0
- shopware_api_client/structs/calculated_price.py +17 -0
- shopware_api_client/structs/calculated_tax.py +8 -0
- shopware_api_client/structs/cart.py +21 -0
- shopware_api_client/structs/cart_price.py +15 -0
- shopware_api_client/structs/cash_rounding_config.py +7 -0
- shopware_api_client/structs/context.py +15 -0
- shopware_api_client/structs/delivery.py +16 -0
- shopware_api_client/structs/delivery_date.py +8 -0
- shopware_api_client/structs/delivery_information.py +13 -0
- shopware_api_client/structs/delivery_position.py +12 -0
- shopware_api_client/structs/delivery_time.py +8 -0
- shopware_api_client/structs/language_info.py +6 -0
- shopware_api_client/structs/line_item.py +39 -0
- shopware_api_client/structs/list_price.py +7 -0
- shopware_api_client/structs/measurement_units.py +8 -0
- shopware_api_client/structs/percentage_price_definition.py +6 -0
- shopware_api_client/structs/price.py +14 -0
- shopware_api_client/structs/quantity_information.py +7 -0
- shopware_api_client/structs/quantity_price_definition.py +14 -0
- shopware_api_client/structs/reference_price.py +5 -0
- shopware_api_client/structs/reference_price_definition.py +7 -0
- shopware_api_client/structs/regulation_price.py +5 -0
- shopware_api_client/structs/sales_channel_context.py +33 -0
- shopware_api_client/structs/shipping_location.py +12 -0
- shopware_api_client/structs/tax_free_config.py +8 -0
- shopware_api_client/structs/tax_rule.py +6 -0
- shopware_api_client/structs/transaction.py +8 -0
- shopware_api_client/structs/variant_listing_config.py +8 -0
- {shopware_api_client-1.0.101.dist-info → shopware_api_client-1.1.1.dist-info}/METADATA +89 -275
- shopware_api_client-1.1.1.dist-info/RECORD +298 -0
- {shopware_api_client-1.0.101.dist-info → shopware_api_client-1.1.1.dist-info}/WHEEL +1 -1
- shopware_api_client-1.0.101.dist-info/RECORD +0 -114
- {shopware_api_client-1.0.101.dist-info → shopware_api_client-1.1.1.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
from typing import Any, Coroutine, Generic, get_args
|
|
1
|
+
from typing import Any, Coroutine, Generic, get_args, TypeGuard
|
|
2
2
|
|
|
3
3
|
from pydantic import GetCoreSchemaHandler, ValidationInfo
|
|
4
4
|
from pydantic.alias_generators import to_camel
|
|
5
5
|
from pydantic_core import SchemaValidator, core_schema
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from shopware_api_client.base import AdminEndpoint, AdminModel, AdminModelClass, ClientBase
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class ForeignRelation(Generic[
|
|
11
|
-
def __init__(self, field_name: str, data:
|
|
10
|
+
class ForeignRelation(Generic[AdminModelClass]):
|
|
11
|
+
def __init__(self, field_name: str, data: AdminModelClass | None = None):
|
|
12
12
|
self.field_name: str = field_name
|
|
13
|
-
self.data:
|
|
13
|
+
self.data: AdminModelClass | None = data
|
|
14
14
|
self.changed: bool = False
|
|
15
15
|
|
|
16
16
|
def _ensure_client(self, client: ClientBase | None) -> None:
|
|
@@ -36,35 +36,39 @@ class ForeignRelation(Generic[ModelClass]):
|
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
@staticmethod
|
|
39
|
-
def _validate(value:
|
|
39
|
+
def _validate(value: AdminModelClass | None, info: ValidationInfo) -> "ForeignRelation":
|
|
40
40
|
field_name = info.field_name
|
|
41
41
|
assert field_name is not None
|
|
42
42
|
return ForeignRelation(field_name=field_name, data=value)
|
|
43
43
|
|
|
44
44
|
@staticmethod
|
|
45
|
-
def _serialize(value: "ForeignRelation[
|
|
45
|
+
def _serialize(value: "ForeignRelation[AdminModelClass]") -> AdminModelClass | None:
|
|
46
46
|
assert isinstance(value, ForeignRelation)
|
|
47
47
|
if value.data is None:
|
|
48
48
|
return None
|
|
49
49
|
return value.data
|
|
50
50
|
|
|
51
|
-
async def _get(self, instance:
|
|
51
|
+
async def _get(self, instance: AdminModelClass) -> AdminModelClass | None:
|
|
52
52
|
related_id = getattr(instance, f"{self.field_name}_id")
|
|
53
53
|
if self.data is not None or related_id is None:
|
|
54
54
|
self._ensure_client(instance._client)
|
|
55
55
|
return self.data
|
|
56
56
|
|
|
57
|
-
model_class: type[
|
|
58
|
-
|
|
57
|
+
model_class: type[AdminModelClass] = get_args(instance.model_fields[self.field_name].annotation)[0]
|
|
58
|
+
endpoint: AdminEndpoint[AdminModelClass] = model_class.using(instance._get_client())
|
|
59
|
+
data = await endpoint.get(pk=related_id)
|
|
60
|
+
|
|
61
|
+
assert data is None or isinstance(data, AdminModel)
|
|
62
|
+
|
|
59
63
|
self.data = data
|
|
60
64
|
return self.data
|
|
61
65
|
|
|
62
|
-
def __get__(self, instance:
|
|
66
|
+
def __get__(self, instance: AdminModelClass, owner: type[Any]) -> Coroutine[Any, Any, AdminModelClass | None]:
|
|
63
67
|
return self._get(instance=instance)
|
|
64
68
|
|
|
65
|
-
def __set__(self, instance:
|
|
69
|
+
def __set__(self, instance: AdminModelClass, value: Any) -> None:
|
|
66
70
|
if value is not None:
|
|
67
|
-
model_class: type[
|
|
71
|
+
model_class: type[AdminModelClass] = get_args(instance.model_fields[self.field_name].annotation)[0]
|
|
68
72
|
model_class.model_validate(value)
|
|
69
73
|
|
|
70
74
|
# Related models passed to the API win against _id fields, but we can try to
|
|
@@ -75,10 +79,10 @@ class ForeignRelation(Generic[ModelClass]):
|
|
|
75
79
|
self.changed = True
|
|
76
80
|
|
|
77
81
|
|
|
78
|
-
class ManyRelation(Generic[
|
|
79
|
-
def __init__(self, field_name: str, data: list[
|
|
82
|
+
class ManyRelation(Generic[AdminModelClass]):
|
|
83
|
+
def __init__(self, field_name: str, data: list[AdminModelClass] | None = None):
|
|
80
84
|
self.field_name: str = field_name
|
|
81
|
-
self.data: list[
|
|
85
|
+
self.data: list[AdminModelClass] | None = data
|
|
82
86
|
self.changed: bool = False
|
|
83
87
|
|
|
84
88
|
def _ensure_client(self, client: ClientBase | None) -> None:
|
|
@@ -87,6 +91,10 @@ class ManyRelation(Generic[ModelClass]):
|
|
|
87
91
|
if elem._client is None:
|
|
88
92
|
elem._client = client
|
|
89
93
|
|
|
94
|
+
@staticmethod
|
|
95
|
+
def _assert_admin_model_list(items: list[Any]) -> TypeGuard[list[AdminModelClass]]:
|
|
96
|
+
return all(isinstance(item, AdminModel) for item in items)
|
|
97
|
+
|
|
90
98
|
@classmethod
|
|
91
99
|
def __get_pydantic_core_schema__(cls, source: Any, handler: GetCoreSchemaHandler) -> core_schema.CoreSchema:
|
|
92
100
|
assert handler.field_name is not None
|
|
@@ -108,34 +116,38 @@ class ManyRelation(Generic[ModelClass]):
|
|
|
108
116
|
)
|
|
109
117
|
|
|
110
118
|
@staticmethod
|
|
111
|
-
def _validate(value: list[
|
|
119
|
+
def _validate(value: list[AdminModelClass] | None, info: ValidationInfo) -> "ManyRelation":
|
|
112
120
|
field_name = info.field_name
|
|
113
121
|
assert field_name is not None
|
|
114
122
|
return ManyRelation(field_name=field_name, data=value)
|
|
115
123
|
|
|
116
124
|
@staticmethod
|
|
117
|
-
def _serialize(value: "ManyRelation[
|
|
125
|
+
def _serialize(value: "ManyRelation[AdminModelClass]") -> list[AdminModelClass] | None:
|
|
118
126
|
assert isinstance(value, ManyRelation)
|
|
119
127
|
if value.data is None:
|
|
120
128
|
return None
|
|
121
129
|
return value.data
|
|
122
130
|
|
|
123
|
-
async def _get(self, instance:
|
|
131
|
+
async def _get(self, instance: AdminModelClass) -> list[AdminModelClass] | None:
|
|
124
132
|
api_link = to_camel(self.field_name)
|
|
125
133
|
if self.data is not None:
|
|
126
134
|
self._ensure_client(instance._client)
|
|
127
135
|
return self.data
|
|
128
136
|
|
|
129
|
-
model_class: type[
|
|
130
|
-
|
|
137
|
+
model_class: type[AdminModelClass] = get_args(instance.model_fields[self.field_name].annotation)[0]
|
|
138
|
+
endpoint: AdminEndpoint[AdminModelClass] = model_class.using(instance._get_client())
|
|
139
|
+
data = await endpoint.get_related(instance, relation=api_link)
|
|
140
|
+
|
|
141
|
+
assert data is None or self._assert_admin_model_list(data)
|
|
142
|
+
|
|
131
143
|
self.data = data
|
|
132
144
|
return self.data
|
|
133
145
|
|
|
134
|
-
def __get__(self, instance:
|
|
146
|
+
def __get__(self, instance: AdminModelClass, owner: type[Any]) -> Coroutine[Any, Any, list[AdminModelClass] | None]:
|
|
135
147
|
return self._get(instance=instance)
|
|
136
148
|
|
|
137
|
-
def __set__(self, instance:
|
|
138
|
-
model_class: type[
|
|
149
|
+
def __set__(self, instance: AdminModelClass, value: Any) -> None:
|
|
150
|
+
model_class: type[AdminModelClass] = get_args(instance.model_fields[self.field_name].annotation)[0]
|
|
139
151
|
schema = core_schema.list_schema(
|
|
140
152
|
core_schema.model_schema(cls=model_class, schema=model_class.__pydantic_core_schema__)
|
|
141
153
|
)
|
|
@@ -1,16 +1,49 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING
|
|
1
|
+
from typing import Callable, TYPE_CHECKING
|
|
2
2
|
|
|
3
3
|
if TYPE_CHECKING:
|
|
4
|
-
from
|
|
5
|
-
|
|
4
|
+
from shopware_api_client.client import StoreClient
|
|
5
|
+
from shopware_api_client.endpoints.base_fields import IdField
|
|
6
6
|
|
|
7
7
|
from .core.address import Address, AddressEndpoint
|
|
8
8
|
from .core.cart import Cart, CartEndpoint
|
|
9
|
+
from .core.context import Context, ContextEndpoint
|
|
10
|
+
from .core.country import Country, CountryEndpoint
|
|
11
|
+
from .core.country_state import CountryState, CountryStateEndpoint
|
|
12
|
+
from .core.currency import Currency, CurrencyEndpoint
|
|
13
|
+
from .core.customer import Customer, CustomerEndpoint
|
|
14
|
+
from .core.language import Language, LanguageEndpoint
|
|
15
|
+
from .core.order import Order, OrderEndpoint
|
|
16
|
+
from .core.product import Product, ProductEndpoint
|
|
17
|
+
from .core.salutation import Salutation, SalutationEndpoint
|
|
9
18
|
|
|
10
|
-
__all__ = [
|
|
19
|
+
__all__ = [
|
|
20
|
+
"Address",
|
|
21
|
+
"Cart",
|
|
22
|
+
"Context",
|
|
23
|
+
"Country",
|
|
24
|
+
"CountryState",
|
|
25
|
+
"Currency",
|
|
26
|
+
"Customer",
|
|
27
|
+
"Language",
|
|
28
|
+
"Order",
|
|
29
|
+
"Product",
|
|
30
|
+
"Salutation",
|
|
31
|
+
"StoreEndpoints",
|
|
32
|
+
]
|
|
11
33
|
|
|
12
34
|
|
|
13
35
|
class StoreEndpoints:
|
|
14
36
|
def init_endpoints(self, client: "StoreClient") -> None:
|
|
15
37
|
self.address = AddressEndpoint(client)
|
|
16
38
|
self.cart = CartEndpoint(client)
|
|
39
|
+
self.country = CountryEndpoint(client)
|
|
40
|
+
self.context = ContextEndpoint(client)
|
|
41
|
+
self.country_state: Callable[["IdField"], CountryStateEndpoint] = lambda country_id: CountryStateEndpoint(
|
|
42
|
+
client=client, country_id=country_id
|
|
43
|
+
)
|
|
44
|
+
self.currency = CurrencyEndpoint(client)
|
|
45
|
+
self.customer = CustomerEndpoint(client)
|
|
46
|
+
self.language = LanguageEndpoint(client)
|
|
47
|
+
self.order = OrderEndpoint(client)
|
|
48
|
+
self.product = ProductEndpoint(client)
|
|
49
|
+
self.salutation = SalutationEndpoint(client)
|
|
@@ -1,78 +1,61 @@
|
|
|
1
|
-
from typing import Any
|
|
2
|
-
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from shopware_api_client.base import StoreSearchEndpoint, EndpointMixin, CustomFieldsMixin
|
|
4
|
+
from shopware_api_client.endpoints.base_fields import IdField
|
|
5
|
+
from shopware_api_client.fieldsets import FieldSetBase
|
|
6
|
+
from shopware_api_client.models.customer_address import CustomerAddressBase
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Address(CustomerAddressBase, EndpointMixin["AddressEndpoint"]):
|
|
10
|
+
country: "Country | None" = None
|
|
11
|
+
country_state: "CountryState | None" = None
|
|
12
|
+
salutation: "Salutation | None" = None
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AddressUpdateSchema(FieldSetBase, CustomFieldsMixin):
|
|
16
|
+
country_id: IdField
|
|
17
|
+
country_state_id: IdField | None = None
|
|
18
|
+
salutation_id: IdField | None = None
|
|
19
|
+
first_name: str
|
|
20
|
+
last_name: str
|
|
21
|
+
zipcode: str | None = None
|
|
22
|
+
city: str
|
|
23
|
+
company: str | None = None
|
|
24
|
+
street: str
|
|
25
|
+
department: str | None = None
|
|
26
|
+
title: str | None = None
|
|
27
|
+
phone_number: str | None = None
|
|
28
|
+
additional_address_line1: str | None = None
|
|
29
|
+
additional_address_line2: str | None = None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class AddressEndpoint(StoreSearchEndpoint[Address]):
|
|
22
33
|
model_class = Address
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
async def all(self) -> list[Address] | list[dict[str, Any]]:
|
|
26
|
-
data = self._get_data_dict()
|
|
34
|
+
path = "/account/list-address"
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
async def delete(self, pk: IdField) -> bool:
|
|
37
|
+
result = await self.client.delete(f"/account/address/{pk}")
|
|
38
|
+
return bool(result.is_success)
|
|
29
39
|
|
|
30
|
-
|
|
40
|
+
async def modify(self, pk: IdField, obj: AddressUpdateSchema) -> Address:
|
|
41
|
+
data = obj.model_dump_json(by_alias=True)
|
|
42
|
+
result: dict[str, Any] = (await self.client.patch(f"/account/address/{pk}", data=data)).json()
|
|
43
|
+
return self._parse_response(result, Address)
|
|
31
44
|
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
async def create(self, obj: AddressUpdateSchema) -> Address:
|
|
46
|
+
data = obj.model_dump_json(by_alias=True)
|
|
47
|
+
result: dict[str, Any] = (await self.client.post("/account/address", data=data)).json()
|
|
48
|
+
return self._parse_response(result, Address)
|
|
34
49
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
async def iter(self, batch_size: int = 100) -> AsyncGenerator[Address | dict[str, Any], None]:
|
|
38
|
-
self._limit = batch_size
|
|
39
|
-
data = self._get_data_dict()
|
|
40
|
-
page = 1
|
|
41
|
-
|
|
42
|
-
while True:
|
|
43
|
-
data["page"] = page
|
|
44
|
-
result = await self.client.post("/account/list-address", json=data)
|
|
45
|
-
|
|
46
|
-
result_dict: dict[str, Any] = result.json()
|
|
47
|
-
result_data: list[dict[str, Any]] = self._parse_data(result_dict)
|
|
48
|
-
|
|
49
|
-
for entry in result_data:
|
|
50
|
-
if self.raw:
|
|
51
|
-
yield entry
|
|
52
|
-
else:
|
|
53
|
-
yield self._parse_response(entry)
|
|
54
|
-
|
|
55
|
-
if "next" in result_dict.get("links", {}) and len(result_data) > 0:
|
|
56
|
-
page += 1
|
|
57
|
-
else:
|
|
58
|
-
break
|
|
59
|
-
|
|
60
|
-
async def set_default_shipping_address(self, pk: str) -> bool:
|
|
50
|
+
async def set_default_shipping_address(self, pk: IdField) -> bool:
|
|
61
51
|
result = await self.client.patch(f"/account/address/default-shipping/{pk}")
|
|
62
|
-
return bool(result.
|
|
52
|
+
return bool(result.is_success)
|
|
63
53
|
|
|
64
|
-
async def set_default_billing_address(self, pk:
|
|
54
|
+
async def set_default_billing_address(self, pk: IdField) -> bool:
|
|
65
55
|
result = await self.client.patch(f"/account/address/default-billing/{pk}")
|
|
66
|
-
return bool(result.
|
|
67
|
-
|
|
68
|
-
async def get(self, pk: str) -> Address | dict[str, Any]:
|
|
69
|
-
raise SWAPIMethodNotAvailable()
|
|
56
|
+
return bool(result.is_success)
|
|
70
57
|
|
|
71
|
-
async def bulk_upsert(
|
|
72
|
-
self, objs: list[Address] | list[dict[str, Any]], fail_silently: bool = False, **request_kwargs: Any
|
|
73
|
-
) -> dict[str, Any]:
|
|
74
|
-
raise SWAPIMethodNotAvailable()
|
|
75
58
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
from .country import Country # noqa: E402
|
|
60
|
+
from .country_state import CountryState # noqa: E402
|
|
61
|
+
from .salutation import Salutation # noqa: E402
|
|
@@ -1,95 +1,49 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
-
from shopware_api_client.base import
|
|
4
|
-
from shopware_api_client.endpoints.
|
|
5
|
-
from shopware_api_client.
|
|
6
|
-
from shopware_api_client.
|
|
3
|
+
from shopware_api_client.base import StoreEndpoint, EndpointMixin
|
|
4
|
+
from shopware_api_client.endpoints.base_fields import IdField
|
|
5
|
+
from shopware_api_client.structs.cart import Cart as CartBase
|
|
6
|
+
from shopware_api_client.structs.line_item import LineItem
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
class
|
|
10
|
-
|
|
11
|
-
quantity: int
|
|
12
|
-
total_price: float
|
|
13
|
-
calculated_taxes: list[dict[str, Any]] | None = None
|
|
14
|
-
tax_rules: list[dict[str, Any]] | None = None
|
|
15
|
-
reference_price: float | None = None
|
|
16
|
-
list_price: float | None = None
|
|
17
|
-
regulation_price: float | None = None
|
|
18
|
-
|
|
9
|
+
class Cart(CartBase, EndpointMixin["CartEndpoint"]):
|
|
10
|
+
pass
|
|
19
11
|
|
|
20
|
-
class ShippingCosts(ItemPrice):
|
|
21
|
-
raw_total: float | None = None
|
|
22
|
-
position_price: float | None = None
|
|
23
|
-
net_price: float | None = None
|
|
24
|
-
has_range: bool | None = None
|
|
25
|
-
variant: str | None = None
|
|
26
12
|
|
|
27
|
-
|
|
28
|
-
class LineItem(BaseFieldSet):
|
|
29
|
-
payload: dict[str, Any]
|
|
30
|
-
label: str
|
|
31
|
-
quantity: int
|
|
32
|
-
price_definition: dict[str, Any]
|
|
33
|
-
price: ItemPrice
|
|
34
|
-
good: bool
|
|
35
|
-
description: str | None = None
|
|
36
|
-
cover: Any
|
|
37
|
-
delivery_information: dict[str, Any]
|
|
38
|
-
children: list[Any]
|
|
39
|
-
removable: bool
|
|
40
|
-
stackable: bool
|
|
41
|
-
quantity_information: dict[str, Any]
|
|
42
|
-
modified: bool
|
|
43
|
-
data_timestamp: str
|
|
44
|
-
data_context_hash: str
|
|
45
|
-
states: list[str]
|
|
46
|
-
modified_by_app: bool
|
|
47
|
-
referenced_id: IdField
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class DeliveryPosition(BaseFieldSet):
|
|
51
|
-
delivery_date: Any
|
|
52
|
-
line_item: LineItem
|
|
53
|
-
price: ItemPrice
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class Location(BaseFieldSet):
|
|
57
|
-
country: Country
|
|
58
|
-
adress: Address | None = None
|
|
59
|
-
state: Any | None = None
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
class CartDelivery(BaseFieldSet):
|
|
63
|
-
delilvery_date: Any | None = None
|
|
64
|
-
location: Location | None = None
|
|
65
|
-
positions: list[DeliveryPosition] | None = None
|
|
66
|
-
shipping_costs: ShippingCosts | None = None #ShippingCosts
|
|
67
|
-
shipping_method: Any | None = None
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class Cart(ApiModelBase["CartEndpoint"]):
|
|
71
|
-
_identifier: str = "cart"
|
|
72
|
-
|
|
73
|
-
token: str
|
|
74
|
-
price: Price
|
|
75
|
-
line_items: list[LineItem]
|
|
76
|
-
errors: list[dict[str, Any]] | dict[str, Any] | None = None
|
|
77
|
-
deliveries: list[CartDelivery]
|
|
78
|
-
transactions: list[dict[str, Any]]
|
|
79
|
-
modified: bool
|
|
80
|
-
customer_comment: str | None = None
|
|
81
|
-
affiliate_code: str | None = None
|
|
82
|
-
campaign_code: str | None = None
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class CartEndpoint(EndpointBase[Cart]):
|
|
13
|
+
class CartEndpoint(StoreEndpoint):
|
|
86
14
|
name = "cart"
|
|
87
15
|
path = "/checkout/cart"
|
|
88
|
-
model_class = Cart
|
|
89
|
-
data_key = "elements"
|
|
90
|
-
|
|
91
16
|
|
|
17
|
+
# kept for backwards-compatibility
|
|
92
18
|
async def first(self) -> Cart:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
19
|
+
return await self.fetch_or_create()
|
|
20
|
+
|
|
21
|
+
async def fetch_or_create(self) -> Cart:
|
|
22
|
+
result: dict[str, Any] = (await self.client.get(self.path)).json()
|
|
23
|
+
return self._parse_response(result, cls=Cart)
|
|
24
|
+
|
|
25
|
+
async def delete(self) -> bool:
|
|
26
|
+
response = await self.client.delete(self.path)
|
|
27
|
+
return bool(response.is_success)
|
|
28
|
+
|
|
29
|
+
async def add_items(self, items: list["LineItem"]) -> Cart:
|
|
30
|
+
result: dict[str, Any] = (
|
|
31
|
+
await self.client.post(
|
|
32
|
+
f"{self.path}/line-item",
|
|
33
|
+
json={"items": [item.model_dump(by_alias=True, mode="json", exclude_unset=True) for item in items]},
|
|
34
|
+
)
|
|
35
|
+
).json()
|
|
36
|
+
return self._parse_response(result, cls=Cart)
|
|
37
|
+
|
|
38
|
+
async def update_items(self, items: list["LineItem"]) -> Cart:
|
|
39
|
+
result: dict[str, Any] = (
|
|
40
|
+
await self.client.patch(
|
|
41
|
+
f"{self.path}/line-item",
|
|
42
|
+
json={"items": [item.model_dump(by_alias=True, mode="json", exclude_unset=True) for item in items]},
|
|
43
|
+
)
|
|
44
|
+
).json()
|
|
45
|
+
return self._parse_response(result, cls=Cart)
|
|
46
|
+
|
|
47
|
+
async def remove_items(self, ids: list[IdField]) -> Cart:
|
|
48
|
+
result: dict[str, Any] = (await self.client.post(f"{self.path}/line-item/delete", json={"ids": ids})).json()
|
|
49
|
+
return self._parse_response(result, cls=Cart)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from shopware_api_client.models.category import CategoryBase
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Category(CategoryBase):
|
|
5
|
+
parent: "Category | None" = None
|
|
6
|
+
children: list["Category"]
|
|
7
|
+
media: "Media | None" = None
|
|
8
|
+
tags: list["Tag"] | None = None
|
|
9
|
+
cms_page: "CmsPage | None" = None
|
|
10
|
+
seo_urls: list["SeoUrl"] | None = None
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
from .cms_page import CmsPage # noqa: E402
|
|
14
|
+
from .media import Media # noqa: E402
|
|
15
|
+
from .seo_url import SeoUrl # noqa: E402
|
|
16
|
+
from .tag import Tag # noqa: E402
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from shopware_api_client.models.cms_page import CmsPageBase
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CmsPage(CmsPageBase):
|
|
5
|
+
sections: list["CmsSection"]
|
|
6
|
+
preview_media: "Media | None" = None
|
|
7
|
+
landing_pages: list["LandingPage"] | None = None
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
from .cms_section import CmsSection # noqa: E402
|
|
11
|
+
from .landing_page import LandingPage # noqa: E402
|
|
12
|
+
from .media import Media # noqa: E402
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from shopware_api_client.models.cms_section import CmsSectionBase
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CmsSection(CmsSectionBase):
|
|
5
|
+
page: "CmsPage | None" = None
|
|
6
|
+
background_media: "Media | None" = None
|
|
7
|
+
blacks: list["CmsBlock"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
from .cms_block import CmsBlock # noqa: E402
|
|
11
|
+
from .cms_page import CmsPage # noqa: E402
|
|
12
|
+
from .media import Media # noqa: E402
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from shopware_api_client.base import StoreEndpoint, EndpointMixin
|
|
4
|
+
from shopware_api_client.endpoints.base_fields import IdField
|
|
5
|
+
from shopware_api_client.structs.sales_channel_context import SalesChannelContext
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Context(SalesChannelContext, EndpointMixin["ContextEndpoint"]):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ContextEndpoint(StoreEndpoint):
|
|
13
|
+
name = "context"
|
|
14
|
+
path = "/context"
|
|
15
|
+
|
|
16
|
+
async def get(self) -> Context:
|
|
17
|
+
result: dict[str, Any] = (await self.client.get(self.path)).json()
|
|
18
|
+
return self._parse_response(result, Context)
|
|
19
|
+
|
|
20
|
+
async def modifiy(
|
|
21
|
+
self,
|
|
22
|
+
currency_id: IdField | None = None,
|
|
23
|
+
language_id: IdField | None = None,
|
|
24
|
+
billing_address_id: IdField | None = None,
|
|
25
|
+
shipping_address_id: IdField | None = None,
|
|
26
|
+
payment_method_id: IdField | None = None,
|
|
27
|
+
shipping_method_id: IdField | None = None,
|
|
28
|
+
country_id: IdField | None = None,
|
|
29
|
+
country_state_id: IdField | None = None,
|
|
30
|
+
) -> bool:
|
|
31
|
+
data: dict[str, Any] = {}
|
|
32
|
+
|
|
33
|
+
if currency_id is not None:
|
|
34
|
+
data["currencyId"] = currency_id
|
|
35
|
+
|
|
36
|
+
if language_id is not None:
|
|
37
|
+
data["languageId"] = language_id
|
|
38
|
+
|
|
39
|
+
if billing_address_id is not None:
|
|
40
|
+
data["billingAddressId"] = billing_address_id
|
|
41
|
+
|
|
42
|
+
if shipping_address_id is not None:
|
|
43
|
+
data["shippingAddressId"] = shipping_address_id
|
|
44
|
+
|
|
45
|
+
if payment_method_id is not None:
|
|
46
|
+
data["paymentMethodId"] = payment_method_id
|
|
47
|
+
|
|
48
|
+
if shipping_method_id is not None:
|
|
49
|
+
data["shippingMethodId"] = shipping_method_id
|
|
50
|
+
|
|
51
|
+
if country_id is not None:
|
|
52
|
+
data["countryId"] = country_id
|
|
53
|
+
|
|
54
|
+
if country_state_id is not None:
|
|
55
|
+
data["countryStateId"] = country_state_id
|
|
56
|
+
|
|
57
|
+
response = await self.client.patch(self.path, json=data)
|
|
58
|
+
return bool(response.is_success)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from shopware_api_client.base import StoreSearchEndpoint, EndpointMixin
|
|
2
|
+
from shopware_api_client.models.country import CountryBase
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Country(CountryBase, EndpointMixin["CountryEndpoint"]):
|
|
6
|
+
states: list["CountryState"] | None = None
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CountryEndpoint(StoreSearchEndpoint[Country]):
|
|
10
|
+
model_class = Country
|
|
11
|
+
name = "country"
|
|
12
|
+
path = "/country"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from .country_state import CountryState # noqa: E402
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from shopware_api_client.base import ClientBase, StoreSearchEndpoint, EndpointMixin
|
|
4
|
+
from shopware_api_client.endpoints.base_fields import IdField
|
|
5
|
+
from shopware_api_client.models.country_state import CountryStateBase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CountryState(CountryStateBase, EndpointMixin["CountryStateEndpoint"]):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CountryStateEndpoint(StoreSearchEndpoint[CountryState]):
|
|
13
|
+
model_class = CountryState
|
|
14
|
+
name = "country_state"
|
|
15
|
+
path = "/country-state/"
|
|
16
|
+
|
|
17
|
+
def __init__(self, client: ClientBase, country_id: IdField, *args: Any, **kwargs: Any) -> None:
|
|
18
|
+
self.path += country_id
|
|
19
|
+
super().__init__(client, *args, **kwargs)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from shopware_api_client.base import StoreSearchEndpoint, EndpointMixin
|
|
2
|
+
from shopware_api_client.models.currency import CurrencyBase
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Currency(CurrencyBase, EndpointMixin["CurrencyEndpoint"]):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CurrencyEndpoint(StoreSearchEndpoint[Currency]):
|
|
10
|
+
model_class = Currency
|
|
11
|
+
name = "currency"
|
|
12
|
+
path = "/currency"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from shopware_api_client.base import EndpointMixin, StoreEndpoint
|
|
4
|
+
from shopware_api_client.models.customer import CustomerBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Customer(CustomerBase, EndpointMixin["CustomerEndpoint"]):
|
|
8
|
+
group: "CustomerGroup | None" = None
|
|
9
|
+
language: "Language | None" = None
|
|
10
|
+
last_payment_method: "PaymentMethod | None" = None
|
|
11
|
+
default_billing_address: "Address | None" = None
|
|
12
|
+
active_billing_address: "Address | None" = None
|
|
13
|
+
default_shipping_address: "Address | None" = None
|
|
14
|
+
active_shipping_address: "Address | None" = None
|
|
15
|
+
salutation: "Salutation | None" = None
|
|
16
|
+
addresses: list["Address"] | None = None
|
|
17
|
+
tags: list["Tag"] | None = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class CustomerEndpoint(StoreEndpoint):
|
|
21
|
+
name = "customer"
|
|
22
|
+
path = "/account/customer"
|
|
23
|
+
|
|
24
|
+
async def get(self) -> Customer:
|
|
25
|
+
result: dict[str, Any] = (await self.client.get(self.path)).json()
|
|
26
|
+
return self._parse_response(result, Customer)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
from .address import Address # noqa: E402
|
|
30
|
+
from .customer_group import CustomerGroup # noqa: E402
|
|
31
|
+
from .language import Language # noqa: E402
|
|
32
|
+
from .payment_method import PaymentMethod # noqa: E402
|
|
33
|
+
from .salutation import Salutation # noqa: E402
|
|
34
|
+
from .tag import Tag # noqa: E402
|