module Hitblocks
Constants
- VERSION
Attributes
api_base[RW]
api_key[RW]
Public Class Methods
construct_HIT(parsed_response)
click to toggle source
# File lib/hitblocks.rb, line 27 def self.construct_HIT(parsed_response) Hitblocks::HIT.new( url: parsed_response["url"], service: parsed_response["service"], status: parsed_response["status"], created: parsed_response["created"], item: construct_item(parsed_response["item"]) ) end
construct_error(parsed_response)
click to toggle source
# File lib/hitblocks.rb, line 47 def self.construct_error(parsed_response) error = parsed_response["error"] if error.nil? error = parsed_response["errors"] end Hitblocks::Error.new( error: error, status: parsed_response["status"] ) end
construct_from(response)
click to toggle source
# File lib/hitblocks.rb, line 38 def self.construct_from(response) parsed_response = response.parsed_response if parsed_response["object"] self.send("construct_#{parsed_response["object"]}", parsed_response) else construct_error(parsed_response) end end
construct_hitblock(parsed_response)
click to toggle source
# File lib/hitblocks.rb, line 80 def self.construct_hitblock(parsed_response) Hitblocks::Hitblock.new( id: parsed_response["id"], title: parsed_response["title"], description: parsed_response["description"], type: parsed_response["type"], created: parsed_response["created"], cost_per_item: parsed_response["cost_per_item"], workers_per_item: parsed_response["workers_per_item"], currency: parsed_response["currency"], items: construct_items(parsed_response["items"]) ) end
construct_item(item)
click to toggle source
# File lib/hitblocks.rb, line 69 def self.construct_item(item) Hitblocks::Item.new( id: item["id"], type: item["type"], created: item["created"], cost: item["cost"], currency: item["currency"], status: item["status"] ) end
construct_items(item_list)
click to toggle source
# File lib/hitblocks.rb, line 94 def self.construct_items(item_list) items = [] item_list.each do |item| items.push(Hitblocks::Item.new( id: item["id"], type: item["type"], created: item["created"], cost: item["cost"], currency: item["currency"], status: item["status"] )) end return items end
construct_list(parsed_response)
click to toggle source
# File lib/hitblocks.rb, line 58 def self.construct_list(parsed_response) data = parsed_response["data"] list_items = [] data.each do |object| list_items.push(self.send("construct_#{object["object"]}", object)) end Hitblocks::List.new( data: list_items ) end