Unable to initialize ItemOffersRequest for a GetItemOffersBatchRequest
Closed this issue · 2 comments
Hello I am trying to initialize a GetItemOffersBatchRequest and having trouble figuring out how it is supposed to work. I'm wondering if this a potential bug or something I'm doing wrong.
Looking at the code I'm expecting this to work similar to how it works in this PHP example. jlevers/selling-partner-api#310
So here is my code
asin = 'some example asin'
options = {'uri' =>"/products/pricing/v0/items/#{asin}/offers",
'method' => 'GET',
'item_condition' => 'New',
'marketplace_id' => 'my market place id'
}
requests = [AmzSpApi::ProductPricingApiModel::ItemOffersRequest.new(options)]
batch_response = api.get_item_offers_batch_with_http_info(requests: requests)
The issue is constructing a ItemOffersRequest immediately fails with this error regardless of what I send.
AmzSpApi::ProductPricingApiModel::ItemOffersRequest.new(options)
or
AmzSpApi::ProductPricingApiModel::ItemOffersRequest.new
=> wrong number of arguments (given 1, expected 0)
Any examples of how this should work would be greatly appreciated!
it's poorly documented as it's generated code but if you "show source" it looks like it's expecting symbols e.g. :uri not 'uri' https://www.rubydoc.info/gems/amz_sp_api/AmzSpApi/ProductPricingApiModel/ItemOffersRequest#initialize-instance_method
Unfortunately, it wasn't an issue of the symbol vs string for me. In case it helps others this is how I got it to work.
asin_requests = ['asin1', 'asin2'].map do |asin|
uri: "/products/pricing/v0/items/#{asin}/offers",
method: 'GET',
# ItemCondition: 'New',
MarketplaceId: '...',
CustomerType: 'Consumer'
}
end
api_instance = AmzSpApi::ProductPricingApiModel::ProductPricingApi.new(AmzSpApi::SpApiClient.new)
item_offers_requests = AmzSpApi::ProductPricingApiModel::GetItemOffersBatchRequest.new(requests: asin_requests)
begin
result = api_instance.get_item_offers_batch_with_http_info(item_offers_requests)
rescue AmzSpApi::ProductPricingApiModel::ApiError => e
puts "Exception when calling ProductPricingApi->get_item_offers_batch: #{e}"
end