Class: CalendarApi::EventsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/calendar_api/apis/events_api.rb

Overview

EventsApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from CalendarApi::BaseApi

Instance Method Details

#create_event(calendar_id, body, conference_data_version: ConferenceDataVersion::ENUM_0, max_attendees: nil, send_updates: nil, supports_attachments: false) ⇒ ApiResponse

Creates an event on the specified calendar. retrieve calendar IDs call the calendarList.list method. Use the keyword “primary” to access the primary calendar of the currently logged-in user. event. Version number of conference data supported by the API client. Version 0 assumes no conference data support. Version 1 enables support for copying of ConferenceData as well as creating new conferences using createRequest. attendees to include in the response. notifications about the creation of the new event. Whether the API client performing the operation supports event attachments. Default is false.

Parameters:

  • calendar_id (String)

    Required parameter: Calendar identifier. To

  • body (Event)

    Required parameter: Request body for create an

  • conference_data_version (ConferenceDataVersion) (defaults to: ConferenceDataVersion::ENUM_0)

    Optional parameter:

  • max_attendees (Integer) (defaults to: nil)

    Optional parameter: The maximum number of

  • send_updates (SendUpdates) (defaults to: nil)

    Optional parameter: Whether to send

  • supports_attachments (TrueClass | FalseClass) (defaults to: false)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/calendar_api/apis/events_api.rb', line 149

