# frozen_string_literal: true require "peddler/endpoint" module Peddler # @see https://developer-docs.amazon.com/sp-api/docs/marketplace-ids MARKETPLACE_IDS = { "CA" => { id: "A2EUQ1WTGCTBG2", country_name: "Canada", selling_region: "North America" }, "US" => { id: "ATVPDKIKX0DER", country_name: "United States", selling_region: "North America" }, "MX" => { id: "A1AM78C64UM0Y8", country_name: "Mexico", selling_region: "North America" }, "BR" => { id: "A2Q3Y263D00KWC", country_name: "Brazil", selling_region: "North America" }, "ES" => { id: "A1RKKUPIHCS9HS", country_name: "Spain", selling_region: "Europe" }, "UK" => { id: "A1F83G8C2ARO7P", country_name: "United Kingdom", selling_region: "Europe" }, "FR" => { id: "A13V1IB3VIYZZH", country_name: "France", selling_region: "Europe" }, "BE" => { id: "AMEN7PMS3EDWL", country_name: "Belgium", selling_region: "Europe" }, "NL" => { id: "A1805IZSGTT6HS", country_name: "Netherlands", selling_region: "Europe" }, "DE" => { id: "A1PA6795UKMFR9", country_name: "Germany", selling_region: "Europe" }, "IT" => { id: "APJ6JRA9NG5V4", country_name: "Italy", selling_region: "Europe" }, "SE" => { id: "A2NODRKZP88ZB9", country_name: "Sweden", selling_region: "Europe" }, "ZA" => { id: "AE08WJ6YKNBMC", country_name: "South Africa", selling_region: "Europe" }, "PL" => { id: "A1C3SOZRARQ6R3", country_name: "Poland", selling_region: "Europe" }, "EG" => { id: "ARBP9OOSHTCHU", country_name: "Egypt", selling_region: "Europe" }, "TR" => { id: "A33AVAJ2PDY3EV", country_name: "Turkey", selling_region: "Europe" }, "SA" => { id: "A17E79C6D8DWNP", country_name: "Saudi Arabia", selling_region: "Europe" }, "AE" => { id: "A2VIGQ35RCS4UG", country_name: "United Arab Emirates", selling_region: "Europe" }, "IN" => { id: "A21TJRUUN4KGV", country_name: "India", selling_region: "Europe" }, "SG" => { id: "A19VAU5U5O7RUS", country_name: "Singapore", selling_region: "Far East" }, "AU" => { id: "A39IBJ37TRP1C6", country_name: "Australia", selling_region: "Far East" }, "JP" => { id: "A1VC38T7YXB528", country_name: "Japan", selling_region: "Far East" }, } Marketplace = Data.define(:id, :country_code, :country_name, :selling_region) do class << self # @param [String] country_code def find(country_code) values = MARKETPLACE_IDS.fetch(country_code) do raise ArgumentError, "#{country_code} not found" end new(**values.merge(country_code: country_code)) end end # @return [Peddler::Endpoint] def endpoint Endpoint.find_by_selling_region(selling_region) end end end