Class GoogleCalendar::Service
In: lib/googlecalendar/service.rb
Parent: Object

This class interacts with google calendar service.

Methods

Constants

AUTH_SERVER = "www.google.com"   Server name to Authenticate
AUTH_PATH = "/accounts/ClientLogin"   Server Path to authenticate
CALENDAR_LIST_PATH = "http://www.google.com/calendar/feeds/"   URL to get calendar list

Public Class methods

[Source]

# File lib/googlecalendar/service.rb, line 69
    def initialize(email, pass)
      @email = email
      @pass = pass
      @session = nil
      @cookie = nil
      @auth = nil
    end

[Source]

# File lib/googlecalendar/service.rb, line 30
    def self.proxy_addr
      @@proxy_addr
    end

[Source]

# File lib/googlecalendar/service.rb, line 34
    def self.proxy_addr=(addr)
      @@proxy_addr=addr
    end

[Source]

# File lib/googlecalendar/service.rb, line 60
    def self.proxy_pass
      @@proxy_pass
    end

[Source]

# File lib/googlecalendar/service.rb, line 64
    def self.proxy_pass=(pass)
      @@proxy_pass = pass
    end

[Source]

# File lib/googlecalendar/service.rb, line 40
    def self.proxy_port
      @@proxy_port
    end

[Source]

# File lib/googlecalendar/service.rb, line 44
    def self.proxy_port=(port)
      @@proxy_port = port
    end

[Source]

# File lib/googlecalendar/service.rb, line 50
    def self.proxy_user
      @@proxy_user
    end

[Source]

# File lib/googlecalendar/service.rb, line 54
    def self.proxy_user=(user)
      @@proxy_user = user
    end

Public Instance methods

get the list of user’s calendars and returns http response object

[Source]

# File lib/googlecalendar/service.rb, line 80
    def calendar_list
      auth unless @auth
      uri = URI.parse(CALENDAR_LIST_PATH + @email)
      do_get(uri, "Authorization" =>  "GoogleLogin auth=#{@auth}")
    end
calendars()

Alias for calendar_list

delete an event.

[Source]

# File lib/googlecalendar/service.rb, line 115
    def delete(feed)
      auth unless @auth
      uri = URI.parse(feed)
      do_post(uri, 
              {"X-HTTP-Method-Override" => "DELETE", 
               "Authorization" =>  "GoogleLogin auth=#{@auth}"}, 
               "DELETE " + uri.path)
    end

insert an event

[Source]

# File lib/googlecalendar/service.rb, line 127
    def insert(feed, event)
      auth unless @auth
      uri = URI.parse(feed)
      do_post(uri, 
              {"Authorization" =>  "GoogleLogin auth=#{@auth}",
               "Content-Type" => "application/atom+xml",
               "Content-Length" => event.length.to_s}, event)
    end

send query for events of a calendar and returns http response object. available condtions are

  • :q => query string
  • :max-results => max contents count. (default: 25)
  • :start-index => 1-based index of the first result to be retrieved
  • :orderby => the order of retrieved data.
  • :published-min => Bounds on the entry publication date(oldest)
  • :published-max => Bounds on the entry publication date(newest)
  • :updated-min => Bounds on the entry update date(oldest)
  • :updated-max => Bounds on the entry update date(newest)
  • :author => Entry author

For detail, see code.google.com/apis/gdata/protocol.html#Queries

[Source]

# File lib/googlecalendar/service.rb, line 103
    def query(cal_url, conditions)
      auth unless @auth
      uri = URI.parse(cal_url)
      uri.query = conditions.map do |key, val|
        "#{key}=#{URI.escape(val.kind_of?(Time) ? val.getutc.iso8601 : val.to_s)}"
      end.join("&")
      do_get(uri, "Authorization" =>  "GoogleLogin auth=#{@auth}")
    end

update an event.

[Source]

# File lib/googlecalendar/service.rb, line 139
    def update(feed, event)
      auth unless @auth
      uri = URI.parse(feed)
      do_post(uri, 
              {"X-HTTP-Method-Override" => "PUT", 
               "Authorization" =>  "GoogleLogin auth=#{@auth}", 
               "Content-Type" => "application/atom+xml",
               "Content-Length" => event.length.to_s}, event)
    end

[Validate]