Gcevent
A wrapper of Google Calendar Event API.
Installation
Add this line to your application's Gemfile:
gem 'gcevent'
And then execute:
$ bundle
Or install it yourself as:
$ gem install gcevent
Usage
Calendar Setting
Google::Calendar.id = "Id of a target Google Calendar"
Google::Calendar.secret_key.path = "Path of xxx-privatekey.p12"
Google::Calendar.secret_key.password = "Password"
Google::Calendar.client_secret_path = "Path of client_secret_xxx.json"
Google::Calendar.client_email = "Email address of service account"
Event#get
event_id = "Google Calendar Event ID"
event = Google::Calendar::Event.get(event_id)
or
event = Google::Calendar::Event.new(event_id: event_id)
event.fetch
Event#list
specified date or time
start_date = Date.today.beginning_of_week
end_date = Date.today.end_of_week
events = Google::Calendar::Event.list(start_date, end_date)
today or this week or ...
Google::Calendar::Event.today
Google::Calendar::Event.tomorrow
Google::Calendar::Event.yesterday
Google::Calendar::Event.this_week
Google::Calendar::Event.this_month
Google::Calendar::Event.this_year
Event#insert
event = Google::Calendar::Event.new
event.summary = "Inserted #{Time.now}"
event.start = { dateTime: Date.today.to_time.utc.iso8601 }
event.end = { dateTime: Date.tomorrow.to_time.utc.iso8601 }
event.insert
or
options = { summary: "Inserted #{Time.now}",
start: { date: Date.today },
end: { date: Date.tomorrow } }
event = Google::Calendar::Event.insert(options)
Event#quickAdd
quick insert
text = "Quick Added"
event = Google::Calendar::Event.quickAdd(text)
Event#update
event = Google::Calendar::Event.this_week.last
event.summary = "Updated #{Time.now}"
event.update
Delete Phase
event = Google::Calendar::Event.this_week.first
event.delete
or
event = Google::Calendar::Event.this_week.last
Google::Calendar::Event.delete(event.id)
Contributing
- Fork it ( https://github.com/[my-github-username]/gcevent/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request