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
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
from collections import OrderedDict
|
|
4
|
+
from time import time
|
|
5
|
+
from typing import Any, Awaitable, NamedTuple, cast
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
from redis.asyncio import Redis
|
|
9
|
+
|
|
10
|
+
_has_redis = True
|
|
11
|
+
except ModuleNotFoundError:
|
|
12
|
+
_has_redis = False
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CacheBase(ABC):
|
|
16
|
+
@abstractmethod
|
|
17
|
+
async def get(self, key: str) -> Any | None: ...
|
|
18
|
+
|
|
19
|
+
@abstractmethod
|
|
20
|
+
async def get_and_decrement(self, key: str) -> int | None: ...
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
async def has_lock(self, key: str, ttl: int) -> bool: ...
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
async def set(self, key: str, value: Any, ttl: int | None = None) -> None: ...
|
|
27
|
+
|
|
28
|
+
@abstractmethod
|
|
29
|
+
async def delete(self, key: str) -> None: ...
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def _json_encode(key: str, value: Any) -> str:
|
|
33
|
+
try:
|
|
34
|
+
return json.dumps(value)
|
|
35
|
+
except (TypeError, ValueError) as e:
|
|
36
|
+
raise ValueError(f"Value {value!r} for cache key {key!r} must be JSON-serializable: {e}") from e
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def _json_decode(raw_value: Any) -> Any | None:
|
|
40
|
+
if raw_value is None:
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
return json.loads(raw_value)
|
|
45
|
+
except json.JSONDecodeError:
|
|
46
|
+
# If write was broken, mimic missing key
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class RedisCache(CacheBase):
|
|
51
|
+
_DECR_IF_EXISTS = """
|
|
52
|
+
if redis.call('EXISTS', KEYS[1]) == 1 then
|
|
53
|
+
return redis.call('DECR', KEYS[1])
|
|
54
|
+
else
|
|
55
|
+
return nil
|
|
56
|
+
end
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
def __init__(self, redis_client: "Redis") -> None:
|
|
60
|
+
if not _has_redis:
|
|
61
|
+
raise RuntimeError("Redis needs to be installed to use it as a cache.")
|
|
62
|
+
|
|
63
|
+
self.client = redis_client
|
|
64
|
+
|
|
65
|
+
async def get(self, key: str) -> Any | None:
|
|
66
|
+
value = await self.client.get(key)
|
|
67
|
+
return self._json_decode(value)
|
|
68
|
+
|
|
69
|
+
async def get_and_decrement(self, key: str) -> int | None:
|
|
70
|
+
return_value = await cast(Awaitable[int | None], self.client.eval(self._DECR_IF_EXISTS, 1, key))
|
|
71
|
+
return None if return_value is None else return_value + 1
|
|
72
|
+
|
|
73
|
+
async def has_lock(self, key: str, ttl: int) -> bool:
|
|
74
|
+
return await self.client.set(key, 1, ex=ttl, nx=True) or False
|
|
75
|
+
|
|
76
|
+
async def set(self, key: str, value: Any, ttl: int | None = None) -> None:
|
|
77
|
+
await self.client.set(name=key, value=self._json_encode(key, value), ex=ttl)
|
|
78
|
+
|
|
79
|
+
async def delete(self, key: str) -> None:
|
|
80
|
+
await self.client.delete(key)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class DictCache(CacheBase):
|
|
84
|
+
class CacheValue(NamedTuple):
|
|
85
|
+
value: Any
|
|
86
|
+
expire_at: int | None
|
|
87
|
+
|
|
88
|
+
def __init__(self, cleanup_cycle_seconds: int) -> None:
|
|
89
|
+
self._cache: OrderedDict[str, DictCache.CacheValue] = OrderedDict()
|
|
90
|
+
self.cleanup_cycle_seconds = cleanup_cycle_seconds
|
|
91
|
+
self.next_cleanup: int = 0
|
|
92
|
+
|
|
93
|
+
async def get(self, key: str) -> Any | None:
|
|
94
|
+
self._cleanup_by_expiry()
|
|
95
|
+
entry = self._cache.get(key)
|
|
96
|
+
|
|
97
|
+
return self._json_decode(entry and entry.value)
|
|
98
|
+
|
|
99
|
+
async def get_and_decrement(self, key: str) -> int | None:
|
|
100
|
+
self._cleanup_by_expiry()
|
|
101
|
+
entry = self._cache.get(key)
|
|
102
|
+
if entry is None:
|
|
103
|
+
return None
|
|
104
|
+
|
|
105
|
+
decoded_value = self._json_decode(entry.value)
|
|
106
|
+
if not isinstance(decoded_value, int):
|
|
107
|
+
raise ValueError(f"Trying to decrement key {key!r}, but value {decoded_value!r} is not an int")
|
|
108
|
+
|
|
109
|
+
new_value = decoded_value - 1
|
|
110
|
+
self._cache[key] = DictCache.CacheValue(self._json_encode(key, new_value), entry.expire_at)
|
|
111
|
+
|
|
112
|
+
return decoded_value
|
|
113
|
+
|
|
114
|
+
async def has_lock(self, key: str, ttl: int) -> bool:
|
|
115
|
+
self._cleanup_by_expiry(False)
|
|
116
|
+
entry = self._cache.get(key)
|
|
117
|
+
if unlocked := entry is None:
|
|
118
|
+
self._cache[key] = DictCache.CacheValue(True, self.get_expiry(ttl))
|
|
119
|
+
|
|
120
|
+
return unlocked
|
|
121
|
+
|
|
122
|
+
async def set(self, key: str, value: Any, ttl: int | None = None) -> None:
|
|
123
|
+
self._cleanup_by_expiry()
|
|
124
|
+
cache_value = self._json_encode(key, value)
|
|
125
|
+
|
|
126
|
+
self._cache[key] = DictCache.CacheValue(cache_value, self.get_expiry(ttl))
|
|
127
|
+
|
|
128
|
+
async def delete(self, key: str) -> None:
|
|
129
|
+
self._cleanup_by_expiry()
|
|
130
|
+
self._cache.pop(key, None)
|
|
131
|
+
|
|
132
|
+
def get_expiry(self, ttl: int | None) -> int | None:
|
|
133
|
+
return int(time()) + ttl if ttl is not None else None
|
|
134
|
+
|
|
135
|
+
def _cleanup_by_expiry(self, do_wait: bool = True) -> None:
|
|
136
|
+
now = int(time())
|
|
137
|
+
|
|
138
|
+
if now < self.next_cleanup and do_wait:
|
|
139
|
+
return
|
|
140
|
+
|
|
141
|
+
initial_size = len(self._cache)
|
|
142
|
+
for _ in range(initial_size):
|
|
143
|
+
if not self._cache:
|
|
144
|
+
break
|
|
145
|
+
|
|
146
|
+
first_key, first_value = next(iter(self._cache.items()))
|
|
147
|
+
|
|
148
|
+
if first_value.expire_at is None:
|
|
149
|
+
self._cache.move_to_end(first_key)
|
|
150
|
+
continue
|
|
151
|
+
|
|
152
|
+
if first_value.expire_at > now:
|
|
153
|
+
break
|
|
154
|
+
|
|
155
|
+
self._cache.popitem(last=False)
|
|
156
|
+
|
|
157
|
+
self.next_cleanup = now + self.cleanup_cycle_seconds
|
shopware_api_client/client.py
CHANGED
|
@@ -19,7 +19,7 @@ class AdminClient(ClientBase, AdminEndpoints):
|
|
|
19
19
|
self._client: httpx.AsyncClient | None = None
|
|
20
20
|
self.init_endpoints(self)
|
|
21
21
|
|
|
22
|
-
def
|
|
22
|
+
def _get_http_client(self) -> httpx.AsyncClient:
|
|
23
23
|
if self._client is None:
|
|
24
24
|
self._client = httpx.AsyncClient(
|
|
25
25
|
event_hooks={"request": [self.log_request], "response": [self.log_response]}
|
|
@@ -180,7 +180,7 @@ class StoreClient(ClientBase, StoreEndpoints):
|
|
|
180
180
|
self._client: httpx.AsyncClient | None = None
|
|
181
181
|
self.init_endpoints(self)
|
|
182
182
|
|
|
183
|
-
def
|
|
183
|
+
def _get_http_client(self) -> httpx.AsyncClient:
|
|
184
184
|
if self._client is None:
|
|
185
185
|
self._client = httpx.AsyncClient(
|
|
186
186
|
event_hooks={"request": [self.log_request], "response": [self.log_response]},
|
shopware_api_client/config.py
CHANGED
|
@@ -14,6 +14,7 @@ class AdminConfig(ConfigBase):
|
|
|
14
14
|
client_secret: str | None = None,
|
|
15
15
|
grant_type: str = "client_credentials",
|
|
16
16
|
extra: dict[str, Any] | None = None,
|
|
17
|
+
**kwargs: Any,
|
|
17
18
|
) -> None:
|
|
18
19
|
match grant_type:
|
|
19
20
|
case "client_credentials":
|
|
@@ -27,7 +28,7 @@ class AdminConfig(ConfigBase):
|
|
|
27
28
|
case _:
|
|
28
29
|
raise SWAPIConfigException("Invalid 'grant_type'. Must be one of: 'client_credentials', 'password'")
|
|
29
30
|
|
|
30
|
-
super().__init__(url=url)
|
|
31
|
+
super().__init__(url=url, **kwargs)
|
|
31
32
|
self.username = username
|
|
32
33
|
self.password = password
|
|
33
34
|
self.client_id = client_id
|
|
@@ -37,7 +38,7 @@ class AdminConfig(ConfigBase):
|
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
class StoreConfig(ConfigBase):
|
|
40
|
-
def __init__(self, url: str, access_key: str, context_token: str | None = None):
|
|
41
|
-
super().__init__(url=url)
|
|
41
|
+
def __init__(self, url: str, access_key: str, context_token: str | None = None, **kwargs: Any):
|
|
42
|
+
super().__init__(url=url, **kwargs)
|
|
42
43
|
self.access_key = access_key
|
|
43
44
|
self.context_token = context_token
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
from typing import TYPE_CHECKING
|
|
2
2
|
|
|
3
|
+
from ...base import AdminModel
|
|
4
|
+
|
|
3
5
|
if TYPE_CHECKING:
|
|
4
6
|
from ...client import AdminClient
|
|
5
7
|
|
|
6
8
|
from .commercial.b2b_components_role import B2bComponentsRole, B2bComponentsRoleEndpoint
|
|
9
|
+
from .commercial.b2b_components_shopping_list import B2bComponentsShoppingList, B2bComponentsShoppingListEndpoint
|
|
10
|
+
from .commercial.b2b_components_shopping_list_line_item import (
|
|
11
|
+
B2bComponentsShoppingListLineItem,
|
|
12
|
+
B2bComponentsShoppingListLineItemEndpoint,
|
|
13
|
+
)
|
|
7
14
|
from .commercial.b2b_employee import B2bEmployee, B2bEmployeeEndpoint
|
|
8
15
|
from .commercial.dynamic_access import DynamicAccess, DynamicAccessEndpoint
|
|
9
16
|
from .core.acl_role import AclRole, AclRoleEndpoint
|
|
@@ -91,6 +98,7 @@ from .core.sales_channel_domain import SalesChannelDomain, SalesChannelDomainEnd
|
|
|
91
98
|
from .core.salutation import Salutation, SalutationEndpoint
|
|
92
99
|
from .core.seo_url import SeoUrl, SeoUrlEndpoint
|
|
93
100
|
from .core.shipping_method import ShippingMethod, ShippingMethodEndpoint
|
|
101
|
+
from .core.shipping_method_price import ShippingMethodPrice, ShippingMethodPriceEndpoint
|
|
94
102
|
from .core.state_machine import StateMachine, StateMachineEndpoint
|
|
95
103
|
from .core.state_machine_history import StateMachineHistory, StateMachineHistoryEndpoint
|
|
96
104
|
from .core.state_machine_state import StateMachineState, StateMachineStateEndpoint
|
|
@@ -111,6 +119,8 @@ __all__ = [
|
|
|
111
119
|
"AdminEndpoints",
|
|
112
120
|
"B2bComponentsRole",
|
|
113
121
|
"B2bEmployee",
|
|
122
|
+
"B2bComponentsShoppingList",
|
|
123
|
+
"B2bComponentsShoppingListLineItem",
|
|
114
124
|
"ApiInfo",
|
|
115
125
|
"App",
|
|
116
126
|
"AppScriptCondition",
|
|
@@ -187,6 +197,7 @@ __all__ = [
|
|
|
187
197
|
"Salutation",
|
|
188
198
|
"SeoUrl",
|
|
189
199
|
"ShippingMethod",
|
|
200
|
+
"ShippingMethodPrice",
|
|
190
201
|
"StateMachine",
|
|
191
202
|
"StateMachineHistory",
|
|
192
203
|
"StateMachineState",
|
|
@@ -211,11 +222,11 @@ class AdminEndpoints:
|
|
|
211
222
|
|
|
212
223
|
from pydantic import AwareDatetime, create_model
|
|
213
224
|
|
|
214
|
-
from ...base import
|
|
225
|
+
from ...base import AdminEndpoint
|
|
215
226
|
from ..base_fields import IdField
|
|
216
227
|
|
|
217
228
|
async for custom_entity in self.custom_entity.iter():
|
|
218
|
-
assert
|
|
229
|
+
assert isinstance(custom_entity, CustomEntity)
|
|
219
230
|
fields: dict[str, Any] = {}
|
|
220
231
|
|
|
221
232
|
for field in custom_entity.fields:
|
|
@@ -255,9 +266,11 @@ class AdminEndpoints:
|
|
|
255
266
|
|
|
256
267
|
fields["_identifier"] = (str, custom_entity.name)
|
|
257
268
|
|
|
258
|
-
ce_model: type[
|
|
269
|
+
ce_model: type[AdminModel[Any]] = create_model(
|
|
270
|
+
custom_entity.name, **fields, __base__=AdminModel[AdminEndpoint]
|
|
271
|
+
)
|
|
259
272
|
|
|
260
|
-
ce_endpoint = new_class(f"{custom_entity.name}Endpoint", (
|
|
273
|
+
ce_endpoint = new_class(f"{custom_entity.name}Endpoint", (AdminEndpoint[AdminModel],))
|
|
261
274
|
ce_endpoint.name = custom_entity.name # type: ignore
|
|
262
275
|
ce_endpoint.path = f"/{custom_entity.name.replace('_', '-')}" # type: ignore
|
|
263
276
|
ce_endpoint.model_class = ce_model # type: ignore
|
|
@@ -269,6 +282,8 @@ class AdminEndpoints:
|
|
|
269
282
|
self.b2b_employee = B2bEmployeeEndpoint(client)
|
|
270
283
|
self.b2b_components_role = B2bComponentsRoleEndpoint(client)
|
|
271
284
|
self.dynamic_access = DynamicAccessEndpoint(client)
|
|
285
|
+
self.b2b_components_shopping_list = B2bComponentsShoppingListEndpoint(client)
|
|
286
|
+
self.b2b_components_shopping_list_line_item = B2bComponentsShoppingListLineItemEndpoint(client)
|
|
272
287
|
|
|
273
288
|
# Core
|
|
274
289
|
self.acl_role = AclRoleEndpoint(client)
|
|
@@ -347,6 +362,7 @@ class AdminEndpoints:
|
|
|
347
362
|
self.salutation = SalutationEndpoint(client)
|
|
348
363
|
self.seo_url = SeoUrlEndpoint(client)
|
|
349
364
|
self.shipping_method = ShippingMethodEndpoint(client)
|
|
365
|
+
self.shipping_method_price = ShippingMethodPriceEndpoint(client)
|
|
350
366
|
self.state_machine = StateMachineEndpoint(client)
|
|
351
367
|
self.state_machine_history = StateMachineHistoryEndpoint(client)
|
|
352
368
|
self.state_machine_state = StateMachineStateEndpoint(client)
|
|
@@ -1,29 +1,14 @@
|
|
|
1
|
-
from
|
|
1
|
+
from shopware_api_client.base import AdminEndpoint, AdminModel
|
|
2
|
+
from shopware_api_client.endpoints.relations import ForeignRelation, ManyRelation
|
|
3
|
+
from shopware_api_client.models.b2b_components_role import B2bComponentsRoleBase
|
|
2
4
|
|
|
3
|
-
from ....base import ApiModelBase, EndpointBase, EndpointClass
|
|
4
|
-
from ...base_fields import IdField
|
|
5
|
-
from ...relations import ForeignRelation, ManyRelation
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
class B2bComponentsRoleBase(ApiModelBase[EndpointClass]):
|
|
9
|
-
_identifier: str = "b2b_components_role"
|
|
10
|
-
|
|
11
|
-
business_partner_customer_id: IdField | None = None
|
|
12
|
-
name: str
|
|
13
|
-
permissions: dict[str, Any] | None = None
|
|
14
|
-
custom_fields: dict[str, Any] | None = None
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class B2bComponentsRoleRelations:
|
|
6
|
+
class B2bComponentsRole(B2bComponentsRoleBase, AdminModel["B2bComponentsRoleEndpoint"]):
|
|
18
7
|
employees: ManyRelation["B2bEmployee"]
|
|
19
8
|
business_partner_customer: ForeignRelation["Customer"]
|
|
20
9
|
|
|
21
10
|
|
|
22
|
-
class
|
|
23
|
-
pass
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class B2bComponentsRoleEndpoint(EndpointBase[B2bComponentsRole]):
|
|
11
|
+
class B2bComponentsRoleEndpoint(AdminEndpoint[B2bComponentsRole]):
|
|
27
12
|
name = "b2b_components_role"
|
|
28
13
|
path = "/b2b-components-role"
|
|
29
14
|
model_class = B2bComponentsRole
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from shopware_api_client.base import AdminModel, AdminEndpoint
|
|
2
|
+
from shopware_api_client.endpoints.relations import ForeignRelation, ManyRelation
|
|
3
|
+
from shopware_api_client.models.b2b_components_shopping_list import B2bComponentsShoppingListBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class B2bComponentsShoppingList(B2bComponentsShoppingListBase, AdminModel["B2bComponentsShoppingListEndpoint"]):
|
|
7
|
+
sales_channel: ForeignRelation["SalesChannel"]
|
|
8
|
+
line_items: ManyRelation["B2bComponentsShoppingListLineItem"]
|
|
9
|
+
customer: ForeignRelation["Customer"]
|
|
10
|
+
employee: ForeignRelation["B2bEmployee"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class B2bComponentsShoppingListEndpoint(AdminEndpoint[B2bComponentsShoppingList]):
|
|
14
|
+
name = "b2b_components_shopping_list"
|
|
15
|
+
path = "/b2b-components-shopping-list"
|
|
16
|
+
model_class = B2bComponentsShoppingList
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
from ..core.customer import Customer # noqa: E402
|
|
20
|
+
from ..core.sales_channel import SalesChannel # noqa: E402
|
|
21
|
+
from .b2b_components_shopping_list_line_item import B2bComponentsShoppingListLineItem # noqa: E402
|
|
22
|
+
from .b2b_employee import B2bEmployee # noqa: E402
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from shopware_api_client.base import AdminModel, AdminEndpoint
|
|
2
|
+
from shopware_api_client.endpoints.relations import ForeignRelation
|
|
3
|
+
from shopware_api_client.models.b2b_components_shopping_list_line_item import B2bComponentsShoppingListLineItemBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class B2bComponentsShoppingListLineItem(
|
|
7
|
+
B2bComponentsShoppingListLineItemBase, AdminModel["B2bComponentsShoppingListLineItemEndpoint"]
|
|
8
|
+
):
|
|
9
|
+
shopping_list: ForeignRelation["B2bComponentsShoppingList"]
|
|
10
|
+
product: ForeignRelation["Product"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class B2bComponentsShoppingListLineItemEndpoint(AdminEndpoint[B2bComponentsShoppingListLineItem]):
|
|
14
|
+
name = "b2b_components_shopping_list_line_item"
|
|
15
|
+
path = "/b2b-components-shopping-list-line-item"
|
|
16
|
+
model_class = B2bComponentsShoppingListLineItem
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
from ..core.product import Product # noqa: E402
|
|
20
|
+
from .b2b_components_shopping_list import B2bComponentsShoppingList # noqa: E402
|
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
from
|
|
1
|
+
from shopware_api_client.base import AdminEndpoint, AdminModel
|
|
2
|
+
from shopware_api_client.endpoints.relations import ForeignRelation
|
|
3
|
+
from shopware_api_client.models.b2b_employee import B2bEmployeeBase
|
|
2
4
|
|
|
3
|
-
from pydantic import AwareDatetime
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
from ...base_fields import IdField
|
|
7
|
-
from ...relations import ForeignRelation
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class B2bEmployeeBase(ApiModelBase[EndpointClass]):
|
|
11
|
-
_identifier: str = "b2b_employee"
|
|
12
|
-
|
|
13
|
-
business_partner_customer_id: IdField | None = None
|
|
14
|
-
role_id: IdField | None = None
|
|
15
|
-
language_id: IdField
|
|
16
|
-
active: bool | None = None
|
|
17
|
-
first_name: str
|
|
18
|
-
last_name: str
|
|
19
|
-
email: str
|
|
20
|
-
recovery_time: AwareDatetime | None = None
|
|
21
|
-
custom_fields: dict[str, Any] | None = None
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class B2bEmployeeRelations:
|
|
6
|
+
class B2bEmployee(B2bEmployeeBase, AdminModel["B2bEmployeeEndpoint"]):
|
|
25
7
|
business_partner_customer: ForeignRelation["Customer"]
|
|
26
8
|
role: ForeignRelation["B2bComponentsRole"]
|
|
27
9
|
language: ForeignRelation["Language"]
|
|
28
10
|
|
|
29
11
|
|
|
30
|
-
class
|
|
31
|
-
pass
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class B2bEmployeeEndpoint(EndpointBase[B2bEmployee]):
|
|
12
|
+
class B2bEmployeeEndpoint(AdminEndpoint[B2bEmployee]):
|
|
35
13
|
name = "b2b_employee"
|
|
36
14
|
path = "/b2b-employee"
|
|
37
15
|
model_class = B2bEmployee
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
+
from shopware_api_client.base import AdminEndpoint, AdminModel
|
|
2
|
+
from shopware_api_client.endpoints.relations import ForeignRelation
|
|
3
|
+
from shopware_api_client.models.dynamic_access import DynamicAccessBase
|
|
1
4
|
|
|
2
|
-
from shopware_api_client.endpoints.admin.core.product import Product
|
|
3
|
-
from shopware_api_client.endpoints.admin.core.rule import Rule
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
from ...base_fields import IdField
|
|
7
|
-
from ...relations import ForeignRelation
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class DynamicAccessBase(ApiModelBase[EndpointClass]):
|
|
11
|
-
_identifier: str = "dynamic_access"
|
|
12
|
-
|
|
13
|
-
product_id: IdField
|
|
14
|
-
rule_id: IdField
|
|
15
|
-
|
|
16
|
-
class DynamicAccessRelations:
|
|
6
|
+
class DynamicAccess(DynamicAccessBase, AdminModel["DynamicAccessEndpoint"]):
|
|
17
7
|
product: ForeignRelation["Product"]
|
|
18
8
|
rule: ForeignRelation["Rule"]
|
|
19
9
|
|
|
20
10
|
|
|
21
|
-
class
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class DynamicAccessEndpoint(EndpointBase[DynamicAccess]):
|
|
11
|
+
class DynamicAccessEndpoint(AdminEndpoint[DynamicAccess]):
|
|
26
12
|
name = "swag_dynamic_access_product_rule"
|
|
27
13
|
path = "/swag-dynamic-access-product-rule"
|
|
28
14
|
model_class = DynamicAccess
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
from ..core.product import Product # noqa: E402
|
|
18
|
+
from ..core.rule import Rule # noqa: E402
|
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
from
|
|
1
|
+
from shopware_api_client.base import AdminEndpoint, AdminModel
|
|
2
|
+
from shopware_api_client.endpoints.relations import ForeignRelation, ManyRelation
|
|
3
|
+
from shopware_api_client.models.acl_role import AclRoleBase
|
|
2
4
|
|
|
3
|
-
from ....base import ApiModelBase, EndpointBase, EndpointClass
|
|
4
|
-
from ...relations import ForeignRelation, ManyRelation
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class AclRoleBase(ApiModelBase[EndpointClass]):
|
|
8
|
-
_identifier = "acl_role"
|
|
9
|
-
|
|
10
|
-
name: str
|
|
11
|
-
description: str | None = None
|
|
12
|
-
privileges: list[str]
|
|
13
|
-
deleted_at: AwareDatetime | None = None
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class AclRoleRelations:
|
|
6
|
+
class AclRole(AclRoleBase, AdminModel["AclRoleEndpoint"]):
|
|
17
7
|
users: ManyRelation["User"]
|
|
18
8
|
app: ForeignRelation["App"]
|
|
19
9
|
integrations: ManyRelation["Integration"]
|
|
20
10
|
|
|
21
11
|
|
|
22
|
-
class
|
|
23
|
-
pass
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class AclRoleEndpoint(EndpointBase[AclRole]):
|
|
12
|
+
class AclRoleEndpoint(AdminEndpoint[AclRole]):
|
|
27
13
|
name = "acl_role"
|
|
28
14
|
path = "/acl-role"
|
|
29
15
|
model_class = AclRole
|
|
@@ -3,10 +3,9 @@ from typing import Any
|
|
|
3
3
|
from pydantic import BaseModel
|
|
4
4
|
from pydantic.main import IncEx
|
|
5
5
|
|
|
6
|
+
from shopware_api_client.base import AdminEndpoint, AdminModel
|
|
6
7
|
from shopware_api_client.exceptions import SWAPIMethodNotAvailable
|
|
7
8
|
|
|
8
|
-
from ....base import ApiModelBase, EndpointBase, EndpointClass
|
|
9
|
-
|
|
10
9
|
|
|
11
10
|
class Bundle(BaseModel):
|
|
12
11
|
css: list[str]
|
|
@@ -25,7 +24,7 @@ class AppBundle(BaseModel):
|
|
|
25
24
|
name: str
|
|
26
25
|
|
|
27
26
|
|
|
28
|
-
class
|
|
27
|
+
class ApiInfo(AdminModel["ApiInfoEndpoint"]):
|
|
29
28
|
_identifier = "api_info"
|
|
30
29
|
|
|
31
30
|
version: str
|
|
@@ -36,25 +35,23 @@ class ApiInfoBase(ApiModelBase[EndpointClass]):
|
|
|
36
35
|
license_toggles: dict[str, bool] | None = None
|
|
37
36
|
|
|
38
37
|
|
|
39
|
-
class
|
|
40
|
-
pass
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class ApiInfoEndpoint(EndpointBase[ApiInfo]):
|
|
38
|
+
class ApiInfoEndpoint(AdminEndpoint[ApiInfo]):
|
|
44
39
|
name = "adminWorker"
|
|
45
40
|
path = "/_info/config"
|
|
46
41
|
model_class = ApiInfo
|
|
47
42
|
|
|
48
43
|
async def delete(self, pk: str) -> bool:
|
|
49
44
|
raise SWAPIMethodNotAvailable()
|
|
50
|
-
|
|
45
|
+
|
|
51
46
|
async def get(self, pk: str) -> ApiInfo | dict[str, Any]:
|
|
52
47
|
raise SWAPIMethodNotAvailable()
|
|
53
48
|
|
|
54
49
|
async def create(self, obj: ApiInfo | dict[str, Any]) -> ApiInfo | dict[str, Any] | None:
|
|
55
50
|
raise SWAPIMethodNotAvailable()
|
|
56
51
|
|
|
57
|
-
async def update(
|
|
52
|
+
async def update(
|
|
53
|
+
self, pk: str, obj: ApiInfo | dict[str, Any], update_fields: IncEx | None = None
|
|
54
|
+
) -> ApiInfo | dict[str, Any] | None:
|
|
58
55
|
raise SWAPIMethodNotAvailable()
|
|
59
56
|
|
|
60
57
|
async def bulk_upsert(
|
|
@@ -62,5 +59,7 @@ class ApiInfoEndpoint(EndpointBase[ApiInfo]):
|
|
|
62
59
|
) -> dict[str, Any]:
|
|
63
60
|
raise SWAPIMethodNotAvailable()
|
|
64
61
|
|
|
65
|
-
async def bulk_delete(
|
|
66
|
-
|
|
62
|
+
async def bulk_delete(
|
|
63
|
+
self, objs: list[ApiInfo] | list[dict[str, Any]], fail_silently: bool = False, **request_kwargs: Any
|
|
64
|
+
) -> dict[str, Any]:
|
|
65
|
+
raise SWAPIMethodNotAvailable()
|
|
@@ -1,52 +1,15 @@
|
|
|
1
|
-
from
|
|
1
|
+
from shopware_api_client.base import AdminEndpoint, AdminModel
|
|
2
|
+
from shopware_api_client.endpoints.relations import ForeignRelation, ManyRelation
|
|
3
|
+
from shopware_api_client.models.app import AppBase
|
|
2
4
|
|
|
3
|
-
from pydantic import Field
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
from ...base_fields import IdField
|
|
7
|
-
from ...relations import ForeignRelation, ManyRelation
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class AppBase(ApiModelBase[EndpointClass]):
|
|
11
|
-
_identifier = "app"
|
|
12
|
-
|
|
13
|
-
name: str
|
|
14
|
-
path: str
|
|
15
|
-
author: str | None = None
|
|
16
|
-
copyright: str | None = None
|
|
17
|
-
license: str | None = None
|
|
18
|
-
active: bool
|
|
19
|
-
configurable: bool
|
|
20
|
-
privacy: str | None = None
|
|
21
|
-
version: str
|
|
22
|
-
icon: str | None = Field(None, description="Runtime field, cannot be used as part of the criteria.", exclude=True)
|
|
23
|
-
modules: list[dict[str, Any]] | None = None
|
|
24
|
-
main_module: dict[str, Any] | None = None
|
|
25
|
-
cookies: list[dict[str, Any]] | None = None
|
|
26
|
-
allow_disable: bool
|
|
27
|
-
base_app_url: str | None = None
|
|
28
|
-
allowed_hosts: list[str] | None = None
|
|
29
|
-
template_load_priority: int | None = None
|
|
30
|
-
label: str
|
|
31
|
-
description: str | None = None
|
|
32
|
-
privacy_policy_extensions: str | None = None
|
|
33
|
-
custom_fields: dict[str, Any] | None = None
|
|
34
|
-
integration_id: IdField
|
|
35
|
-
acl_role_id: IdField
|
|
36
|
-
translated: dict[str, Any] | None = None
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class AppRelations:
|
|
6
|
+
class App(AppBase, AdminModel["AppEndpoint"]):
|
|
40
7
|
app: ForeignRelation["App"]
|
|
41
8
|
acl_roles: ManyRelation["AclRole"]
|
|
42
9
|
integrations: ManyRelation["Integration"]
|
|
43
10
|
|
|
44
11
|
|
|
45
|
-
class
|
|
46
|
-
pass
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class AppEndpoint(EndpointBase[App]):
|
|
12
|
+
class AppEndpoint(AdminEndpoint[App]):
|
|
50
13
|
name = "app"
|
|
51
14
|
path = "/app"
|
|
52
15
|
model_class = App
|
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
from
|
|
1
|
+
from shopware_api_client.base import AdminEndpoint, AdminModel
|
|
2
|
+
from shopware_api_client.endpoints.relations import ForeignRelation, ManyRelation
|
|
3
|
+
from shopware_api_client.models.app_script_condition import AppScriptConditionBase
|
|
2
4
|
|
|
3
|
-
from ....base import ApiModelBase, EndpointBase, EndpointClass
|
|
4
|
-
from ...base_fields import IdField
|
|
5
|
-
from ...relations import ForeignRelation, ManyRelation
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
class AppScriptConditionBase(ApiModelBase[EndpointClass]):
|
|
9
|
-
_identifier = "app_script_condition"
|
|
10
|
-
|
|
11
|
-
identifier: str
|
|
12
|
-
name: str
|
|
13
|
-
active: bool
|
|
14
|
-
group: str | None = None
|
|
15
|
-
script: str | None = None
|
|
16
|
-
config: list[dict[str, Any]] | None = None
|
|
17
|
-
app_id: IdField
|
|
18
|
-
translated: dict[str, Any] | None = None
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class AppScriptConditionRelations:
|
|
6
|
+
class AppScriptCondition(AppScriptConditionBase, AdminModel["AppScriptConditionEndpoint"]):
|
|
22
7
|
app: ForeignRelation["App"]
|
|
23
8
|
rule_conditions: ManyRelation["RuleCondition"]
|
|
24
9
|
|
|
25
10
|
|
|
26
|
-
class
|
|
27
|
-
pass
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class AppScriptConditionEndpoint(EndpointBase[AppScriptCondition]):
|
|
11
|
+
class AppScriptConditionEndpoint(AdminEndpoint[AppScriptCondition]):
|
|
31
12
|
name = "app_script_condition"
|
|
32
13
|
path = "/app-script-condition"
|
|
33
14
|
model_class = AppScriptCondition
|