Class: Mws::Apis::Feeds::Api
- Inherits:
-
Object
- Object
- Mws::Apis::Feeds::Api
- Defined in:
- lib/mws/apis/feeds/api.rb
Instance Attribute Summary collapse
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#inventory ⇒ Object
readonly
Returns the value of attribute inventory.
-
#prices ⇒ Object
readonly
Returns the value of attribute prices.
-
#products ⇒ Object
readonly
Returns the value of attribute products.
-
#shipping ⇒ Object
readonly
Returns the value of attribute shipping.
Instance Method Summary collapse
- #cancel(options = {}) ⇒ Object
- #count ⇒ Object
- #for(type) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(connection, defaults = {}) ⇒ Api
constructor
A new instance of Api.
- #list(params = {}) ⇒ Object
- #submit(body, params) ⇒ Object
Constructor Details
#initialize(connection, defaults = {}) ⇒ Api
Returns a new instance of Api.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mws/apis/feeds/api.rb', line 7 def initialize(connection, defaults={}) raise Mws::Errors::ValidationError, 'A connection is required.' if connection.nil? @connection = connection defaults[:version] ||= '2009-01-01' @defaults = defaults @products = self.for :product @images = self.for :image @prices = self.for :price @shipping = self.for :override @inventory = self.for :inventory end |
Instance Attribute Details
#images ⇒ Object (readonly)
Returns the value of attribute images.
5 6 7 |
# File 'lib/mws/apis/feeds/api.rb', line 5 def images @images end |
#inventory ⇒ Object (readonly)
Returns the value of attribute inventory.
5 6 7 |
# File 'lib/mws/apis/feeds/api.rb', line 5 def inventory @inventory end |
#prices ⇒ Object (readonly)
Returns the value of attribute prices.
5 6 7 |
# File 'lib/mws/apis/feeds/api.rb', line 5 def prices @prices end |
#products ⇒ Object (readonly)
Returns the value of attribute products.
5 6 7 |
# File 'lib/mws/apis/feeds/api.rb', line 5 def products @products end |
#shipping ⇒ Object (readonly)
Returns the value of attribute shipping.
5 6 7 |
# File 'lib/mws/apis/feeds/api.rb', line 5 def shipping @shipping end |
Instance Method Details
#cancel(options = {}) ⇒ Object
34 35 36 |
# File 'lib/mws/apis/feeds/api.rb', line 34 def cancel(={}) end |
#count ⇒ Object
46 47 48 |
# File 'lib/mws/apis/feeds/api.rb', line 46 def count() @connection.get('/', {}, @defaults.merge(action: 'GetFeedSubmissionCount')).xpath('Count').first.text.to_i end |
#for(type) ⇒ Object
50 51 52 |
# File 'lib/mws/apis/feeds/api.rb', line 50 def for(type) TargetedApi.new self, @connection.merchant, type end |
#get(id) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/mws/apis/feeds/api.rb', line 20 def get(id) node = @connection.get '/', { feed_submission_id: id }, @defaults.merge( action: 'GetFeedSubmissionResult', xpath: 'AmazonEnvelope/Message' ) SubmissionResult.from_xml node end |
#list(params = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/mws/apis/feeds/api.rb', line 38 def list(params={}) params[:feed_submission_id] ||= params.delete(:ids) || [ params.delete(:id) ].flatten.compact doc = @connection.get('/', params, @defaults.merge(action: 'GetFeedSubmissionList')) doc.xpath('FeedSubmissionInfo').map do | node | SubmissionInfo.from_xml node end end |
#submit(body, params) ⇒ Object
28 29 30 31 32 |
# File 'lib/mws/apis/feeds/api.rb', line 28 def submit(body, params) params[:feed_type] = Feed::Type.for(params[:feed_type]).val doc = @connection.post '/', params, body, @defaults.merge(action: 'SubmitFeed') SubmissionInfo.from_xml doc.xpath('FeedSubmissionInfo').first end |