Class: Gonebusy::EntitiesScheduleResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/gonebusy/models/entities_schedule_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, resource_id = nil, service_id = nil, time_windows = nil) ⇒ EntitiesScheduleResponse

Returns a new instance of EntitiesScheduleResponse.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gonebusy/models/entities_schedule_response.rb', line 38

def initialize(id = nil,
               owner_id = nil,
               resource_id = nil,
               service_id = nil,
               time_windows = nil)
  @id = id
  @owner_id = owner_id
  @resource_id = resource_id
  @service_id = service_id
  @time_windows = time_windows
end

Instance Attribute Details

#idInteger

id of Schedule

Returns:

  • (Integer)


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

def id
  @id
end

#owner_idInteger

id of owner of Schedule

Returns:

  • (Integer)


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

def owner_id
  @owner_id
end

#resource_idInteger

id of Resource

Returns:

  • (Integer)


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

def resource_id
  @resource_id
end

#service_idInteger

id of Service

Returns:

  • (Integer)


19
20
21
# File 'lib/gonebusy/models/entities_schedule_response.rb', line 19

def service_id
  @service_id
end

#time_windowsList of EntitiesTimeWindowResponse

array of TimeWindows making up Schedule

Returns:



23
24
25
# File 'lib/gonebusy/models/entities_schedule_response.rb', line 23

def time_windows
  @time_windows
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gonebusy/models/entities_schedule_response.rb', line 51

def self.from_hash(hash)
  return nil unless hash

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

  # Create object from extracted values
  EntitiesScheduleResponse.new(id,
                               owner_id,
                               resource_id,
                               service_id,
                               time_windows)
end

.namesObject

A mapping from model property names to API property names



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gonebusy/models/entities_schedule_response.rb', line 26

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