def update_event(self,
                  calendar_id,
                  event_id,
                  new_event,
                  client_id=client,
                  send_notifications="False"):
     url = "{host}/{api}/calendars/{calendar_id}/events/{event_id}".\
         format(host=self.host, api=self.api, calendar_id=calendar_id, event_id=event_id)
     params = {"sendNotifications": send_notifications}
     request_body = create_string_from_json({
         "end": new_event.end,
         "start": new_event.start,
         "attendees": new_event.attendees,
         "iCalUID": new_event.iCalUID
     })
     req = HttpLib(url=url,
                   header=self.header,
                   json=create_json_from_string(request_body),
                   params=params)
     req.auth_to_google(client=client_id, scope=scope_calendar)
     req.send_put()
     if req.get_response_status_code(req.response) is status_code_200:
         return req.response, EventModel().get_event_model_from_json(
             **req.get_response_json(req.response))
     return req.response, None
 def get_quick_event(self, calendar_id, event_id):
     url = "{host}/{api}/calendars/{calendar_id}/events/{event_id}".\
         format(host=self.host, api=self.api, calendar_id=calendar_id, event_id=event_id)
     req = HttpLib(url)
     req.auth_to_google(client=client, scope=scope_calendar)
     req.send_get()
     if req.get_response_status_code(req.response) is status_code_200:
         return req.response, EventModel().get_summary(
             **req.get_response_json(req.response))
     return req.response, None
 def move_event(self, initial_calendar_id, event_id, target_calendar_id):
     params = {"destination": target_calendar_id}
     url = "{host}/{api}/calendars/{calendar_id}/events/{event_id}/move".\
         format(host=self.host, api=self.api, calendar_id=initial_calendar_id, event_id=event_id)
     req = HttpLib(url=url, params=params, header=self.header)
     req.auth_to_google(client=client, scope=scope_calendar)
     req.send_post()
     if req.get_response_status_code(req.response) is status_code_200:
         return req.response, EventModel().get_event_model_from_json(
             **req.get_response_json(req.response))
     return req.response, None
 def quick_add_event(self, calendar_id, summary):
     params = {"text": summary}
     url = "{host}/{api}/calendars/{calendar_id}/events/quickAdd".\
         format(host=self.host, api=self.api, calendar_id=calendar_id)
     req = HttpLib(url=url, header=self.header, params=params)
     req.auth_to_google(client=client, scope=scope_calendar)
     req.send_post()
     if req.get_response_status_code(req.response) is status_code_200:
         return req.response, EventModel().get_summary(
             **req.get_response_json(req.response))
     return req.response, None
 def instances_event(self, calendar_id, event_id):
     url = "{host}/{api}/calendars/{calendar_id}/events/{event_id}/instances".\
         format(host=self.host, api=self.api, calendar_id=calendar_id, event_id=event_id)
     req = HttpLib(url)
     req.auth_to_google(client=client, scope=scope_calendar)
     req.send_get()
     instances_events = []
     if req.get_response_status_code(req.response) is status_code_200:
         for event in req.get_response_json(req.response)['items']:
             instances_events.append(
                 EventModel().get_event_model_from_json(**event))
     return req.response, instances_events
 def list_events(self, calendar_id, client_id=client, params=None):
     url = "{host}/{api}/calendars/{calendar_id}/events".\
         format(host=self.host, api=self.api, calendar_id=calendar_id)
     req = HttpLib(url, params=params)
     req.auth_to_google(client=client_id, scope=scope_calendar)
     req.send_get()
     list_events = []
     if req.get_response_status_code(req.response) is status_code_200:
         for event in req.get_response_json(req.response)['items']:
             list_events.append(
                 EventModel().get_event_model_from_json(**event))
     return req.response, list_events
 def import_event(self, calendar_id, recurrent_event):
     request_body = {
         "end": recurrent_event.end,
         "start": recurrent_event.start,
         "attendees": recurrent_event.attendees,
         "iCalUID": recurrent_event.iCalUID,
         "recurrence": recurrent_event.recurrence
     }
     url = "{host}/{api}/calendars/{calendar_id}/events/import".\
         format(host=self.host, api=self.api, calendar_id=calendar_id)
     req = HttpLib(url, json=request_body)
     req.auth_to_google(client=client, scope=scope_calendar)
     req.send_post()
     if req.get_response_status_code(req.response) is status_code_200:
         return req.response, EventModel().get_event_model_from_json(
             **req.get_response_json(req.response))
     return req.response, None
Beispiel #8
0
def create_random_recurrence_event():
    return EventModel().create_random_recurrence_event()
Beispiel #9
0
def create_random_event(attendees=None):
    return EventModel().create_random_event(email=attendees)
Beispiel #10
0
def create_random_list_events(count, start_date, end_date):
    list_events = []
    for x in range(0, int(count)):
        list_events.append(EventModel().create_random_event(start_date, end_date))
    return list_events