Class: Peddler::Client
Abstract
- Inherits:
-
Object
show all
- Includes:
- Jeff
- Defined in:
- lib/peddler/client.rb
Overview
This class is abstract.
Subclass to implement an MWS API section.
Direct Known Subclasses
MWS::CartInformation, MWS::CustomerInformation, MWS::Feeds, MWS::FulfillmentInboundShipment, MWS::FulfillmentInventory, MWS::FulfillmentOutboundShipment, MWS::OffAmazonPayments, MWS::Orders, MWS::Products, MWS::Recommendations, MWS::Reports, MWS::Sellers, MWS::Subscriptions
Constant Summary
collapse
- BadMarketplaceId =
Class.new(StandardError)
- HOSTS =
{
'A2EUQ1WTGCTBG2' => 'mws.amazonservices.ca',
'AAHKV2X7AFYLW' => 'mws.amazonservices.com.cn',
'A1PA6795UKMFR9' => 'mws-eu.amazonservices.com',
'A1RKKUPIHCS9HS' => 'mws-eu.amazonservices.com',
'A13V1IB3VIYZZH' => 'mws-eu.amazonservices.com',
'A1F83G8C2ARO7P' => 'mws-eu.amazonservices.com',
'A21TJRUUN4KGV' => 'mws.amazonservices.in',
'APJ6JRA9NG5V4' => 'mws-eu.amazonservices.com',
'A1VC38T7YXB528' => 'mws.amazonservices.jp',
'ATVPDKIKX0DER' => 'mws.amazonservices.com'
}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
26
27
28
|
# File 'lib/peddler/client.rb', line 26
def body
@body
end
|
#marketplace_id ⇒ Object
44
45
46
|
# File 'lib/peddler/client.rb', line 44
def marketplace_id
@marketplace_id ||= ENV['MWS_MARKETPLACE_ID']
end
|
#merchant_id ⇒ Object
48
49
50
|
# File 'lib/peddler/client.rb', line 48
def merchant_id
@merchant_id ||= ENV['MWS_MERCHANT_ID']
end
|
Class Method Details
.inherited(base) ⇒ Object
36
37
38
|
# File 'lib/peddler/client.rb', line 36
def self.inherited(base)
base.params(params)
end
|
.path(path = nil) ⇒ Object
32
33
34
|
# File 'lib/peddler/client.rb', line 32
def self.path(path = nil)
path ? @path = path : @path
end
|
Instance Method Details
#aws_endpoint ⇒ Object
40
41
42
|
# File 'lib/peddler/client.rb', line 40
def aws_endpoint
"https://#{host}/#{self.class.path}"
end
|
52
53
54
|
# File 'lib/peddler/client.rb', line 52
def
@headers ||= {}
end
|
#operation(action = nil) ⇒ Object
61
62
63
|
# File 'lib/peddler/client.rb', line 61
def operation(action = nil)
action ? @operation = Operation.new(action) : @operation
end
|
#run(parser = Parser, &blk) ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/peddler/client.rb', line 65
def run(parser = Parser, &blk)
opts = { query: operation, headers: , expects: 200 }
opts.store(:body, body) if body
opts.store(:response_block, blk) if block_given?
res = post(opts)
parser.parse(res)
end
|