Class: CalendarApi::FreeBusyResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/calendar_api/models/free_busy_response.rb

Overview

Response with free/busy information.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(kind: 'calendar#freeBusy', time_min: SKIP, time_max: SKIP, calendars: SKIP, groups: SKIP, additional_properties: nil) ⇒ FreeBusyResponse

Returns a new instance of FreeBusyResponse.



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/calendar_api/models/free_busy_response.rb', line 60

def initialize(kind: 'calendar#freeBusy', time_min: SKIP, time_max: SKIP,
               calendars: SKIP, groups: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @kind = kind unless kind == SKIP
  @time_min = time_min unless time_min == SKIP
  @time_max = time_max unless time_max == SKIP
  @calendars = calendars unless calendars == SKIP
  @groups = groups unless groups == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#calendarsHash[String, FreeBusyCalendar]

Free/busy information for each requested calendar.

Returns:



27
28
29
# File 'lib/calendar_api/models/free_busy_response.rb', line 27

def calendars
  @calendars
end

#groupsHash[String, FreeBusyGroup]

Expansion of groups.

Returns:



31
32
33
# File 'lib/calendar_api/models/free_busy_response.rb', line 31

def groups
  @groups
end

#kindString

Type of the resource.

Returns:

  • (String)


15
16
17
# File 'lib/calendar_api/models/free_busy_response.rb', line 15

def kind
  @kind
end

#time_maxDateTime

The end of the time range queried.

Returns:

  • (DateTime)


23
24
25
# File 'lib/calendar_api/models/free_busy_response.rb', line 23

def time_max
  @time_max
end

#time_minDateTime

The start of the time range queried.

Returns:

  • (DateTime)


19
20
21
# File 'lib/calendar_api/models/free_busy_response.rb', line 19

def time_min
  @time_min
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/calendar_api/models/free_busy_response.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  kind = hash['kind'] ||= 'calendar#freeBusy'
  time_min = if hash.key?('timeMin')
               (DateTimeHelper.from_rfc3339(hash['timeMin']) if hash['timeMin'])
             else
               SKIP
             end
  time_max = if hash.key?('timeMax')
               (DateTimeHelper.from_rfc3339(hash['timeMax']) if hash['timeMax'])
             else
               SKIP
             end
  calendars = FreeBusyCalendar.from_hash(hash['calendars']) if hash['calendars']

  calendars = SKIP unless hash.key?('calendars')
  groups = FreeBusyGroup.from_hash(hash['groups']) if hash['groups']

  groups = SKIP unless hash.key?('groups')

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  FreeBusyResponse.new(kind: kind,
                       time_min: time_min,
                       time_max: time_max,
                       calendars: calendars,
                       groups: groups,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/calendar_api/models/free_busy_response.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['kind'] = 'kind'
  @_hash['time_min'] = 'timeMin'
  @_hash['time_max'] = 'timeMax'
  @_hash['calendars'] = 'calendars'
  @_hash['groups'] = 'groups'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
# File 'lib/calendar_api/models/free_busy_response.rb', line 56

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
52
53
# File 'lib/calendar_api/models/free_busy_response.rb', line 45

def self.optionals
  %w[
    kind
    time_min
    time_max
    calendars
    groups
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



128
129
130
131
132
133
# File 'lib/calendar_api/models/free_busy_response.rb', line 128

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} kind: #{@kind.inspect}, time_min: #{@time_min.inspect}, time_max:"\
  " #{@time_max.inspect}, calendars: #{@calendars.inspect}, groups: #{@groups.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_time_maxObject



116
117
118
# File 'lib/calendar_api/models/free_busy_response.rb', line 116

def to_custom_time_max
  DateTimeHelper.to_rfc3339(time_max)
end

#to_custom_time_minObject



112
113
114
# File 'lib/calendar_api/models/free_busy_response.rb', line 112

def to_custom_time_min
  DateTimeHelper.to_rfc3339(time_min)
end

#to_sObject

Provides a human-readable string representation of the object.



121
122
123
124
125
# File 'lib/calendar_api/models/free_busy_response.rb', line 121

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} kind: #{@kind}, time_min: #{@time_min}, time_max: #{@time_max}, calendars:"\
  " #{@calendars}, groups: #{@groups}, additional_properties: #{@additional_properties}>"
end