11import enum
2+ import os
23import urllib .parse
34from datetime import datetime
45
5- from sp_api .base import Client , sp_endpoint , fill_query_params , ApiResponse
6+ from sp_api .base import Client , sp_endpoint , fill_query_params , ApiResponse , Marketplaces
67
78
89class AmznShippingBusiness (str , enum .Enum ):
9- AmazonShipping_US = "AmazonShipping_US"
10- AmazonShipping_IN = "AmazonShipping_IN"
11- AmazonShipping_UK = "AmazonShipping_UK"
12- AmazonShipping_UAE = "AmazonShipping_UAE"
13- AmazonShipping_SA = "AmazonShipping_SA"
14- AmazonShipping_EG = "AmazonShipping_EG"
15- AmazonShipping_IT = "AmazonShipping_IT"
16- AmazonShipping_ES = "AmazonShipping_ES"
17- AmazonShipping_FR = "AmazonShipping_FR"
18- AmazonShipping_JP = "AmazonShipping_JP"
10+ US = "AmazonShipping_US"
11+ IN = "AmazonShipping_IN"
12+ UK = "AmazonShipping_UK"
13+ AE = "AmazonShipping_UAE"
14+ SA = "AmazonShipping_SA"
15+ IT = "AmazonShipping_IT"
16+ EG = "AmazonShipping_EG"
17+ ES = "AmazonShipping_ES"
18+ FR = "AmazonShipping_FR"
19+ JP = "AmazonShipping_JP"
20+
21+ @classmethod
22+ def has_key (cls , name ):
23+ return name in cls .__members__
1924
2025
2126class Shipping (Client ):
@@ -26,11 +31,19 @@ class Shipping(Client):
2631 Provides programmatic access to Amazon Shipping APIs.
2732 """
2833
29- amzn_shipping_business : AmznShippingBusiness = AmznShippingBusiness .AmazonShipping_UK
34+ amzn_shipping_business : AmznShippingBusiness = AmznShippingBusiness .US
3035
3136 def __init__ (self , * args , ** kwargs ):
3237 if 'amzn_shipping_business' in kwargs :
33- self .amzn_shipping_business = kwargs .pop ('amzn_shipping_business' , AmznShippingBusiness .AmazonShipping_UK )
38+ self .amzn_shipping_business = kwargs .pop ('amzn_shipping_business' , AmznShippingBusiness .US )
39+ else :
40+ marketplace = args [0 ] if len (args ) > 0 else Marketplaces .US
41+ if os .environ .get ('SP_API_DEFAULT_MARKETPLACE' , None ):
42+ marketplace = Marketplaces [os .environ .get ('SP_API_DEFAULT_MARKETPLACE' )]
43+
44+ if AmznShippingBusiness .has_key (marketplace .name ):
45+ self .amzn_shipping_business = AmznShippingBusiness [marketplace .name ]
46+
3447 super ().__init__ (* args , ** kwargs )
3548
3649 @property
0 commit comments