Class: Gonebusy::EntitiesAvailabilityResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/gonebusy/models/entities_availability_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = nil, owner_id = nil, resources = nil) ⇒ EntitiesAvailabilityResponse

Returns a new instance of EntitiesAvailabilityResponse.



28
29
30
31
32
33
34
# File 'lib/gonebusy/models/entities_availability_response.rb', line 28

def initialize(id = nil,
               owner_id = nil,
               resources = nil)
  @id = id
  @owner_id = owner_id
  @resources = resources
end

Instance Attribute Details

#idInteger

id of Service

Returns:

  • (Integer)


7
8
9
# File 'lib/gonebusy/models/entities_availability_response.rb', line 7

def id
  @id
end

#owner_idInteger

id of owner of Service

Returns:

  • (Integer)


11
12
13
# File 'lib/gonebusy/models/entities_availability_response.rb', line 11

def owner_id
  @owner_id
end

#resourcesList of EntitiesResourceAvailabilities

array of Resource ids and available time slots

Returns:



15
16
17
# File 'lib/gonebusy/models/entities_availability_response.rb', line 15

def resources
  @resources
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/gonebusy/models/entities_availability_response.rb', line 37

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash
  id = hash['id']
  owner_id = hash['owner_id']
  # Parameter is an array, so we need to iterate through it
  resources = nil
  if hash['resources'] != nil
    resources = Array.new
    hash['resources'].each{|structure| resources << (EntitiesResourceAvailabilities.from_hash(structure) if structure)}
  end

  # Create object from extracted values
  EntitiesAvailabilityResponse.new(id,
                                   owner_id,
                                   resources)
end

.namesObject

A mapping from model property names to API property names



18
19
20
21
22
23
24
25
26
# File 'lib/gonebusy/models/entities_availability_response.rb', line 18

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash["id"] = "id"
    @_hash["owner_id"] = "owner_id"
    @_hash["resources"] = "resources"
  end
  @_hash
end