ericcj / amz_sp_api

AmzSpApi - Unofficial Ruby gem for the Selling Partner APIs (SP-API)
Apache License 2.0
50 stars 60 forks source link

Calling get_feed(FEED_ID) results in undefined method `build_from_hash' for Feed:Class #33

Open noorani786 opened 2 years ago

noorani786 commented 2 years ago

After successfully submitting a feed, when we call get_feed(FEED_ID), it always throws this error:

7: from /var/www/ncube_ecomm/releases/20221019163120/app/proxies/amzn_sp_api/feed_proxy.rb:19:inget_feed' 6: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/feeds-api-model/api/feeds_api.rb:190:in get_feed' 5: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/feeds-api-model/api/feeds_api.rb:226:inget_feed_with_http_info' 4: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/sp_api_client.rb:18:in call_api' 3: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/api_client.rb:72:incall_api' 2: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/api_client.rb:200:in deserialize' 1: from /var/www/ncube_ecomm/shared/bundle/ruby/2.5.0/gems/amz_sp_api-1.0.0/lib/api_client.rb:239:inconvert_to_type' NoMethodError (undefined method build_from_hash' for Feed:Class)

Can you please fix it?

ericcj commented 2 years ago

we use this method successfully. do you have another class named Feed in your codebase and what is its namespace? the one it intends to use has a build_from_hash method https://github.com/ericcj/amz_sp_api/blob/main/lib/feeds-api-model/models/feed.rb#L222 but i wouldn't be surprised if there was a bug in this line that somehow is picking up yours https://github.com/ericcj/amz_sp_api/blob/main/lib/api_client.rb#L239

dicksonwu2000 commented 4 months ago

I am getting same error, using ruby-3.3.2 ETHON: performed EASY effective_url=https://sellingpartnerapi-na.amazon.com/reports/2021-06-30/reports/105390019918 response_code=200 return_code=ok total_time=0.137147 app/models/amazon_seller_orderv2.rb:75:in load': undefined methodbuild_from_hash' for class Report (NoMethodError) from (irb):3:in `

'

mendywoly commented 4 months ago

You most likely have a report model, add this method to your model.

Class Report 

…

def self.build_from_hash(data)
   AmzSpApi::ReportsApiModel::Report.build_from_hash(data)
  end

…

end
dicksonwu2000 commented 4 months ago

Thank you @mendywoly. You are correct. It works perfectly now.