You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.6 KiB

  1. from dateutil.parser import parse as date_parse
  2. from gapi.apis.calendar_api.models import weekdays, Event
  3. from gapi.apis.calendar_api import calendar_api
  4. import datetime
  5. if __name__ == "__main__":
  6. MY_API = calendar_api("fuck google")
  7. # ~~BODY EXAMPLE~~##~~BODY EXAMPLE~~
  8. example = {
  9. "attendees": [{"email": "lpage@example.com"}, {"email": "sbrin@example.com"}],
  10. "description": "A chance to hear more about Google's\
  11. developer products.",
  12. "end": {
  13. "dateTime": "2015-05-28T17:00:00-07:00",
  14. "timeZone": "America/Los_Angeles",
  15. },
  16. "location": "800 Howard St., San Francisco, CA 94103",
  17. "recurrence": ["RRULE:FREQ=DAILY;COUNT=2"],
  18. "reminders": {
  19. "overrides": [
  20. {"method": "email", "minutes": 1440},
  21. {"method": "popup", "minutes": 10},
  22. ],
  23. "useDefault": False,
  24. },
  25. "start": {
  26. "dateTime": "2015-05-28T09:00:00-07:00",
  27. "timeZone": "America/Los_Angeles",
  28. },
  29. "summary": "Google I/O 2015",
  30. }
  31. e = Event(
  32. date_parse("march 16, 2019 10:00 am"),
  33. date_parse("march 16, 2019 3:30 pm"),
  34. "Hang out with Matt",
  35. )
  36. CAL_ID = "raphael.roberts48@gmail.com"
  37. event = Event.from_json(example)
  38. id = event.upload(MY_API, CAL_ID)
  39. print(id)
  40. e2 = Event.from_id(MY_API, CAL_ID, id)
  41. until = datetime.datetime.today() + datetime.timedelta(days=20)
  42. e2.add_weekly_recurrence(until, weekdays.MON, weekdays.TUE)
  43. e2.upload(MY_API, CAL_ID)