Module: Peddler

Defined in:
lib/peddler/api.rb,
lib/peddler/error.rb,
lib/peddler/token.rb,
lib/peddler/version.rb,
lib/peddler/endpoint.rb,
lib/peddler/marketplace.rb,
lib/peddler/api/sales_v1.rb,
lib/peddler/api/orders_v0.rb,
lib/peddler/api/sellers_v1.rb,
lib/peddler/api/finances_v0.rb,
lib/peddler/api/services_v1.rb,
lib/peddler/api/shipping_v1.rb,
lib/peddler/api/shipping_v2.rb,
lib/peddler/api/messaging_v1.rb,
lib/peddler/api/product_fees_v0.rb,
lib/peddler/api/catalog_items_v0.rb,
lib/peddler/api/fba_inventory_v1.rb,
lib/peddler/api/feeds_2021_06_30.rb,
lib/peddler/api/notifications_v1.rb,
lib/peddler/api/solicitations_v1.rb,
lib/peddler/api/vendor_orders_v1.rb,
lib/peddler/api/tokens_2021_03_01.rb,
lib/peddler/api/product_pricing_v0.rb,
lib/peddler/api/reports_2021_06_30.rb,
lib/peddler/api/uploads_2020_11_01.rb,
lib/peddler/api/vendor_invoices_v1.rb,
lib/peddler/api/finances_2024_06_19.rb,
lib/peddler/api/invoices_2024_06_19.rb,
lib/peddler/api/vendor_shipments_v1.rb,
lib/peddler/api/easy_ship_2022_03_23.rb,
lib/peddler/api/data_kiosk_2023_11_15.rb,
lib/peddler/api/shipment_invoicing_v0.rb,
lib/peddler/api/fulfillment_inbound_v0.rb,
lib/peddler/api/merchant_fulfillment_v0.rb,
lib/peddler/api/aplus_content_2020_11_01.rb,
lib/peddler/api/catalog_items_2020_12_01.rb,
lib/peddler/api/catalog_items_2022_04_01.rb,
lib/peddler/api/replenishment_2022_11_07.rb,
lib/peddler/api/listings_items_2020_09_01.rb,
lib/peddler/api/listings_items_2021_08_01.rb,
lib/peddler/api/supply_sources_2020_07_01.rb,
lib/peddler/api/fba_inbound_eligibility_v1.rb,
lib/peddler/api/product_pricing_2022_05_01.rb,
lib/peddler/api/vendor_transaction_status_v1.rb,
lib/peddler/api/fulfillment_inbound_2024_03_20.rb,
lib/peddler/api/fulfillment_outbound_2020_07_01.rb,
lib/peddler/api/listings_restrictions_2021_08_01.rb,
lib/peddler/api/application_management_2023_11_30.rb,
lib/peddler/api/application_integrations_2024_04_01.rb,
lib/peddler/api/product_type_definitions_2020_09_01.rb,
lib/peddler/api/vendor_direct_fulfillment_orders_v1.rb,
lib/peddler/api/vendor_direct_fulfillment_payments_v1.rb,
lib/peddler/api/vendor_direct_fulfillment_shipping_v1.rb,
lib/peddler/api/vendor_direct_fulfillment_inventory_v1.rb,
lib/peddler/api/vendor_direct_fulfillment_transactions_v1.rb,
lib/peddler/api/vendor_direct_fulfillment_orders_2021_12_28.rb,
lib/peddler/api/vendor_direct_fulfillment_shipping_2021_12_28.rb,
lib/peddler/api/amazon_warehousing_and_distribution_2024_05_09.rb,
lib/peddler/api/vendor_direct_fulfillment_transactions_2021_12_28.rb,
lib/peddler/api/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb

Defined Under Namespace

Classes: API, Error, Token

Constant Summary collapse

VERSION =
"3.0.0"
ENDPOINTS =
{
  "us-east-1" => {
    selling_region: "North America",
    host: "sellingpartnerapi-na.amazon.com",
  },
  "us-west-2" => {
    selling_region: "Far East",
    host: "sellingpartnerapi-fe.amazon.com",
  },
  "eu-west-1" => {
    selling_region: "Europe",
    host: "sellingpartnerapi-eu.amazon.com",
  },
}
Endpoint =
Data.define(:aws_region, :selling_region, :host) do
  class << self
    # @param [String] aws_region
    def find(aws_region)
      values = ENDPOINTS.fetch(aws_region) do
        raise ArgumentError, "#{aws_region} not found"
      end

      new(**values.merge(aws_region: aws_region))
    end

    def find_by_selling_region(selling_region)
      aws_region, values = ENDPOINTS.find { |_, v| v[:selling_region] == selling_region } ||
        raise(ArgumentError, "#{selling_region} not found")

      new(**values.merge(aws_region: aws_region))
    end
  end

  # @return [URI]
  def production
    URI::HTTPS.build(host: host)
  end

  # @return [URI]
  def sandbox
    URI::HTTPS.build(host: "sandbox.#{host}")
  end
