class IceAndFireApi::Book
Attributes
characters[R]
country[R]
isbn[R]
mediaType[R]
name[R]
numberOfPages[R]
povCharacters[R]
publisher[R]
released[R]
url[R]
Public Class Methods
find(id)
click to toggle source
# File lib/ice_and_fire_api/book.rb, line 21 def self.find(id) response = Faraday.get("#{IceAndFireApi::API_URL}/books/#{id}") attributes = JSON.parse(response.body) new(attributes) end
find_by(query_parameters)
click to toggle source
# File lib/ice_and_fire_api/book.rb, line 27 def self.find_by(query_parameters) book_query = URI.encode_www_form(query_parameters) response = Faraday.get("#{IceAndFireApi::API_URL}/books?#{book_query}") attributes_response = JSON.parse(response.body) attributes_array = [] attributes_response.each do |attributes| attributes_array << new(attributes) end attributes_array end
new(attributes)
click to toggle source
# File lib/ice_and_fire_api/book.rb, line 7 def initialize(attributes) @url = attributes['url'] @name = attributes['name'] @isbn = attributes['isbn'] @authors = attributes['authors'] @number_of_pages = attributes['numberOfPages'] @publisher = attributes['publisher'] @country = attributes['country'] @media_type = attributes['mediaType'] @released = attributes['released'] @characters = attributes['characters'] @pov_characters = attributes['povCharacters'] end