Class: Peddler::Client
- Inherits:
-
Object
- Object
- Peddler::Client
- Extended by:
- Forwardable
- Includes:
- Jeff
- Defined in:
- lib/peddler/client.rb
Overview
An abstract client
Subclass this to implement an MWS API section.
Direct Known Subclasses
MWS::Feeds::Client, MWS::Finances::Client, MWS::FulfillmentInboundShipment::Client, MWS::FulfillmentInventory::Client, MWS::FulfillmentOutboundShipment::Client, MWS::MerchantFulfillment::Client, MWS::OffAmazonPayments::Client, MWS::Orders::Client, MWS::Products::Client, MWS::Recommendations::Client, MWS::Reports::Client, MWS::Sellers::Client, MWS::Subscriptions::Client
Class Attribute Summary collapse
- .parser ⇒ Object private
- .path ⇒ Object private
- .version ⇒ Object private
Instance Attribute Summary collapse
-
#auth_token ⇒ String
The MWS Auth Token for a seller’s account.
-
#body ⇒ String
The body of the HTTP request.
-
#marketplace ⇒ Peddler::Marketplace
The marketplace where you signed up as application developer.
-
#merchant_id ⇒ String
The seller’s Merchant ID.
- #path ⇒ Object private
Instance Method Summary collapse
- #aws_endpoint ⇒ Object private
- #defaults ⇒ Object private
- #headers ⇒ Object private
-
#initialize(opts = {}) ⇒ Client
constructor
Creates a new client.
- #operation(action = nil) ⇒ Object private
- #run ⇒ Object private
Constructor Details
#initialize(opts = {}) ⇒ Client
Creates a new client
45 46 47 |
# File 'lib/peddler/client.rb', line 45 def initialize(opts = {}) opts.each { |k, v| send("#{k}=", v) } end |
Class Attribute Details
.parser ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/peddler/client.rb', line 20 def parser @parser end |
.path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/peddler/client.rb', line 20 def path @path end |
.version ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/peddler/client.rb', line 20 def version @version end |
Instance Attribute Details
#auth_token ⇒ String
You can omit this if you are accessing your own seller account
The MWS Auth Token for a seller’s account
52 53 54 |
# File 'lib/peddler/client.rb', line 52 def auth_token @auth_token end |
#body ⇒ String
The body of the HTTP request
76 77 78 |
# File 'lib/peddler/client.rb', line 76 def body @body end |
#marketplace ⇒ Peddler::Marketplace
You can pass the two-letter country code of the marketplace as shorthand when setting
The marketplace where you signed up as application developer
62 63 64 |
# File 'lib/peddler/client.rb', line 62 def marketplace @marketplace end |
#merchant_id ⇒ String
The seller’s Merchant ID
56 57 58 |
# File 'lib/peddler/client.rb', line 56 def merchant_id @merchant_id end |
#path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 |
# File 'lib/peddler/client.rb', line 87 def path @path ||= self.class.path end |
Instance Method Details
#aws_endpoint ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
102 103 104 |
# File 'lib/peddler/client.rb', line 102 def aws_endpoint "https://#{host}#{path}" end |
#defaults ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 |
# File 'lib/peddler/client.rb', line 92 def defaults @defaults ||= { expects: 200 } end |
#headers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
97 98 99 |
# File 'lib/peddler/client.rb', line 97 def headers @headers ||= {} end |
#operation(action = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 |
# File 'lib/peddler/client.rb', line 107 def operation(action = nil) action ? @operation = Operation.new(action) : @operation end |
#run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/peddler/client.rb', line 112 def run opts = opts.store(:response_block, Proc.new) if block_given? res = post(opts) self.body = nil if res.status == 200 parser.new(res, encoding) rescue ::Excon::Error::HTTPStatus => error handle_http_status_error(error) end |