end
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 == "GB" ? "UK" : country_code) do
        raise ArgumentError, "#{country_code} not found"
      end

      new(**values.merge(country_code: country_code))
    end

    # @param [String] country_code
    # @return [String]
    def id(country_code)
      find(country_code).id
    end

    # @param [Array<String>] country_codes
    # @return [Array<String>]
    def ids(*country_codes)
      country_codes.map { |country_code| id(country_code) }
    end
  end

  # @return [Peddler::Endpoint]
  def endpoint
    Endpoint.find_by_selling_region(selling_region)
  end

  # @note So HTTP can encode
  # @return [String]
  def to_str
    id
  end
end

Class Method Summary collapse

Class Method Details

.amazon_warehousing_and_distribution_2024_05_09Object



8
9
10
# File 'lib/peddler/api/amazon_warehousing_and_distribution_2024_05_09.rb', line 8

def amazon_warehousing_and_distribution_2024_05_09(...)
  API::AmazonWarehousingAndDistribution20240509.new(...)
end

.aplus_content_2020_11_01Object



8
9
10
# File 'lib/peddler/api/aplus_content_2020_11_01.rb', line 8

def aplus_content_2020_11_01(...)
  API::AplusContent20201101.new(...)
end

.application_integrations_2024_04_01Object



8
9
10
# File 'lib/peddler/api/application_integrations_2024_04_01.rb', line 8

def application_integrations_2024_04_01(...)
  API::ApplicationIntegrations20240401.new(...)
end

.application_management_2023_11_30Object



8
9
10
# File 'lib/peddler/api/application_management_2023_11_30.rb', line 8

def application_management_2023_11_30(...)
  API::ApplicationManagement20231130.new(...)
end

.catalog_items_2020_12_01Object



8
9
10
# File 'lib/peddler/api/catalog_items_2020_12_01.rb', line 8

def catalog_items_2020_12_01(...)
  API::CatalogItems20201201.new(...)
end

.catalog_items_2022_04_01Object



8
9
10
# File 'lib/peddler/api/catalog_items_2022_04_01.rb', line 8

def catalog_items_2022_04_01(...)
  API::CatalogItems20220401.new(...)
end

.catalog_items_v0Object



8
9
10
# File 'lib/peddler/api/catalog_items_v0.rb', line 8

def catalog_items_v0(...)
  API::CatalogItemsV0.new(...)
end

.data_kiosk_2023_11_15Object



8
9
10
# File 'lib/peddler/api/data_kiosk_2023_11_15.rb', line 8

def data_kiosk_2023_11_15(...)
  API::DataKiosk20231115.new(...)
end

.easy_ship_2022_03_23Object



8
9
10
# File 'lib/peddler/api/easy_ship_2022_03_23.rb', line 8

def easy_ship_2022_03_23(...)
  API::EasyShip20220323.new(...)
end

.fba_inbound_eligibility_v1Object



8
9
10
# File 'lib/peddler/api/fba_inbound_eligibility_v1.rb', line 8

def fba_inbound_eligibility_v1(...)
  API::FBAInboundEligibilityV1.new(...)
end

.fba_inventory_v1Object



8
9
10
# File 'lib/peddler/api/fba_inventory_v1.rb', line 8

def fba_inventory_v1(...)
  API::FBAInventoryV1.new(...)
end

.feeds_2021_06_30Object



8
9
10
# File 'lib/peddler/api/feeds_2021_06_30.rb', line 8

def feeds_2021_06_30(...)
  API::Feeds20210630.new(...)
end

.finances_2024_06_19Object



8
9
10
# File 'lib/peddler/api/finances_2024_06_19.rb', line 8

def finances_2024_06_19(...)
  API::Finances20240619.new(...)
end

.finances_v0Object



8
9
10
# File 'lib/peddler/api/finances_v0.rb', line 8

def finances_v0(...)
  API::FinancesV0.new(...)
end

.fulfillment_inbound_2024_03_20Object



8
9
10
# File 'lib/peddler/api/fulfillment_inbound_2024_03_20.rb', line 8

def fulfillment_inbound_2024_03_20(...)
  API::FulfillmentInbound20240320.new(...)
end

.fulfillment_inbound_v0Object



8
9
10
# File 'lib/peddler/api/fulfillment_inbound_v0.rb', line 8

def fulfillment_inbound_v0(...)
  API::FulfillmentInboundV0.new(...)
end

.fulfillment_outbound_2020_07_01Object



8
9
10
# File 'lib/peddler/api/fulfillment_outbound_2020_07_01.rb', line 8

def fulfillment_outbound_2020_07_01(...)
  API::FulfillmentOutbound20200701.new(...)
end

.invoices_2024_06_19Object



8
9
10
# File 'lib/peddler/api/invoices_2024_06_19.rb', line 8

def invoices_2024_06_19(...)
  API::Invoices20240619.new(...)
end

.listings_items_2020_09_01Object



8
9
10
# File 'lib/peddler/api/listings_items_2020_09_01.rb', line 8

def listings_items_2020_09_01(...)
  API::ListingsItems20200901.new(...)
end

.listings_items_2021_08_01Object



8
9
10
# File 'lib/peddler/api/listings_items_2021_08_01.rb', line 8

def listings_items_2021_08_01(...)
  API::ListingsItems20210801.new(...)
end

.listings_restrictions_2021_08_01Object



8
9
10
# File 'lib/peddler/api/listings_restrictions_2021_08_01.rb', line 8

def listings_restrictions_2021_08_01(...)
  API::ListingsRestrictions20210801.new(...)
end

.merchant_fulfillment_v0Object



8
9
10
# File 'lib/peddler/api/merchant_fulfillment_v0.rb', line 8

def merchant_fulfillment_v0(...)
  API::MerchantFulfillmentV0.new(...)
end

.messaging_v1Object



8
9
10
# File 'lib/peddler/api/messaging_v1.rb', line 8

def messaging_v1(...)
  API::MessagingV1.new(...)
end

.notifications_v1Object



8
9
10
# File 'lib/peddler/api/notifications_v1.rb', line 8

def notifications_v1(...)
  API::NotificationsV1.new(...)
end

.orders_v0Object



8
9
10
# File 'lib/peddler/api/orders_v0.rb', line 8

def orders_v0(...)
  API::OrdersV0.new(...)
end

.product_fees_v0Object



8
9
10
# File 'lib/peddler/api/product_fees_v0.rb', line 8

def product_fees_v0(...)
  API::ProductFeesV0.new(...)
end

.product_pricing_2022_05_01Object



8
9
10
# File 'lib/peddler/api/product_pricing_2022_05_01.rb', line 8

def product_pricing_2022_05_01(...)
  API::ProductPricing20220501.new(...)
end

.product_pricing_v0Object



8
9
10
# File 'lib/peddler/api/product_pricing_v0.rb', line 8

def product_pricing_v0(...)
  API::ProductPricingV0.new(...)
end

.product_type_definitions_2020_09_01Object



8
9
10
# File 'lib/peddler/api/product_type_definitions_2020_09_01.rb', line 8

def product_type_definitions_2020_09_01(...)
  API::ProductTypeDefinitions20200901.new(...)
end

.replenishment_2022_11_07Object



8
9
10
# File 'lib/peddler/api/replenishment_2022_11_07.rb', line 8

def replenishment_2022_11_07(...)
  API::Replenishment20221107.new(...)
end

.reports_2021_06_30Object



8
9
10
# File 'lib/peddler/api/reports_2021_06_30.rb', line 8

def reports_2021_06_30(...)
  API::Reports20210630.new(...)
end

.sales_v1Object



8
9
10
# File 'lib/peddler/api/sales_v1.rb', line 8

def sales_v1(...)
  API::SalesV1.new(...)
end

.sellers_v1Object



8
9
10
# File 'lib/peddler/api/sellers_v1.rb', line 8

def sellers_v1(...)
  API::SellersV1.new(...)
end

.services_v1Object



8
9
10
# File 'lib/peddler/api/services_v1.rb', line 8

def services_v1(...)
  API::ServicesV1.new(...)
end

.shipment_invoicing_v0Object



8
9
10
# File 'lib/peddler/api/shipment_invoicing_v0.rb', line 8

