class Hitblocks::Item
Attributes
id[RW]
Public Class Methods
create(params)
click to toggle source
# File lib/hitblocks/item.rb, line 34 def create(params) self.base_uri Hitblocks.api_base payload = Hash.new payload[:item] = params.reject {|x| x == :hitblock} response = self.post("/hitblocks/#{params[:hitblock].id}/items", body: payload.to_json, headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }, basic_auth: { username: Hitblocks.api_key } ) Hitblocks.construct_from(response) end
list()
click to toggle source
# File lib/hitblocks/item.rb, line 15 def list self.base_uri Hitblocks.api_base response = self.get('/items', basic_auth: { username: Hitblocks.api_key } ) Hitblocks.construct_from(response) end
new(params = {})
click to toggle source
# File lib/hitblocks/item.rb, line 9 def initialize(params = {}) self.class.raise_missing_parameters if params.fetch(:id, nil).nil? @id = params[:id] end
retrieve(id = nil)
click to toggle source
# File lib/hitblocks/item.rb, line 24 def retrieve(id = nil) self.raise_missing_parameters unless id self.base_uri Hitblocks.api_base response = self.get("/items/#{id}", basic_auth: { username: Hitblocks.api_key } ) Hitblocks.construct_from(response) end
Private Class Methods
raise_missing_parameters()
click to toggle source
# File lib/hitblocks/item.rb, line 71 def self.raise_missing_parameters raise Hitblocks::MissingParametersError, "Missing ID Parameter" end
Public Instance Methods
delete()
click to toggle source
# File lib/hitblocks/item.rb, line 51 def delete self.class.base_uri Hitblocks.api_base response = self.class.delete("/items/#{self.id}", basic_auth: { username: Hitblocks.api_key } ) return response end
post()
click to toggle source
# File lib/hitblocks/item.rb, line 60 def post self.class.base_uri Hitblocks.api_base response = self.class.post("/items/#{self.id}/post", basic_auth: { username: Hitblocks.api_key } ) Hitblocks.construct_from(response) end