timotheus / ebaysdk-python

eBay API SDK for Python
https://developer.ebay.com/tools/sdks
Other
808 stars 326 forks source link

Specifiying multiple fields in particular ShippingServiceOptions #292

Closed springfielddatarecovery closed 4 years ago

springfielddatarecovery commented 4 years ago

Love using this SDK thank you for making this : ). I have one particular issue I am trying to work around which is specifying multiple ShippingServiceOptions fields in api.execute(AddFixedPriceItem). In the samples provided for the trading api there is only one ShippingServiceOptions given. What if you want to add multiples? Here is how I would think it would look but of course then the key in the dictionary is not unique so only the final key ends up being submitted to eBay.

"Item": { "ShippingDetails": { "GlobalShipping": True, "ShippingType": "Flat", "ShippingServiceOptions": { "ShippingServicePriority": "1", "ShippingService": "USPSFirstClass", "FreeShipping": True }, "ShippingServiceOptions": { "ShippingServicePriority": "2", "ShippingService": "USPSExpressMail", "ShippingServiceCost":"30.00", }, "ShippingPackageDetails":{ "WeightMajor":"2", "WeightMinor":"1", "PackageDepth":"2", "PackageWidth":"6", "PackageLength":"9" } }, }

Reference: Trading API example: https://github.com/timotheus/ebaysdk-python/blob/master/samples/trading.py#L148

springfielddatarecovery commented 4 years ago

I figured this out. I have added the correct way to do this in case anybody else sees this. International shipping added for extra points. 'ShippingDetails': { 'GlobalShipping': 'true', 'ShippingServiceOptions': [{'FreeShipping': 'true', 'ShippingService': 'USPSFirstClass', 'ShippingServicePriority': '1'}, {'ShippingService': 'USPSExpressMail', 'ShippingServiceCost': '25.00', 'ShippingServicePriority': '2', }], 'InternationalShippingServiceOption': [ {'ShipToLocation': ['Americas', 'Europe', 'CA', 'GB', 'MX', 'DE', 'BR', 'FR', 'AU'], 'ShippingService': 'USPSFirstClassMailInternational', 'ShippingServicePriority': '1'}, {'ShipToLocation': 'Worldwide', 'ShippingService': 'USPSPriorityMailInternationalSmallFlatRateBox', 'ShippingServicePriority': '2'}], 'ShippingType': 'FlatDomesticCalculatedInternational'}, 'ShippingPackageDetails': {'PackageDepth': '4', 'PackageLength': '6', 'PackageWidth': '6', 'ShippingPackage': 'PackageThickEnvelope', 'WeightMajor': '0', 'WeightMinor': '15', }