def shipment_invoicing_v0(...)
  API::ShipmentInvoicingV0.new(...)
end

.shipping_v1Object



8
9
10
# File 'lib/peddler/api/shipping_v1.rb', line 8

def shipping_v1(...)
  API::ShippingV1.new(...)
end

.shipping_v2Object



8
9
10
# File 'lib/peddler/api/shipping_v2.rb', line 8

def shipping_v2(...)
  API::ShippingV2.new(...)
end

.solicitations_v1Object



8
9
10
# File 'lib/peddler/api/solicitations_v1.rb', line 8

def solicitations_v1(...)
  API::SolicitationsV1.new(...)
end

.supply_sources_2020_07_01Object



8
9
10
# File 'lib/peddler/api/supply_sources_2020_07_01.rb', line 8

def supply_sources_2020_07_01(...)
  API::SupplySources20200701.new(...)
end

.tokens_2021_03_01Object



8
9
10
# File 'lib/peddler/api/tokens_2021_03_01.rb', line 8

def tokens_2021_03_01(...)
  API::Tokens20210301.new(...)
end

.uploads_2020_11_01Object



8
9
10
# File 'lib/peddler/api/uploads_2020_11_01.rb', line 8

def uploads_2020_11_01(...)
  API::Uploads20201101.new(...)
end

.vendor_direct_fulfillment_inventory_v1Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_inventory_v1.rb', line 8

def vendor_direct_fulfillment_inventory_v1(...)
  API::VendorDirectFulfillmentInventoryV1.new(...)
end

.vendor_direct_fulfillment_orders_2021_12_28Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_orders_2021_12_28.rb', line 8

def vendor_direct_fulfillment_orders_2021_12_28(...)
  API::VendorDirectFulfillmentOrders20211228.new(...)
end

.vendor_direct_fulfillment_orders_v1Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_orders_v1.rb', line 8

def vendor_direct_fulfillment_orders_v1(...)
  API::VendorDirectFulfillmentOrdersV1.new(...)
end

.vendor_direct_fulfillment_payments_v1Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_payments_v1.rb', line 8

def vendor_direct_fulfillment_payments_v1(...)
  API::VendorDirectFulfillmentPaymentsV1.new(...)
end

.vendor_direct_fulfillment_sandbox_test_data_2021_10_28Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb', line 8

def vendor_direct_fulfillment_sandbox_test_data_2021_10_28(...)
  API::VendorDirectFulfillmentSandboxTestData20211028.new(...)
end

.vendor_direct_fulfillment_shipping_2021_12_28Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_shipping_2021_12_28.rb', line 8

def vendor_direct_fulfillment_shipping_2021_12_28(...)
  API::VendorDirectFulfillmentShipping20211228.new(...)
end

.vendor_direct_fulfillment_shipping_v1Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_shipping_v1.rb', line 8

def vendor_direct_fulfillment_shipping_v1(...)
  API::VendorDirectFulfillmentShippingV1.new(...)
end

.vendor_direct_fulfillment_transactions_2021_12_28Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_transactions_2021_12_28.rb', line 8

def vendor_direct_fulfillment_transactions_2021_12_28(...)
  API::VendorDirectFulfillmentTransactions20211228.new(...)
end

.vendor_direct_fulfillment_transactions_v1Object



8
9
10
# File 'lib/peddler/api/vendor_direct_fulfillment_transactions_v1.rb', line 8

def vendor_direct_fulfillment_transactions_v1(...)
  API::VendorDirectFulfillmentTransactionsV1.new(...)
end

.vendor_invoices_v1Object



8
9
10
# File 'lib/peddler/api/vendor_invoices_v1.rb', line 8

def vendor_invoices_v1(...)
  API::VendorInvoicesV1.new(...)
end

.vendor_orders_v1Object



8
9
10
# File 'lib/peddler/api/vendor_orders_v1.rb', line 8

def vendor_orders_v1(...)
  API::VendorOrdersV1.new(...)
end

.vendor_shipments_v1Object



8
9
10
# File 'lib/peddler/api/vendor_shipments_v1.rb', line 8

def vendor_shipments_v1(...)
  API::VendorShipmentsV1.new(...)
end

.vendor_transaction_status_v1Object



8
9
10
# File 'lib/peddler/api/vendor_transaction_status_v1.rb', line 8

def vendor_transaction_status_v1(...)
  API::VendorTransactionStatusV1.new(...)
end