Class: Mws::Apis::Feeds::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/mws/apis/feeds/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#imagesObject (readonly)

Returns the value of attribute images.



5
6
7
# File 'lib/mws/apis/feeds/api.rb', line 5

def images
  @images
end

#inventoryObject (readonly)

Returns the value of attribute inventory.



5
6
7
# File 'lib/mws/apis/feeds/api.rb', line 5

def inventory
  @inventory
end

#pricesObject (readonly)

Returns the value of attribute prices.



5
6
7
# File 'lib/mws/apis/feeds/api.rb', line 5

def prices
  @prices
end

#productsObject (readonly)

Returns the value of attribute products.



5
6
7
# File 'lib/mws/apis/feeds/api.rb', line 5

def products
  @products
end

#shippingObject (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(options={})

end

#countObject



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