diff --git a/Source/FikaAmazonAPI/Utils/Country.cs b/Source/FikaAmazonAPI/Utils/Country.cs index df18b378..a7d57761 100644 --- a/Source/FikaAmazonAPI/Utils/Country.cs +++ b/Source/FikaAmazonAPI/Utils/Country.cs @@ -24,32 +24,32 @@ private Country(string code, string name, string domain, string sellercentralUrl AmazonlUrl = $"https://amazon.{domain}"; } - public static Country US { get { return new Country("US", "United States of America", "com", "https://sellercentral.amazon.com", "https://vendorcentral.amazon.ca"); } } - public static Country CA { get { return new Country("CA", "Canada", "ca", "https://sellercentral.amazon.ca", "https://vendorcentral.amazon.ca"); } } - public static Country MX { get { return new Country("MX", "Mexico", "com.mx", "https://sellercentral.amazon.com.mx", "https://vendorcentral.amazon.com.mx"); } } - public static Country BR { get { return new Country("BR", "Brazil", "com.br", "https://sellercentral.amazon.com.br", "https://vendorcentral.amazon.com.br"); } } - - public static Country ES { get { return new Country("ES", "Spain", "es", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.es"); } } - public static Country GB { get { return new Country("GB", "United Kingdom", "co.uk", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.co.uk"); } } - public static Country FR { get { return new Country("FR", "France", "fr", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.fr"); } } - public static Country BE { get { return new Country("BE", "Belgium", "com.be", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.eu"); } } - public static Country NL { get { return new Country("NL", "Netherlands", "nl", "https://sellercentral.amazon.nl", "https://vendorcentral.amazon.nl"); } } - public static Country DE { get { return new Country("DE", "Germany", "de", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.de"); } } - public static Country IT { get { return new Country("IT", "Italy", "it", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.it"); } } - public static Country SE { get { return new Country("SE", "Sweden", "se", "https://sellercentral.amazon.se", "https://vendorcentral.amazon.se"); } } - public static Country PL { get { return new Country("PL", "Poland", "pl", "https://sellercentral.amazon.pl", "https://vendorcentral.amazon.pl"); } } - public static Country EG { get { return new Country("EG", "Egypt", "eg", "https://sellercentral.amazon.eg", "https://vendorcentral.amazon.me"); } } - public static Country TR { get { return new Country("TR", "Turkey", "com.tr", "https://sellercentral.amazon.com.tr", "https://vendorcentral.amazon.com.tr"); } } - public static Country AE { get { return new Country("AE", "United Arab Emirates", "ae", "https://sellercentral.amazon.ae", "https://vendorcentral.amazon.me"); } } - public static Country IN { get { return new Country("IN", "India", "in", "https://sellercentral.amazon.in", "https://www.vendorcentral.in"); } } - public static Country SA { get { return new Country("SA", "Saudi Arabia", "sa", "https://sellercentral.amazon.sa", "https://vendorcentral.amazon.me"); } } - public static Country IE { get { return new Country("IE", "Ireland", "ie", "https://sellercentral.amazon.ie", "https://vendorcentral.amazon.ie"); } } - - - public static Country SG { get { return new Country("SG", "Singapore", "sg", "https://sellercentral.amazon.sg", "https://vendorcentral.amazon.com.sg"); } } - public static Country AU { get { return new Country("AU", "Australia", "com.au", "https://sellercentral.amazon.com.au", "https://vendorcentral.amazon.com.au"); } } - public static Country JP { get { return new Country("JP", "Japan", "co.jp", "https://sellercentral.amazon.co.jp", "https://vendorcentral.amazon.co.jp"); } } - - public static Country ZA { get { return new Country("ZA", "South Africa", "co.za", "https://sellercentral.amazon.co.za", "https://vendorcentral.amazon.co.za"); } } + public static readonly Country US = new Country("US", "United States of America", "com", "https://sellercentral.amazon.com", "https://vendorcentral.amazon.ca"); + public static readonly Country CA = new Country("CA", "Canada", "ca", "https://sellercentral.amazon.ca", "https://vendorcentral.amazon.ca"); + public static readonly Country MX = new Country("MX", "Mexico", "com.mx", "https://sellercentral.amazon.com.mx", "https://vendorcentral.amazon.com.mx"); + public static readonly Country BR = new Country("BR", "Brazil", "com.br", "https://sellercentral.amazon.com.br", "https://vendorcentral.amazon.com.br"); + + public static readonly Country ES = new Country("ES", "Spain", "es", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.es"); + public static readonly Country GB = new Country("GB", "United Kingdom", "co.uk", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.co.uk"); + public static readonly Country FR = new Country("FR", "France", "fr", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.fr"); + public static readonly Country BE = new Country("BE", "Belgium", "com.be", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.eu"); + public static readonly Country NL = new Country("NL", "Netherlands", "nl", "https://sellercentral.amazon.nl", "https://vendorcentral.amazon.nl"); + public static readonly Country DE = new Country("DE", "Germany", "de", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.de"); + public static readonly Country IT = new Country("IT", "Italy", "it", "https://sellercentral-europe.amazon.com", "https://vendorcentral.amazon.it"); + public static readonly Country SE = new Country("SE", "Sweden", "se", "https://sellercentral.amazon.se", "https://vendorcentral.amazon.se"); + public static readonly Country PL = new Country("PL", "Poland", "pl", "https://sellercentral.amazon.pl", "https://vendorcentral.amazon.pl"); + public static readonly Country EG = new Country("EG", "Egypt", "eg", "https://sellercentral.amazon.eg", "https://vendorcentral.amazon.me"); + public static readonly Country TR = new Country("TR", "Turkey", "com.tr", "https://sellercentral.amazon.com.tr", "https://vendorcentral.amazon.com.tr"); + public static readonly Country AE = new Country("AE", "United Arab Emirates", "ae", "https://sellercentral.amazon.ae", "https://vendorcentral.amazon.me"); + public static readonly Country IN = new Country("IN", "India", "in", "https://sellercentral.amazon.in", "https://www.vendorcentral.in"); + public static readonly Country SA = new Country("SA", "Saudi Arabia", "sa", "https://sellercentral.amazon.sa", "https://vendorcentral.amazon.me"); + public static readonly Country IE = new Country("IE", "Ireland", "ie", "https://sellercentral.amazon.ie", "https://vendorcentral.amazon.ie"); + + + public static readonly Country SG = new Country("SG", "Singapore", "sg", "https://sellercentral.amazon.sg", "https://vendorcentral.amazon.com.sg"); + public static readonly Country AU = new Country("AU", "Australia", "com.au", "https://sellercentral.amazon.com.au", "https://vendorcentral.amazon.com.au"); + public static readonly Country JP = new Country("JP", "Japan", "co.jp", "https://sellercentral.amazon.co.jp", "https://vendorcentral.amazon.co.jp"); + + public static readonly Country ZA = new Country("ZA", "South Africa", "co.za", "https://sellercentral.amazon.co.za", "https://vendorcentral.amazon.co.za"); } } diff --git a/Source/FikaAmazonAPI/Utils/MarketPlace.cs b/Source/FikaAmazonAPI/Utils/MarketPlace.cs index 1bb5806f..a9545518 100644 --- a/Source/FikaAmazonAPI/Utils/MarketPlace.cs +++ b/Source/FikaAmazonAPI/Utils/MarketPlace.cs @@ -25,22 +25,23 @@ private MarketPlace(string id, Region region, Country country, BaseCurrencyCode [JsonConstructorAttribute] public MarketPlace() { } + + private static readonly List _allMarketplaces = new List() + { + // NorthAmerica + US, Canada, Mexico, Brazil, + // Europe + Spain, UnitedKingdom, France, Belgium, + Netherlands, Germany, Italy, Sweden, + Egypt, Poland, Turkey, UnitedArabEmirates, + India, SaudiArabia, SouthAfrica, Ireland, + // FarEast + Singapore, Australia, Japan + }; public static MarketPlace GetMarketPlaceByID(string id) { - var list = new List(); - //NorthAmerica - list.Add(US); list.Add(Canada); list.Add(Mexico); list.Add(Brazil); - //Europe - list.Add(Spain); list.Add(UnitedKingdom); list.Add(France); list.Add(Belgium); - list.Add(Netherlands); list.Add(Germany); list.Add(Italy); list.Add(Sweden); - list.Add(Egypt); list.Add(Poland); list.Add(Turkey); list.Add(UnitedArabEmirates); - list.Add(India); list.Add(SaudiArabia); list.Add(SouthAfrica); - list.Add(Ireland); - //FarEast - list.Add(Singapore); list.Add(Australia); list.Add(Japan); - - var marketpalce = list.FirstOrDefault(a => a.ID == id); + var marketpalce = _allMarketplaces.FirstOrDefault(a => a.ID == id); if (marketpalce == null) throw new AmazonInvalidInputException($"InvalidInput, MarketPlace or MarketPlaceID cannot be null for both!"); @@ -49,51 +50,39 @@ public static MarketPlace GetMarketPlaceByID(string id) public static MarketPlace GetMarketplaceByCountryCode(string countryCode) { - var list = new List(); - //NorthAmerica - list.Add(US); list.Add(Canada); list.Add(Mexico); list.Add(Brazil); - //Europe - list.Add(Spain); list.Add(UnitedKingdom); list.Add(France); list.Add(Belgium); - list.Add(Netherlands); list.Add(Germany); list.Add(Italy); list.Add(Sweden); - list.Add(Egypt); list.Add(Poland); list.Add(Turkey); list.Add(UnitedArabEmirates); - list.Add(India); list.Add(SaudiArabia); list.Add(SouthAfrica); - list.Add(Ireland); - //FarEast - list.Add(Singapore); list.Add(Australia); list.Add(Japan); - return list.FirstOrDefault(a => a.Country.Code == countryCode); + return _allMarketplaces.FirstOrDefault(a => a.Country.Code == countryCode); } //https://developer-docs.amazon.com/sp-api/docs/marketplace-ids //NorthAmerica - public static MarketPlace US { get { return new MarketPlace("ATVPDKIKX0DER", Region.NorthAmerica, Country.US, BaseCurrencyCode.USD); } } - public static MarketPlace Canada { get { return new MarketPlace("A2EUQ1WTGCTBG2", Region.NorthAmerica, Country.CA, BaseCurrencyCode.CAD); } } - public static MarketPlace Mexico { get { return new MarketPlace("A1AM78C64UM0Y8", Region.NorthAmerica, Country.MX, BaseCurrencyCode.MXN); } } - public static MarketPlace Brazil { get { return new MarketPlace("A2Q3Y263D00KWC", Region.NorthAmerica, Country.BR, BaseCurrencyCode.BRL); } } + public static readonly MarketPlace US = new MarketPlace("ATVPDKIKX0DER", Region.NorthAmerica, Country.US, BaseCurrencyCode.USD); + public static readonly MarketPlace Canada = new MarketPlace("A2EUQ1WTGCTBG2", Region.NorthAmerica, Country.CA, BaseCurrencyCode.CAD); + public static readonly MarketPlace Mexico = new MarketPlace("A1AM78C64UM0Y8", Region.NorthAmerica, Country.MX, BaseCurrencyCode.MXN); + public static readonly MarketPlace Brazil = new MarketPlace("A2Q3Y263D00KWC", Region.NorthAmerica, Country.BR, BaseCurrencyCode.BRL); //Europe - public static MarketPlace Spain { get { return new MarketPlace("A1RKKUPIHCS9HS", Region.Europe, Country.ES, BaseCurrencyCode.EUR); } } - public static MarketPlace UnitedKingdom { get { return new MarketPlace("A1F83G8C2ARO7P", Region.Europe, Country.GB, BaseCurrencyCode.GBP); } } - public static MarketPlace France { get { return new MarketPlace("A13V1IB3VIYZZH", Region.Europe, Country.FR, BaseCurrencyCode.EUR); } } - public static MarketPlace Belgium { get { return new MarketPlace("AMEN7PMS3EDWL", Region.Europe, Country.BE, BaseCurrencyCode.EUR); } } - public static MarketPlace Netherlands { get { return new MarketPlace("A1805IZSGTT6HS", Region.Europe, Country.NL, BaseCurrencyCode.EUR); } } - public static MarketPlace Germany { get { return new MarketPlace("A1PA6795UKMFR9", Region.Europe, Country.DE, BaseCurrencyCode.EUR); } } - public static MarketPlace Italy { get { return new MarketPlace("APJ6JRA9NG5V4", Region.Europe, Country.IT, BaseCurrencyCode.EUR); } } - public static MarketPlace Sweden { get { return new MarketPlace("A2NODRKZP88ZB9", Region.Europe, Country.SE, BaseCurrencyCode.SEK); } } - public static MarketPlace Egypt { get { return new MarketPlace("ARBP9OOSHTCHU", Region.Europe, Country.EG, BaseCurrencyCode.EGP); } } - public static MarketPlace Poland { get { return new MarketPlace("A1C3SOZRARQ6R3", Region.Europe, Country.PL, BaseCurrencyCode.PLN); } } - public static MarketPlace Turkey { get { return new MarketPlace("A33AVAJ2PDY3EV", Region.Europe, Country.TR, BaseCurrencyCode.TRY); } } - public static MarketPlace UnitedArabEmirates { get { return new MarketPlace("A2VIGQ35RCS4UG", Region.Europe, Country.AE, BaseCurrencyCode.AED); } } - public static MarketPlace India { get { return new MarketPlace("A21TJRUUN4KGV", Region.Europe, Country.IN, BaseCurrencyCode.INR); } } - public static MarketPlace SaudiArabia { get { return new MarketPlace("A17E79C6D8DWNP", Region.Europe, Country.SA, BaseCurrencyCode.SAR); } } - public static MarketPlace SouthAfrica { get { return new MarketPlace("AE08WJ6YKNBMC", Region.Europe, Country.ZA, BaseCurrencyCode.ZAR); } } - public static MarketPlace Ireland { get { return new MarketPlace("A28R8C7NBKEWEA", Region.Europe, Country.IE, BaseCurrencyCode.EUR); } } + public static readonly MarketPlace Spain = new MarketPlace("A1RKKUPIHCS9HS", Region.Europe, Country.ES, BaseCurrencyCode.EUR); + public static readonly MarketPlace UnitedKingdom = new MarketPlace("A1F83G8C2ARO7P", Region.Europe, Country.GB, BaseCurrencyCode.GBP); + public static readonly MarketPlace France = new MarketPlace("A13V1IB3VIYZZH", Region.Europe, Country.FR, BaseCurrencyCode.EUR); + public static readonly MarketPlace Belgium = new MarketPlace("AMEN7PMS3EDWL", Region.Europe, Country.BE, BaseCurrencyCode.EUR); + public static readonly MarketPlace Netherlands = new MarketPlace("A1805IZSGTT6HS", Region.Europe, Country.NL, BaseCurrencyCode.EUR); + public static readonly MarketPlace Germany = new MarketPlace("A1PA6795UKMFR9", Region.Europe, Country.DE, BaseCurrencyCode.EUR); + public static readonly MarketPlace Italy = new MarketPlace("APJ6JRA9NG5V4", Region.Europe, Country.IT, BaseCurrencyCode.EUR); + public static readonly MarketPlace Sweden = new MarketPlace("A2NODRKZP88ZB9", Region.Europe, Country.SE, BaseCurrencyCode.SEK); + public static readonly MarketPlace Egypt = new MarketPlace("ARBP9OOSHTCHU", Region.Europe, Country.EG, BaseCurrencyCode.EGP); + public static readonly MarketPlace Poland = new MarketPlace("A1C3SOZRARQ6R3", Region.Europe, Country.PL, BaseCurrencyCode.PLN); + public static readonly MarketPlace Turkey = new MarketPlace("A33AVAJ2PDY3EV", Region.Europe, Country.TR, BaseCurrencyCode.TRY); + public static readonly MarketPlace UnitedArabEmirates = new MarketPlace("A2VIGQ35RCS4UG", Region.Europe, Country.AE, BaseCurrencyCode.AED); + public static readonly MarketPlace India = new MarketPlace("A21TJRUUN4KGV", Region.Europe, Country.IN, BaseCurrencyCode.INR); + public static readonly MarketPlace SaudiArabia = new MarketPlace("A17E79C6D8DWNP", Region.Europe, Country.SA, BaseCurrencyCode.SAR); + public static readonly MarketPlace SouthAfrica = new MarketPlace("AE08WJ6YKNBMC", Region.Europe, Country.ZA, BaseCurrencyCode.ZAR); + public static readonly MarketPlace Ireland = new MarketPlace("A28R8C7NBKEWEA", Region.Europe, Country.IE, BaseCurrencyCode.EUR); - - //FarEast - public static MarketPlace Singapore { get { return new MarketPlace("A19VAU5U5O7RUS", Region.FarEast, Country.SG, BaseCurrencyCode.SGD); } } - public static MarketPlace Australia { get { return new MarketPlace("A39IBJ37TRP1C6", Region.FarEast, Country.AU, BaseCurrencyCode.AUD); } } - public static MarketPlace Japan { get { return new MarketPlace("A1VC38T7YXB528", Region.FarEast, Country.JP, BaseCurrencyCode.JPY); } } + //FarEast + public static readonly MarketPlace Singapore = new MarketPlace("A19VAU5U5O7RUS", Region.FarEast, Country.SG, BaseCurrencyCode.SGD); + public static readonly MarketPlace Australia = new MarketPlace("A39IBJ37TRP1C6", Region.FarEast, Country.AU, BaseCurrencyCode.AUD); + public static readonly MarketPlace Japan = new MarketPlace("A1VC38T7YXB528", Region.FarEast, Country.JP, BaseCurrencyCode.JPY); } } diff --git a/Source/FikaAmazonAPI/Utils/Region.cs b/Source/FikaAmazonAPI/Utils/Region.cs index 2e28af2f..de38810b 100644 --- a/Source/FikaAmazonAPI/Utils/Region.cs +++ b/Source/FikaAmazonAPI/Utils/Region.cs @@ -18,8 +18,8 @@ private Region(string regionName, string hostUrl, string sandboxHostUrl) public string SandboxHostUrl { get; set; } - public static Region NorthAmerica { get { return new Region("us-east-1", "https://sellingpartnerapi-na.amazon.com", "https://sandbox.sellingpartnerapi-na.amazon.com"); } } - public static Region Europe { get { return new Region("eu-west-1", "https://sellingpartnerapi-eu.amazon.com", "https://sandbox.sellingpartnerapi-eu.amazon.com"); } } - public static Region FarEast { get { return new Region("us-west-2", "https://sellingpartnerapi-fe.amazon.com", "https://sandbox.sellingpartnerapi-fe.amazon.com"); } } + public static readonly Region NorthAmerica = new Region("us-east-1", "https://sellingpartnerapi-na.amazon.com", "https://sandbox.sellingpartnerapi-na.amazon.com"); + public static readonly Region Europe = new Region("eu-west-1", "https://sellingpartnerapi-eu.amazon.com", "https://sandbox.sellingpartnerapi-eu.amazon.com"); + public static readonly Region FarEast = new Region("us-west-2", "https://sellingpartnerapi-fe.amazon.com", "https://sandbox.sellingpartnerapi-fe.amazon.com"); } }