Class: Peddler::Endpoint

Inherits:
Data
  • Object
show all
Defined in:
lib/peddler/endpoint.rb

Constant Summary collapse

REGIONS =
{ # steep:ignore
  "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",
  },
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aws_regionObject (readonly)

Returns the value of attribute aws_region

Returns:

  • (Object)

    the current value of aws_region



6
7
8
# File 'lib/peddler/endpoint.rb', line 6

def aws_region
  @aws_region
end

#hostObject (readonly)

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



6
7
8
# File 'lib/peddler/endpoint.rb', line 6

def host
  @host
end

#selling_regionObject (readonly)

Returns the value of attribute selling_region

Returns:

  • (Object)

    the current value of selling_region



6
7
8
# File 'lib/peddler/endpoint.rb', line 6

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) } # steep:ignore
end

.find(aws_region) ⇒ Object

Parameters:

  • aws_region (String)


30
31
32
33
34
35
36
# File 'lib/peddler/endpoint.rb', line 30

def find(aws_region)
  values = REGIONS.fetch(aws_region) do # steep:ignore
    raise ArgumentError, "#{aws_region} not found"
  end

  new(**values, aws_region: aws_region)
end

.find_by_selling_region(selling_region) ⇒ Object

Parameters:

  • selling_region (String)


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 } || # steep:ignore
    raise(ArgumentError, "#{selling_region} not found")

  new(**values, aws_region: aws_region)
end

Instance Method Details

#productionURI

steep:ignore:start

Returns:

  • (URI)


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

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

#sandboxURI

Returns:

  • (URI)


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

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