Class: Peddler::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/peddler/endpoint.rb,
sig/peddler/endpoint.rbs

Constant Summary collapse

REGIONS =

Returns:

  • (Hash[String, Hash[Symbol, String]])

See Also:

{
  "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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aws_regionString (readonly)

Returns the value of attribute aws_region.

Returns:

  • (String)


10
11
12
# File 'sig/peddler/endpoint.rbs', line 10

def aws_region
  @aws_region
end

#hostString (readonly)

Returns the value of attribute host.

Returns:

  • (String)


12
13
14
# File 'sig/peddler/endpoint.rbs', line 12

def host
  @host
end

#selling_regionString (readonly)

Returns the value of attribute selling_region.

Returns:

  • (String)


13
14
15
# File 'sig/peddler/endpoint.rbs', line 13

def selling_region
  @selling_region
end

Class Method Details

.allArray<Endpoint>

Returns:



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

Parameters:

  • aws_region (String)

Returns:



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

Parameters:

  • selling_region (String)

Returns:



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

.new(aws_region:, selling_region:, host:) ⇒ Endpoint .new(arg0) ⇒ Endpoint

Overloads:

  • .new(aws_region:, selling_region:, host:) ⇒ Endpoint

    Parameters:

    • aws_region: (String)
    • selling_region: (String)
    • host: (String)

    Returns:

  • .new(arg0) ⇒ Endpoint

    Parameters:

    • arg0 (String)

    Returns:



5
6
# File 'sig/peddler/endpoint.rbs', line 5

def self.new: (aws_region: String, selling_region: String, host: String) -> Endpoint
| (**String) -> Endpoint

Instance Method Details

#productionURI

Returns:

  • (URI)


48
49
50
# File 'lib/peddler/endpoint.rb', line 48

def production
  URI::HTTPS.build(host: host)
end

#sandboxURI

Returns:

  • (URI)


53
54
55
# File 'lib/peddler/endpoint.rb', line 53

def sandbox
  URI::HTTPS.build(host: "sandbox.#{host}")
end