Add the following code to your project's shard.yml under:
dependencies
to use in production
- OR -
development_dependencies
to use in development
PlaceCalendar provides a standardised interface for cloud based calendaring solutions, with Office365 and Google currently supported.
Endpoints are provided for
Add the dependency to your shard.yml
:
dependencies:
place_calendar:
github: PlaceOS/calendar
Run shards install
require "place_calendar"
o365_creds = {
tenant: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
client_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
client_secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
}
client = PlaceCalendar::Client.new(**o365_creds)
google_creds = {
file_path: "/path/to/your/credtions.json",
scopes: ["https://www.googleapis.com/auth/calendar", "https://www.googleapis.com/auth/directory.user.readonly", "https://www.googleapis.com/auth/drive"],
domain: "yourdomain.com"
}
client = PlaceCalendar::Client.new(**google_creds)
list = client.list_users
# list calendars
calendars = client.list_calendars("mailbox@domain.com")
# get a calendar
calendar = client.get_calendar("mailbox@domain.com", calendar_id)
# list events
list = client.list_events("mailbox@domain.com")
# get an event
event = client.get_event("mailbox@domain.com", event_id)
# create an event
e = PlaceCalendar::Event.new
e.title = "My New Meeting"
e.body = "All about my new meeting"
e.event_start = Time.local
e.event_end = Time.local + 30.minutes
a.attendees << {name: "John Smith", email: "john.smith@domain.com"}
new_event = client.create_event(user_id: "mailbox@domain.com", event: e)
# update an event
new_event.attendees << {name: "Foo Bar", email: "foo.bar@domain.com"}
client.update_event(user_id: "mailbox@domain.com", event: new_event)
# delete an event
client.delete_event(user_id: "mailbox@domain.com", id: new_event.id)
# recurring events
daily_recurrence = PlaceCalendar::Recurrence.new(
Time.local, # recurrence start time
Time.local + 14.days, # recurrence end time
2, # recurrence interval
"daily" # recurrent pattern, daily, weekly, or monthly
)
my_event.recurrence = daily_recurrence
client.update_event(user_id: "mailbox@domain.com", id: my_event.id)
# list attachments
attachments = client.list_attachments(user_id: "mailbox@domain.com", event_id: my_event.id)
# get an attachment
attachment = client.get_attachent(user_id: "mailbox@domain.com", event_id: my_event.id, id: "123")
# create an attachment
my_attachment = PlaceCalendar::Attachment.new(name: "filename.ext", content_bytes: File.read("filename.ext"))
client.create_attachment(user_id: "mailbox@domain.com", event_id: event.id, attachment: my_attachment)
# delete an attachment
client.delete_attachment(user_id: "mailbox@domain.com", event_id: my_event.id, attachment_id: my_attachment.id)
# get availability for multiple uers
# this will return an array of PlaceCalendar::Availability objects, one for each of the emails in the array, for the time period specified
schedule = client.get_availability("mailbox@domain.com", ["me@domain.com", "you@domain.com", "them@domain.com"], Time.local - 1.week, Time.local + 1.week)
TODO: Write development instructions here
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)