def create_event(calendar_id,
                 body,
                 conference_data_version: ConferenceDataVersion::ENUM_0,
                 max_attendees: nil,
                 send_updates: nil,
                 supports_attachments: false)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/calendars/{calendarId}/events',
                                 Server::DEFAULT)
               .template_param(new_parameter(calendar_id, key: 'calendarId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .query_param(new_parameter(conference_data_version, key: 'conferenceDataVersion'))
               .query_param(new_parameter(max_attendees, key: 'maxAttendees'))
               .query_param(new_parameter(send_updates, key: 'sendUpdates'))
               .query_param(new_parameter(supports_attachments, key: 'supportsAttachments'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Event.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad request — invalid parameters or request body.',
                             ErrorResponseError1Exception)
                .local_error('401',
                             'Authentication required or credentials are invalid.',
                             ErrorResponseError1Exception)
                .local_error('403',
                             'Insufficient permissions for the requested resource.',
                             ErrorResponseError1Exception)
                .local_error('404',
                             'The requested resource was not found.',
                             ErrorResponseError1Exception)
                .local_error('409',
                             'Conflict — an event with the given ID already exists.',
                             ErrorResponseError1Exception))
    .execute
end

#delete_event(calendar_id, event_id, send_updates: nil) ⇒ ApiResponse

Deletes an event from the specified calendar. retrieve calendar IDs call the calendarList.list method. Use the keyword “primary” to access the primary calendar of the currently logged-in user. receive notifications about the deletion of the event.

Parameters:

  • calendar_id (String)

    Required parameter: Calendar identifier. To

  • event_id (String)

    Required parameter: Event identifier.

  • send_updates (SendUpdates) (defaults to: nil)

    Optional parameter: Guests who should

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/calendar_api/apis/events_api.rb', line 270

def delete_event(calendar_id,
                 event_id,
                 send_updates: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/calendars/{calendarId}/events/{eventId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(calendar_id, key: 'calendarId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(event_id, key: 'eventId')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(send_updates, key: 'sendUpdates'))
               .auth(Single.new('oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad request — invalid parameters or request body.',
                             ErrorResponseError1Exception)
                .local_error('401',
                             'Authentication required or credentials are invalid.',
                             ErrorResponseError1Exception)
                .local_error('403',
                             'Insufficient permissions for the requested resource.',
                             ErrorResponseError1Exception)
                .local_error('404',
                             'The requested resource was not found.',
                             ErrorResponseError1Exception)
                .local_error('410',
                             'Event has already been deleted.',
                             ErrorResponseError1Exception))
    .execute
end

#list_events(calendar_id, event_types: nil, i_cal_uid: nil, max_attendees: nil, max_results: 250, order_by: nil, page_token: nil, private_extended_property: nil, q: nil, shared_extended_property: nil, show_deleted: false, show_hidden_invitations: false, single_events: false, sync_token: nil, time_max: nil, time_min: nil, time_zone: nil, updated_min: nil) ⇒ ApiResponse

Returns events on the specified calendar. Results are paginated and ordered by start time (when singleEvents is true) or by last modification time (default). retrieve calendar IDs call the calendarList.list method. Use the keyword “primary” to access the primary calendar of the currently logged-in user. type. May be repeated to include multiple types. to search for. Only one event with the given UID will be returned. attendees to include in the response. If there are more attendees, only the participant is returned. returned on one result page. The number of events in the resulting page may be less than this value. Default is 250, maximum allowed is 2500. returned in the result. When using orderBy with startTime, singleEvents must be true. result page to return. property constraint specified as propertyName=value. Matches only private properties. events matching these terms in the summary, description, location, attendee’s displayName, and attendee’s email. property constraint specified as propertyName=value. Matches only shared properties. to include deleted events (with status equals “cancelled”) in the result. Default is false. parameter: Whether to include hidden invitations in the result. Default is false. to expand recurring events into instances and only return single one-off events and instances of recurring events. Default is false. nextSyncToken field returned on the last page of results from the previous list request. Makes the result contain only entries that have changed since then. Cannot be used together with iCalUID, orderBy, privateExtendedProperty, q, sharedExtendedProperty, timeMin, timeMax, or updatedMin. an event’s start time to filter by. Must be an RFC3339 timestamp with mandatory time zone offset. an event’s end time to filter by. Must be an RFC3339 timestamp with mandatory time zone offset. response. Defaults to the time zone of the calendar. event’s last modification time (RFC3339 timestamp) to filter by.

Parameters:

  • calendar_id (String)

    Required parameter: Calendar identifier. To

  • event_types (Array[EventType]) (defaults to: nil)

    Optional parameter: Filter by event

  • i_cal_uid (String) (defaults to: nil)

    Optional parameter: Specifies an iCalendar UID

  • max_attendees (Integer) (defaults to: nil)

    Optional parameter: The maximum number of

  • max_results (Integer) (defaults to: 250)

    Optional parameter: Maximum number of events

  • order_by (EventOrderBy) (defaults to: nil)

    Optional parameter: The order of the events

  • page_token (String) (defaults to: nil)

    Optional parameter: Token specifying which

  • private_extended_property (String) (defaults to: nil)

    Optional parameter: Extended

  • q (String) (defaults to: nil)

    Optional parameter: Free text search terms to find

  • shared_extended_property (String) (defaults to: nil)

    Optional parameter: Extended

  • show_deleted (TrueClass | FalseClass) (defaults to: false)

    Optional parameter: Whether

  • show_hidden_invitations (TrueClass | FalseClass) (defaults to: false)

    Optional

  • single_events (TrueClass | FalseClass) (defaults to: false)

    Optional parameter: Whether

  • sync_token (String) (defaults to: nil)

    Optional parameter: Token obtained from the

  • time_max (DateTime) (defaults to: nil)

    Optional parameter: Upper bound (exclusive) for

  • time_min (DateTime) (defaults to: nil)

    Optional parameter: Lower bound (exclusive) for

  • time_zone (String) (defaults to: nil)

    Optional parameter: Time zone used in the

  • updated_min (DateTime) (defaults to: nil)

    Optional parameter: Lower bound for an

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



66
67
68
69
70
71
72
73
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/calendar_api/apis/events_api.rb', line 66

def list_events(calendar_id,
                event_types: nil,
                i_cal_uid: nil,
                max_attendees: nil,
                max_results: 250,
                order_by: nil,
                page_token: nil,
                private_extended_property: nil,
                q: nil,
                shared_extended_property: nil,
                show_deleted: false,
                show_hidden_invitations: false,
                single_events: false,
                sync_token: nil,
                time_max: nil,
                time_min: nil,
                time_zone: nil,
                updated_min: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/calendars/{calendarId}/events',
                                 Server::DEFAULT)
               .template_param(new_parameter(calendar_id, key: 'calendarId')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(event_types, key: 'eventTypes'))
               .query_param(new_parameter(i_cal_uid, key: 'iCalUID'))
               .query_param(new_parameter(max_attendees, key: 'maxAttendees'))
               .query_param(new_parameter(max_results, key: 'maxResults'))
               .query_param(new_parameter(order_by, key: 'orderBy'))
               .query_param(new_parameter(page_token, key: 'pageToken'))
               .query_param(new_parameter(private_extended_property, key: 'privateExtendedProperty'))
               .query_param(new_parameter(q, key: 'q'))
               .query_param(new_parameter(shared_extended_property, key: 'sharedExtendedProperty'))
               .query_param(new_parameter(show_deleted, key: 'showDeleted'))
               .query_param(new_parameter(show_hidden_invitations, key: 'showHiddenInvitations'))
               .query_param(new_parameter(single_events, key: 'singleEvents'))
               .query_param(new_parameter(sync_token, key: 'syncToken'))
               .query_param(new_parameter(time_max, key: 'timeMax'))
               .query_param(new_parameter(time_min, key: 'timeMin'))
               .query_param(new_parameter(time_zone, key: 'timeZone'))
               .query_param(new_parameter(updated_min, key: 'updatedMin'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(EventList.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad request — invalid parameters or request body.',
                             ErrorResponseError1Exception)
                .local_error('401',
                             'Authentication required or credentials are invalid.',
                             ErrorResponseError1Exception)
                .local_error('403',
                             'Insufficient permissions for the requested resource.',
                             ErrorResponseError1Exception)
                .local_error('404',
                             'The requested resource was not found.',
                             ErrorResponseError1Exception))
    .execute
end

#patch_event(calendar_id, event_id, body, conference_data_version: ConferenceDataVersion::ENUM_0, max_attendees: nil, send_updates: nil, supports_attachments: false) ⇒ ApiResponse

Updates an event using patch semantics. Each patch request consumes three quota units. Only fields specified in the request body are modified; unspecified fields remain unchanged. Array fields, if specified, overwrite existing arrays entirely. retrieve calendar IDs call the calendarList.list method. Use the keyword “primary” to access the primary calendar of the currently logged-in user. event. Version number of conference data supported by the API client. attendees to include in the response. notifications about the event update. Whether the API client performing the operation supports event attachments.

Parameters:

  • calendar_id (String)

    Required parameter: Calendar identifier. To

  • event_id (String)

    Required parameter: Event identifier.

  • body (Event)

    Required parameter: Request body for update an

  • conference_data_version (ConferenceDataVersion) (defaults to: ConferenceDataVersion::ENUM_0)

    Optional parameter:

  • max_attendees (Integer) (defaults to: nil)

    Optional parameter: The maximum number of

  • send_updates (SendUpdates) (defaults to: nil)

    Optional parameter: Whether to send

  • supports_attachments (TrueClass | FalseClass) (defaults to: false)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/calendar_api/apis/events_api.rb', line 215

def patch_event(calendar_id,
                event_id,
                body,
                conference_data_version: ConferenceDataVersion::ENUM_0,
                max_attendees: nil,
                send_updates: nil,
                supports_attachments: false)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/calendars/{calendarId}/events/{eventId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(calendar_id, key: 'calendarId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(event_id, key: 'eventId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .query_param(new_parameter(conference_data_version, key: 'conferenceDataVersion'))
               .query_param(new_parameter(max_attendees, key: 'maxAttendees'))
               .query_param(new_parameter(send_updates, key: 'sendUpdates'))
               .query_param(new_parameter(supports_attachments, key: 'supportsAttachments'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Event.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad request — invalid parameters or request body.',
                             ErrorResponseError1Exception)
                .local_error('401',
                             'Authentication required or credentials are invalid.',
                             ErrorResponseError1Exception)
                .local_error('403',
                             'Insufficient permissions for the requested resource.',
                             ErrorResponseError1Exception)
                .local_error('404',
                             'The requested resource was not found.',
                             ErrorResponseError1Exception))
    .execute
end

#watch_events(calendar_id, body, event_types: nil) ⇒ ApiResponse

Sets up a push notification channel to watch for changes to events on the specified calendar. When events change, a POST notification is sent to the specified address. retrieve calendar IDs call the calendarList.list method. Use the keyword “primary” to access the primary calendar of the currently logged-in user. event changes. event types to watch for changes.

Parameters:

  • calendar_id (String)

    Required parameter: Calendar identifier. To

  • body (WatchRequest)

    Required parameter: Request body for watch for

  • event_types (Array[EventType]) (defaults to: nil)

    Optional parameter: Filters which

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/calendar_api/apis/events_api.rb', line 318

def watch_events(calendar_id,
                 body,
                 event_types: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/calendars/{calendarId}/events/watch',
                                 Server::DEFAULT)
               .template_param(new_parameter(calendar_id, key: 'calendarId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .query_param(new_parameter(event_types, key: 'eventTypes'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Channel.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad request — invalid parameters or request body.',
                             ErrorResponseError1Exception)
                .local_error('401',
                             'Authentication required or credentials are invalid.',
                             ErrorResponseError1Exception)
                .local_error('403',
                             'Insufficient permissions for the requested resource.',
                             ErrorResponseError1Exception)
                .local_error('404',
                             'The requested resource was not found.',
                             ErrorResponseError1Exception))
    .execute
end