Class: Peddler::Endpoint
- Inherits:
-
Object
- Object
- Peddler::Endpoint
- Defined in:
- lib/peddler/endpoint.rb,
sig/peddler/endpoint.rbs
Constant Summary collapse
- REGIONS =
{ "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", }, }.freeze
Instance Attribute Summary collapse
-
#aws_region ⇒ String
readonly
Returns the value of attribute aws_region.
-
#host ⇒ String
readonly
Returns the value of attribute host.
-
#selling_region ⇒ String
readonly
Returns the value of attribute selling_region.
Class Method Summary collapse
-
.all ⇒ Array<Endpoint>
-
.find(aws_region) ⇒ Endpoint
-
.find_by_selling_region(selling_region) ⇒ Endpoint
-
.new ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#aws_region ⇒ String (readonly)
Returns the value of attribute aws_region.
10 11 12 |
# File 'sig/peddler/endpoint.rbs', line 10 def aws_region @aws_region end |
#host ⇒ String (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'sig/peddler/endpoint.rbs', line 12 def host @host end |
#selling_region ⇒ String (readonly)
Returns the value of attribute selling_region.
13 14 15 |
# File 'sig/peddler/endpoint.rbs', line 13 def selling_region @selling_region end |
Class Method Details
.all ⇒ Array<Endpoint>
25 26 27 |
# File 'lib/peddler/endpoint.rb', line 25 def all REGIONS.map { |aws_region, values| new(**values, aws_region: aws_region) } end |
.find(aws_region) ⇒ Endpoint
30 31 32 33 34 35 36 |
# File 'lib/peddler/endpoint.rb', line 30 def find(aws_region) values = REGIONS.fetch(aws_region) do raise ArgumentError, "#{aws_region} not found" end new(**values, aws_region: aws_region) end |
.find_by_selling_region(selling_region) ⇒ Endpoint
39 40 41 42 43 44 |
# File 'lib/peddler/endpoint.rb', line 39 def find_by_selling_region(selling_region) aws_region, values = REGIONS.find { |_, v| v[:selling_region] == selling_region } || raise(ArgumentError, "#{selling_region} not found") new(**values, aws_region: aws_region) end |
Instance Method Details
#production ⇒ URI
48 49 50 |
# File 'lib/peddler/endpoint.rb', line 48 def production URI::HTTPS.build(host: host) end |
#sandbox ⇒ URI
53 54 55 |
# File 'lib/peddler/endpoint.rb', line 53 def sandbox URI::HTTPS.build(host: "sandbox.#{host}") end |