- Implement tests for `EbayOAuthClient` to verify authorization URL generation with configured scopes and token reuse logic. - Add tests for `WebhookChallengeHandler` to ensure correct SHA256 response generation and for `WebhookSignatureParser` to validate extraction of known fields from signature strings.
284 lines
14 KiB
Python
284 lines
14 KiB
Python
from collections.abc import Mapping
|
|
from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING, Generator
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from ..types import UNSET, Unset
|
|
|
|
from ..types import UNSET, Unset
|
|
from typing import cast
|
|
from typing import Union
|
|
|
|
if TYPE_CHECKING:
|
|
from ..models.shipping_option import ShippingOption
|
|
from ..models.category_type import CategoryType
|
|
from ..models.time_duration import TimeDuration
|
|
from ..models.region_set import RegionSet
|
|
|
|
|
|
|
|
|
|
|
|
T = TypeVar("T", bound="FulfillmentPolicyRequest")
|
|
|
|
|
|
|
|
@_attrs_define
|
|
class FulfillmentPolicyRequest:
|
|
""" This root container defines a seller's fulfillment policy for a specific marketplace and category group. This type
|
|
is used when creating or updating a fulfillment business policy.
|
|
|
|
Attributes:
|
|
category_types (Union[Unset, list['CategoryType']]): This container is used to specify whether the fulfillment
|
|
business policy applies to motor vehicle listings, or if it applies to non-motor vehicle listings.
|
|
description (Union[Unset, str]): A seller-defined description of the fulfillment policy. This description is
|
|
only for the seller's use, and is not exposed on any eBay pages. <br><br><b>Max length</b>: 250
|
|
freight_shipping (Union[Unset, bool]): This field is included and set to <code>true</code> if freight shipping
|
|
is available for the item. Freight shipping can be used for large items over 150 lbs.<br><br><b>Default</b>:
|
|
false
|
|
global_shipping (Union[Unset, bool]): <span class="tablenote"><b>Note</b>: This field is only applicable for the
|
|
eBay United Kingdom marketplace (<code>EBAY_GB</code>).</span><br>This field is included and set to
|
|
<code>true</code> if the seller wants to use the Global Shipping Program for international shipments. See the <a
|
|
href="https://pages.ebay.com/help/sell/shipping-globally.html ">Global Shipping Program</a> help topic for more
|
|
details and requirements on the Global Shipping Program.<br><br>A seller can use a combination of the Global
|
|
Shipping Program and other international shipping services. <br><br>If set to <code>false</code> or if the field
|
|
is omitted, the seller has to manually specifying individual international shipping services (if the seller
|
|
ships internationally), as described in <a href="https://developer.ebay.com/api-docs/sell/static/seller-
|
|
accounts/ht_shipping-worldwide.html ">Setting up worldwide shipping</a>. <br><br>Sellers opt in or out of the
|
|
Global Shipping Program through the Shipping preferences in My eBay.<br><br>eBay International Shipping is an
|
|
account level setting; no field needs to be set in a Fulfillment business policy to enable eBay International
|
|
Shipping. If a US seller's account is opted in to eBay International Shipping, this shipping option will be
|
|
enabled automatically for all listings where international shipping is available. A US seller who is opted in to
|
|
eBay International Shipping can also specify individual international shipping service options for a Fulfillment
|
|
business policy.<p><b>Default</b>: false</p>
|
|
handling_time (Union[Unset, TimeDuration]): A type used to specify a period of time using a specified time-
|
|
measurement unit. Payment, return, and fulfillment business policies all use this type to specify time
|
|
windows.<br><br>Whenever a container that uses this type is used in a request, both of these fields are
|
|
required. Similarly, whenever a container that uses this type is returned in a response, both of these fields
|
|
are always returned.
|
|
local_pickup (Union[Unset, bool]): This field should be included and set to <code>true</code> if local pickup is
|
|
one of the fulfillment options available to the buyer. It is possible for the seller to make local pickup and
|
|
some shipping service options available to the buyer.<br><br>With local pickup, the buyer and seller make
|
|
arrangements for pickup time and location.<br><br><b>Default</b>: <code>false</code>
|
|
marketplace_id (Union[Unset, str]): The ID of the eBay marketplace to which this fulfillment policy applies. For
|
|
implementation help, refer to <a href='https://developer.ebay.com/api-
|
|
docs/sell/account/types/ba:MarketplaceIdEnum'>eBay API documentation</a>
|
|
name (Union[Unset, str]): A seller-defined name for this fulfillment policy. Names must be unique for policies
|
|
assigned to the same marketplace. <br><br><b>Max length</b>: 64
|
|
pickup_drop_off (Union[Unset, bool]): This field should be included and set to <code>true</code> if the seller
|
|
offers the "Click and Collect" feature for an item. <p>To enable "Click and Collect" on a listing, a seller must
|
|
be eligible for Click and Collect. Currently, Click and Collect is available to only large retail merchants
|
|
selling in the eBay AU, UK, DE, FR, and IT marketplaces.</p> <p>In addition to setting this field to
|
|
<code>true</code>, the merchant must also do the following to enable the "Click and Collect" option on a
|
|
listing: <ul><li>Have inventory for the product at one or more physical stores tied to the merchant's account.
|
|
<p>Sellers can use the <b>createInventoryLocation</b> method in the Inventory API to associate physical stores
|
|
to their account and they can then add inventory to specific store locations.</p></li><li>Set an immediate
|
|
payment requirement on the item. The immediate payment feature requires the seller to: <ul><li>Set the
|
|
<b>immediatePay</b> flag in the payment policy to 'true'.</li><li>Have a valid store location with a complete
|
|
street address.</li></ul></li></ul><p>When a merchant successfully lists an item with Click and Collect,
|
|
prospective buyers within a reasonable distance from one of the merchant's stores (that has stock available)
|
|
will see the "Available for Click and Collect" option on the listing, along with information on the closest
|
|
store that has the item.</p><b>Default</b>: false
|
|
shipping_options (Union[Unset, list['ShippingOption']]): This array is used to provide detailed information on
|
|
the domestic and international shipping options available for the policy. <br><br>A separate
|
|
<b>ShippingOption</b> object is required for domestic shipping service options and for international shipping
|
|
service options (if the seller ships to international locations). <ul><li>The <b>optionType</b> field is used to
|
|
indicate whether the <b>ShippingOption</b> object applies to domestic or international shipping, and the
|
|
<b>costType</b> field is used to indicate whether flat-rate shipping or calculated shipping will be used.</li>
|
|
<li>The <b>rateTableId</b> field can be used to associate a defined shipping rate table to the policy, and the
|
|
<b>packageHandlingCost</b> container can be used to set a handling charge for the policy.</li></ul> <p>A
|
|
separate <b>ShippingServices</b> object will be used to specify cost and other details for every available
|
|
domestic and international shipping service option. </p>
|
|
ship_to_locations (Union[Unset, RegionSet]): This type consists of the <b>regionIncluded</b> and
|
|
<b>regionExcluded</b> arrays, which indicate the areas to where the seller does and doesn't ship.
|
|
"""
|
|
|
|
category_types: Union[Unset, list['CategoryType']] = UNSET
|
|
description: Union[Unset, str] = UNSET
|
|
freight_shipping: Union[Unset, bool] = UNSET
|
|
global_shipping: Union[Unset, bool] = UNSET
|
|
handling_time: Union[Unset, 'TimeDuration'] = UNSET
|
|
local_pickup: Union[Unset, bool] = UNSET
|
|
marketplace_id: Union[Unset, str] = UNSET
|
|
name: Union[Unset, str] = UNSET
|
|
pickup_drop_off: Union[Unset, bool] = UNSET
|
|
shipping_options: Union[Unset, list['ShippingOption']] = UNSET
|
|
ship_to_locations: Union[Unset, 'RegionSet'] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
|
|
|
|
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
from ..models.shipping_option import ShippingOption
|
|
from ..models.category_type import CategoryType
|
|
from ..models.time_duration import TimeDuration
|
|
from ..models.region_set import RegionSet
|
|
category_types: Union[Unset, list[dict[str, Any]]] = UNSET
|
|
if not isinstance(self.category_types, Unset):
|
|
category_types = []
|
|
for category_types_item_data in self.category_types:
|
|
category_types_item = category_types_item_data.to_dict()
|
|
category_types.append(category_types_item)
|
|
|
|
|
|
|
|
description = self.description
|
|
|
|
freight_shipping = self.freight_shipping
|
|
|
|
global_shipping = self.global_shipping
|
|
|
|
handling_time: Union[Unset, dict[str, Any]] = UNSET
|
|
if not isinstance(self.handling_time, Unset):
|
|
handling_time = self.handling_time.to_dict()
|
|
|
|
local_pickup = self.local_pickup
|
|
|
|
marketplace_id = self.marketplace_id
|
|
|
|
name = self.name
|
|
|
|
pickup_drop_off = self.pickup_drop_off
|
|
|
|
shipping_options: Union[Unset, list[dict[str, Any]]] = UNSET
|
|
if not isinstance(self.shipping_options, Unset):
|
|
shipping_options = []
|
|
for shipping_options_item_data in self.shipping_options:
|
|
shipping_options_item = shipping_options_item_data.to_dict()
|
|
shipping_options.append(shipping_options_item)
|
|
|
|
|
|
|
|
ship_to_locations: Union[Unset, dict[str, Any]] = UNSET
|
|
if not isinstance(self.ship_to_locations, Unset):
|
|
ship_to_locations = self.ship_to_locations.to_dict()
|
|
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update({
|
|
})
|
|
if category_types is not UNSET:
|
|
field_dict["categoryTypes"] = category_types
|
|
if description is not UNSET:
|
|
field_dict["description"] = description
|
|
if freight_shipping is not UNSET:
|
|
field_dict["freightShipping"] = freight_shipping
|
|
if global_shipping is not UNSET:
|
|
field_dict["globalShipping"] = global_shipping
|
|
if handling_time is not UNSET:
|
|
field_dict["handlingTime"] = handling_time
|
|
if local_pickup is not UNSET:
|
|
field_dict["localPickup"] = local_pickup
|
|
if marketplace_id is not UNSET:
|
|
field_dict["marketplaceId"] = marketplace_id
|
|
if name is not UNSET:
|
|
field_dict["name"] = name
|
|
if pickup_drop_off is not UNSET:
|
|
field_dict["pickupDropOff"] = pickup_drop_off
|
|
if shipping_options is not UNSET:
|
|
field_dict["shippingOptions"] = shipping_options
|
|
if ship_to_locations is not UNSET:
|
|
field_dict["shipToLocations"] = ship_to_locations
|
|
|
|
return field_dict
|
|
|
|
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
from ..models.shipping_option import ShippingOption
|
|
from ..models.category_type import CategoryType
|
|
from ..models.time_duration import TimeDuration
|
|
from ..models.region_set import RegionSet
|
|
d = dict(src_dict)
|
|
category_types = []
|
|
_category_types = d.pop("categoryTypes", UNSET)
|
|
for category_types_item_data in (_category_types or []):
|
|
category_types_item = CategoryType.from_dict(category_types_item_data)
|
|
|
|
|
|
|
|
category_types.append(category_types_item)
|
|
|
|
|
|
description = d.pop("description", UNSET)
|
|
|
|
freight_shipping = d.pop("freightShipping", UNSET)
|
|
|
|
global_shipping = d.pop("globalShipping", UNSET)
|
|
|
|
_handling_time = d.pop("handlingTime", UNSET)
|
|
handling_time: Union[Unset, TimeDuration]
|
|
if isinstance(_handling_time, Unset):
|
|
handling_time = UNSET
|
|
else:
|
|
handling_time = TimeDuration.from_dict(_handling_time)
|
|
|
|
|
|
|
|
|
|
local_pickup = d.pop("localPickup", UNSET)
|
|
|
|
marketplace_id = d.pop("marketplaceId", UNSET)
|
|
|
|
name = d.pop("name", UNSET)
|
|
|
|
pickup_drop_off = d.pop("pickupDropOff", UNSET)
|
|
|
|
shipping_options = []
|
|
_shipping_options = d.pop("shippingOptions", UNSET)
|
|
for shipping_options_item_data in (_shipping_options or []):
|
|
shipping_options_item = ShippingOption.from_dict(shipping_options_item_data)
|
|
|
|
|
|
|
|
shipping_options.append(shipping_options_item)
|
|
|
|
|
|
_ship_to_locations = d.pop("shipToLocations", UNSET)
|
|
ship_to_locations: Union[Unset, RegionSet]
|
|
if isinstance(_ship_to_locations, Unset):
|
|
ship_to_locations = UNSET
|
|
else:
|
|
ship_to_locations = RegionSet.from_dict(_ship_to_locations)
|
|
|
|
|
|
|
|
|
|
fulfillment_policy_request = cls(
|
|
category_types=category_types,
|
|
description=description,
|
|
freight_shipping=freight_shipping,
|
|
global_shipping=global_shipping,
|
|
handling_time=handling_time,
|
|
local_pickup=local_pickup,
|
|
marketplace_id=marketplace_id,
|
|
name=name,
|
|
pickup_drop_off=pickup_drop_off,
|
|
shipping_options=shipping_options,
|
|
ship_to_locations=ship_to_locations,
|
|
)
|
|
|
|
|
|
fulfillment_policy_request.additional_properties = d
|
|
return fulfillment_policy_request
|
|
|
|
@property
|
|
def additional_keys(self) -> list[str]:
|
|
return list(self.additional_properties.keys())
|
|
|
|
def __getitem__(self, key: str) -> Any:
|
|
return self.additional_properties[key]
|
|
|
|
def __setitem__(self, key: str, value: Any) -> None:
|
|
self.additional_properties[key] = value
|
|
|
|
def __delitem__(self, key: str) -> None:
|
|
del self.additional_properties[key]
|
|
|
|
def __contains__(self, key: str) -> bool:
|
|
return key in self.additional_properties
|