Sha256: 95e35b105a746cffa2e14e44d4f8ca4976ff14c016dfd0e3a08039d48c5946ec
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true require "uri" module Peddler # @see https://developer-docs.amazon.com/sp-api/docs/sp-api-endpoints 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, 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, 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 end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
peddler-4.1.1 | lib/peddler/endpoint.rb |
peddler-4.1.0 | lib/peddler/endpoint.rb |
peddler-4.0.1 | lib/peddler/endpoint.rb |
peddler-4.0.0 | lib/peddler/endpoint.rb |