Class: Paapi::Client
- Inherits:
-
Object
- Object
- Paapi::Client
- Defined in:
- lib/paapi/client.rb
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
Returns the value of attribute access_key.
-
#market ⇒ Object
Returns the value of attribute market.
-
#marketplace ⇒ Object
Returns the value of attribute marketplace.
-
#partner_tag ⇒ Object
Returns the value of attribute partner_tag.
-
#partner_type ⇒ Object
readonly
Returns the value of attribute partner_type.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
Instance Method Summary collapse
- #get_browse_nodes(browse_node_ids:, **options) ⇒ Object
- #get_items(item_ids:, **options) ⇒ Object
- #get_variations(asin:, **options) ⇒ Object
-
#initialize(access_key: Paapi.access_key, secret_key: Paapi.secret_key, partner_tag: Paapi.partner_tag, market: Paapi.market || DEFAULT_MARKET, resources: Paapi.resources || DEFAULT_RESOURCES, partner_type: DEFAULT_PARTNER_TYPE) ⇒ Client
constructor
A new instance of Client.
-
#search_items(keywords: nil, **options) ⇒ Object
TODO: Currently we assume Keywords, but we need one of the follow: [Keywords Actor Artist Author Brand Title ].
Constructor Details
#initialize(access_key: Paapi.access_key, secret_key: Paapi.secret_key, partner_tag: Paapi.partner_tag, market: Paapi.market || DEFAULT_MARKET, resources: Paapi.resources || DEFAULT_RESOURCES, partner_type: DEFAULT_PARTNER_TYPE) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/paapi/client.rb', line 10 def initialize(access_key: Paapi.access_key, secret_key: Paapi.secret_key, partner_tag: Paapi.partner_tag, market: Paapi.market || DEFAULT_MARKET, resources: Paapi.resources || DEFAULT_RESOURCES, partner_type: DEFAULT_PARTNER_TYPE ) raise ArgumentError unless MARKETPLACES.keys.include?(market.to_sym) @access_key = access_key @secret_key = secret_key @partner_type = partner_type @resources = resources unless resources.nil? self.market = market @partner_tag = partner_tag if !partner_tag.nil? end |
Instance Attribute Details
#access_key ⇒ Object (readonly)
Returns the value of attribute access_key.
8 9 10 |
# File 'lib/paapi/client.rb', line 8 def access_key @access_key end |
#market ⇒ Object
Returns the value of attribute market.
8 9 10 |
# File 'lib/paapi/client.rb', line 8 def market @market end |
#marketplace ⇒ Object
Returns the value of attribute marketplace.
7 8 9 |
# File 'lib/paapi/client.rb', line 7 def marketplace @marketplace end |
#partner_tag ⇒ Object
Returns the value of attribute partner_tag.
7 8 9 |
# File 'lib/paapi/client.rb', line 7 def partner_tag @partner_tag end |
#partner_type ⇒ Object (readonly)
Returns the value of attribute partner_type.
8 9 10 |
# File 'lib/paapi/client.rb', line 8 def partner_type @partner_type end |
#resources ⇒ Object
Returns the value of attribute resources.
7 8 9 |
# File 'lib/paapi/client.rb', line 7 def resources @resources end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
8 9 10 |
# File 'lib/paapi/client.rb', line 8 def secret_key @secret_key end |
Instance Method Details
#get_browse_nodes(browse_node_ids:, **options) ⇒ Object
57 58 59 60 |
# File 'lib/paapi/client.rb', line 57 def get_browse_nodes(browse_node_ids:, **) payload = { BrowseNodeIds: Array(browse_node_ids), Resources: @resources }.merge() request(op: :get_browse_nodes, payload: payload) end |
#get_items(item_ids:, **options) ⇒ Object
36 37 38 39 |
# File 'lib/paapi/client.rb', line 36 def get_items(item_ids:, **) payload = { ItemIds: Array(item_ids), Resources: @resources }.merge() request(op: :get_items, payload: payload) end |
#get_variations(asin:, **options) ⇒ Object
41 42 43 44 |
# File 'lib/paapi/client.rb', line 41 def get_variations(asin:, ** ) payload = { ASIN: asin, Resources: @resources }.merge() request(op: :get_variations, payload: payload) end |
#search_items(keywords: nil, **options) ⇒ Object
TODO: Currently we assume Keywords, but we need one of the follow: [Keywords Actor Artist Author Brand Title ]
47 48 49 50 51 52 53 54 55 |
# File 'lib/paapi/client.rb', line 47 def search_items(keywords: nil, ** ) raise ArgumentError("Missing keywords") unless (.keys | SEARCH_PARAMS).length.positive? search_index = .dig(:SearchIndex) ||'All' payload = { Keywords: keywords, Resources: @resources, ItemCount: 10, ItemPage: 1, SearchIndex: search_index }.merge() request(op: :search_items, payload: payload) end |