Class: CalendarApi::EventList

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

Overview

A paginated list of events on a calendar.

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#events', etag: SKIP, summary: SKIP, description: SKIP, updated: SKIP, time_zone: SKIP, access_role: SKIP, default_reminders: SKIP, next_page_token: SKIP, next_sync_token: SKIP, items: SKIP, additional_properties: nil) ⇒ EventList

Returns a new instance of EventList.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/calendar_api/models/event_list.rb', line 98

def initialize(kind: 'calendar#events', etag: SKIP, summary: SKIP,
               description: SKIP, updated: SKIP, time_zone: SKIP,
               access_role: SKIP, default_reminders: SKIP,
               next_page_token: SKIP, next_sync_token: SKIP, items: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @kind = kind unless kind == SKIP
  @etag = etag unless etag == SKIP
  @summary = summary unless summary == SKIP
  @description = description unless description == SKIP
  @updated = updated unless updated == SKIP
  @time_zone = time_zone unless time_zone == SKIP
  @access_role = access_role unless access_role == SKIP
  @default_reminders = default_reminders unless default_reminders == SKIP
  @next_page_token = next_page_token unless next_page_token == SKIP
  @next_sync_token = next_sync_token unless next_sync_token == SKIP
  @items = items unless items == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#access_roleCalendarAccessRole

The user’s access role for a calendar.

Returns:



39
40
41
# File 'lib/calendar_api/models/event_list.rb', line 39

def access_role
  @access_role
end

#default_remindersArray[Reminder]

Default reminders on the calendar for the authenticated user.

Returns:



43
44
45
# File 'lib/calendar_api/models/event_list.rb', line 43

def default_reminders
  @default_reminders
end

#descriptionString

Description of the calendar.

Returns:

  • (String)


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

def description
  @description
end

#etagString

ETag of the collection.

Returns:

  • (String)


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

def etag
  @etag
end

#itemsArray[Event]

List of events on the calendar.

Returns:



57
58
59
# File 'lib/calendar_api/models/event_list.rb', line 57

def items
  @items
end

#kindString

Type of the collection.

Returns:

  • (String)


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

def kind
  @kind
end

#next_page_tokenString

Token used to access the next page of this result. Omitted if no further results are available.

Returns:

  • (String)


48
49
50
# File 'lib/calendar_api/models/event_list.rb', line 48

def next_page_token
  @next_page_token
end

#next_sync_tokenString

Token used for incremental synchronization at a later point. Only provided on the last page of results.

Returns:

  • (String)


53
54
55
# File 'lib/calendar_api/models/event_list.rb', line 53

def next_sync_token
  @next_sync_token
end

#summaryString

Title of the calendar.

Returns:

  • (String)


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

def summary
  @summary
end

#time_zoneString

The time zone of the calendar.

Returns:

  • (String)


35
36
37
# File 'lib/calendar_api/models/event_list.rb', line 35

def time_zone
  @time_zone
end

#updatedDateTime

Last modification time of the calendar (RFC3339).

Returns:

  • (DateTime)


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

def updated
  @updated
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/calendar_api/models/event_list.rb', line 121

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  kind = hash['kind'] ||= 'calendar#events'
  etag = hash.key?('etag') ? hash['etag'] : SKIP
  summary = hash.key?('summary') ? hash['summary'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  updated = if hash.key?('updated')
              (DateTimeHelper.from_rfc3339(hash['updated']) if hash['updated'])
            else
              SKIP
            end
  time_zone = hash.key?('timeZone') ? hash['timeZone'] : SKIP
  access_role = hash.key?('accessRole') ? hash['accessRole'] : SKIP
  # Parameter is an array, so we need to iterate through it
  default_reminders = nil
  unless hash['defaultReminders'].nil?
    default_reminders = []
    hash['defaultReminders'].each do |structure|
      default_reminders << (Reminder.from_hash(structure) if structure)
    end
  end

  default_reminders = SKIP unless hash.key?('defaultReminders')
  next_page_token =
    hash.key?('nextPageToken') ? hash['nextPageToken'] : SKIP
  next_sync_token =
    hash.key?('nextSyncToken') ? hash['nextSyncToken'] : SKIP
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (Event.from_hash(structure) if structure)
    end
  end

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

  # 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.
  EventList.new(kind: kind,
                etag: etag,
                summary: summary,
                description: description,
                updated: updated,
                time_zone: time_zone,
                access_role: access_role,
                default_reminders: default_reminders,
                next_page_token: next_page_token,
                next_sync_token: next_sync_token,
                items: items,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['kind'] = 'kind'
  @_hash['etag'] = 'etag'
  @_hash['summary'] = 'summary'
  @_hash['description'] = 'description'
  @_hash['updated'] = 'updated'
  @_hash['time_zone'] = 'timeZone'
  @_hash['access_role'] = 'accessRole'
  @_hash['default_reminders'] = 'defaultReminders'
  @_hash['next_page_token'] = 'nextPageToken'
  @_hash['next_sync_token'] = 'nextSyncToken'
  @_hash['items'] = 'items'
  @_hash
end

.nullablesObject

An array for nullable fields



94
95
96
# File 'lib/calendar_api/models/event_list.rb', line 94

def self.nullables
  []
end

.optionalsObject

An array for optional fields



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/calendar_api/models/event_list.rb', line 77

def self.optionals
  %w[
    kind
    etag
    summary
    description
    updated
    time_zone
    access_role
    default_reminders
    next_page_token
    next_sync_token
    items
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



198
199
200
201
202
203
204
205
206
# File 'lib/calendar_api/models/event_list.rb', line 198

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} kind: #{@kind.inspect}, etag: #{@etag.inspect}, summary:"\
  " #{@summary.inspect}, description: #{@description.inspect}, updated: #{@updated.inspect},"\
  " time_zone: #{@time_zone.inspect}, access_role: #{@access_role.inspect}, default_reminders:"\
  " #{@default_reminders.inspect}, next_page_token: #{@next_page_token.inspect},"\
  " next_sync_token: #{@next_sync_token.inspect}, items: #{@items.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_updatedObject



183
184
185
# File 'lib/calendar_api/models/event_list.rb', line 183

def to_custom_updated
  DateTimeHelper.to_rfc3339(updated)
end

#to_sObject

Provides a human-readable string representation of the object.



188
189
190
191
192
193
194
195
# File 'lib/calendar_api/models/event_list.rb', line 188

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} kind: #{@kind}, etag: #{@etag}, summary: #{@summary}, description:"\
  " #{@description}, updated: #{@updated}, time_zone: #{@time_zone}, access_role:"\
  " #{@access_role}, default_reminders: #{@default_reminders}, next_page_token:"\
  " #{@next_page_token}, next_sync_token: #{@next_sync_token}, items: #{@items},"\
  " additional_properties: #{@additional_properties}>"
end