def reserve_time_slot(self, calendar_event_id, participant_id=None, **kwargs): """ Return single Calendar Event by id :calls: `POST /api/v1/calendar_events/:id/reservations \ <https://canvas.instructure.com/doc/api/calendar_events.html#method.calendar_events_api.reserve>`_ :param calendar_event_id: The ID of the calendar event. :type calendar_event_id: `int` :rtype: :class:`canvasapi.calendar_event.CalendarEvent` """ from canvasapi.calendar_event import CalendarEvent if participant_id: uri = 'calendar_events/%s/reservations/%s' % (calendar_event_id, participant_id) else: uri = 'calendar_events/%s/reservations' % (calendar_event_id) response = self.__requester.request('POST', uri, **combine_kwargs(**kwargs)) return CalendarEvent(self.__requester, response.json())
def reserve_time_slot(self, calendar_event, participant_id=None, **kwargs): """ Return single Calendar Event by id :calls: `POST /api/v1/calendar_events/:id/reservations \ <https://canvas.instructure.com/doc/api/calendar_events.html#method.calendar_events_api.reserve>`_ :param calendar_event: The object or ID of the calendar event. :type calendar_event: :class:`canvasapi.calendar_event.CalendarEvent` or int :param participant_id: The ID of the participant, if given. :type participant_id: str :rtype: :class:`canvasapi.calendar_event.CalendarEvent` """ from canvasapi.calendar_event import CalendarEvent calendar_event_id = obj_or_id(calendar_event, "calendar_event", (CalendarEvent, )) if participant_id: uri = 'calendar_events/{}/reservations/{}'.format( calendar_event_id, participant_id) else: uri = 'calendar_events/{}/reservations'.format(calendar_event_id) response = self.__requester.request('POST', uri, _kwargs=combine_kwargs(**kwargs)) return CalendarEvent(self.__requester, response.json())
def create_calendar_event(self, calendar_event, **kwargs): """ Create a new Calendar Event. :calls: `POST /api/v1/calendar_events \ <https://canvas.instructure.com/doc/api/calendar_events.html#method.calendar_events_api.create>`_ :param calendar_event: The attributes of the calendar event. :type calendar_event: `dict` :rtype: :class:`canvasapi.calendar_event.CalendarEvent` """ from canvasapi.calendar_event import CalendarEvent if isinstance(calendar_event, dict) and 'context_code' in calendar_event: kwargs['calendar_event'] = calendar_event else: raise RequiredFieldMissing( "Dictionary with key 'context_codes' is required.") response = self.__requester.request('POST', 'calendar_events', _kwargs=combine_kwargs(**kwargs)) return CalendarEvent(self.__requester, response.json())
def get_calendar_event(self, calendar_event_id): """ Return single Calendar Event by id :calls: `GET /api/v1/calendar_events/:id \ <https://canvas.instructure.com/doc/api/calendar_events.html#method.calendar_events_api.show>`_ :param calendar_event_id: The ID of the calendar event. :type calendar_event_id: `int` :rtype: :class:`canvasapi.calendar_event.CalendarEvent` """ from canvasapi.calendar_event import CalendarEvent response = self.__requester.request( 'GET', 'calendar_events/%s' % (calendar_event_id)) return CalendarEvent(self.__requester, response.json())
def get_calendar_event(self, calendar_event): """ Return single Calendar Event by id :calls: `GET /api/v1/calendar_events/:id \ <https://canvas.instructure.com/doc/api/calendar_events.html#method.calendar_events_api.show>`_ :param calendar_event: The object or ID of the calendar event. :type calendar_event: :class:`canvasapi.calendar_event.CalendarEvent` or int :rtype: :class:`canvasapi.calendar_event.CalendarEvent` """ from canvasapi.calendar_event import CalendarEvent calendar_event_id = obj_or_id(calendar_event, "calendar_event", (CalendarEvent, )) response = self.__requester.request( 'GET', 'calendar_events/{}'.format(calendar_event_id)) return CalendarEvent(self.__requester, response.json())