This is really just a sketch of a library at the moment, but it will let you do some basic things with the GoogleApps API. I’ve built this with the idea of using it in a Rails project because that’s what I’m using it for, but it doesn’t have to be so…
If you’re interested in building this out more, send me an email or just fork the project.
-
HTTParty v0.4.2 & Crack
-
A GoogleApps account (N.B. it’s nice to have separate ones for dev and prod)
-
gem install dependencies (see requirements above)
-
Copy google_apps.rb to your Rails project lib directory
-
Make a file: config/google_apps.yml with settings for your environments,
e.g.:
development: email: soandso@gmail.com password: pass
(Alternatively, or if you’re not using Rails, just edit the google_apps.rb file so that @@config is a hash with this info.)
g = GoogleApps::CalendarsConnection.new calendars = g.calendars
calendar = g.calendars.first calendar.events
calendar_event = g.create_event! :title => "My Event", :description => "Behind the scenes", :starts_at => Time.zone.now, :ends_at => 1.day.from_now
calendar_event = g.create_event! :title => "My Event", :description => "Behind the scenes", :starts_at => Time.zone.now, :ends_at => 1.hour.from_now, :recurrence => { :freq => :daily, :until => 1.week.from_now }
calendar = g.calendars.detect{|cal| cal.title == "My Public Calendar"} calendar.create_event! :title => "My Event", :description => "Open to the public", :starts_at => Time.zone.now, :ends_at => 1.day.from_now
calendar_event.update! :title => "Cool Event", :description => "Now with more fizz... BAM!", :starts_at => Time.zone.now, :ends_at => 1.day.from_now
calendar_event.destroy
g = GoogleApps::SpreadsheetsConnection.new gs = g.create! :title => "My Cool Spreadsheet"
g.add_user gs, ["ghostfacekillah@example.com", "raekwonthechef@example.com"], :writer
gs.link
-
A better test framework for testing expected behavior against XML responses from Google
-
Make connections less wasteful by using ETags and pooling
-
Break out google_apps.rb into utility-specific files, e.g. google_apps_connect.rb
-
acts_as_google_calendar