Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get authors data #6

Closed
koki-73 opened this issue Aug 21, 2020 · 2 comments
Closed

Can't get authors data #6

koki-73 opened this issue Aug 21, 2020 · 2 comments

Comments

@koki-73
Copy link

koki-73 commented Aug 21, 2020

Hello, this gem is so nice to use PA API.
But I couldn't get authors data by using authors method like "item.authors".

I checked this paapi file, and I guess there is room for improvement.

When I request book data (market is jp), the request about authors is like as below

 "ItemInfo"=>
    {"ByLineInfo"=>
      {"Contributors"=>
        [{"Locale"=>"ja_JP", "Name"=>"###", "Role"=>"著", "RoleType"=>"author"},

but item.rb file is like as below

  def contributors_of(kind)
      kind = kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.capitalize }
      contributors.select { |e| e['Role'] == kind }&.map { |e| e.dig('Name') }&.reject {|n| n.to_s.empty?}
  end

  def authors
      contributors_of 'Author'
  end

so I think you might want to change like as below

  def contributors_of(kind)
      kind = kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.capitalize }
      contributors.select { |e| e['RoleType'] == kind }&.map { |e| e.dig('Name') }&.reject {|n| n.to_s.empty?}
  end

  def authors
      contributors_of 'author'
  end

I would greatly appreicate if you can give our proposal a good review.

@dkam dkam closed this as completed in 9465254 Aug 21, 2020
@dkam
Copy link
Owner

dkam commented Aug 21, 2020

Thanks for the bug report. It seems Amazon has started using RoleType and lower case values. I've updated Paapi to match, as suggested and pushed a new version of the gem.

@koki-73
Copy link
Author

koki-73 commented Aug 21, 2020

I appreciate your prompt action! It went smoothly in my app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants