Class: Hitblocks::Hitblock

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/hitblocks/hitblock.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Hitblock

Returns a new instance of Hitblock.



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/hitblocks/hitblock.rb', line 31

def initialize(params = {})
  self.class.raise_missing_parameters if params.fetch(:id, nil).nil?
  @id = params[:id]
  @title = params[:title]
  @description = params[:description]
  @type = params[:type]
  @created = params[:created]
  @cost_per_item = params[:cost_per_item]
  @workers_per_item = params[:workers_per_item]
  @currency = params[:currency]
  @items = params[:items]
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/hitblocks/hitblock.rb', line 5

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



6
7
8
# File 'lib/hitblocks/hitblock.rb', line 6

def items
  @items
end

Class Method Details

.listObject



20
21
22
23
24
25
26
27
28
# File 'lib/hitblocks/hitblock.rb', line 20

def list
  self.base_uri Hitblocks.api_base
  response = self.get("/hitblocks",
                      basic_auth: {
                        username: Hitblocks.api_key,
                      })

  Hitblocks.construct_from(response)
end

.retrieve(id = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/hitblocks/hitblock.rb', line 9

def retrieve(id = nil)
  self.base_uri Hitblocks.api_base
  raise_missing_parameters if id.nil?
  response = self.get("/hitblocks/#{id}",
                      basic_auth: {
                        username: Hitblocks.api_key, 
                      })

  Hitblocks.construct_from(response)
end