Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions Source/FikaAmazonAPI/Utils/MarketPlace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,6 @@ private MarketPlace(string id, Region region, Country country, BaseCurrencyCode

[JsonConstructorAttribute]
public MarketPlace() { }

private static readonly List<MarketPlace> _allMarketplaces = new List<MarketPlace>()
{
// 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 marketpalce = _allMarketplaces.FirstOrDefault(a => a.ID == id);
if (marketpalce == null)
throw new AmazonInvalidInputException($"InvalidInput, MarketPlace or MarketPlaceID cannot be null for both!");

return marketpalce;
}

public static MarketPlace GetMarketplaceByCountryCode(string countryCode)
{
return _allMarketplaces.FirstOrDefault(a => a.Country.Code == countryCode);
}

//https://developer-docs.amazon.com/sp-api/docs/marketplace-ids

Expand Down Expand Up @@ -84,5 +57,32 @@ public static MarketPlace GetMarketplaceByCountryCode(string countryCode)
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);

private static readonly List<MarketPlace> _allMarketplaces = new List<MarketPlace>()
{
// 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 marketpalce = _allMarketplaces.FirstOrDefault(a => a.ID == id);
if (marketpalce == null)
throw new AmazonInvalidInputException($"InvalidInput, MarketPlace or MarketPlaceID cannot be null for both!");

return marketpalce;
}

public static MarketPlace GetMarketplaceByCountryCode(string countryCode)
{
return _allMarketplaces.FirstOrDefault(a => a.Country.Code == countryCode);
}
}
}
Loading