Class: GoogleCalendar::ServiceBase
- Inherits:
-
Object
- Object
- GoogleCalendar::ServiceBase
- Defined in:
- lib/googlecalendar/service_base.rb
Overview
This class interacts with google calendar service.
Direct Known Subclasses
Constant Summary collapse
- AUTH_SERVER =
Server name to Authenticate
"www.google.com"
- CALENDAR_LIST_PATH =
URL to get calendar list
"http://www.google.com/calendar/feeds/default/allcalendars/full"
- @@proxy_addr =
proxy server address
nil
- @@proxy_port =
proxy server port number
nil
- @@proxy_user =
proxy server username
nil
- @@proxy_pass =
proxy server password
nil
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
- .proxy_addr ⇒ Object
- .proxy_addr=(addr) ⇒ Object
- .proxy_pass ⇒ Object
- .proxy_pass=(pass) ⇒ Object
- .proxy_port ⇒ Object
- .proxy_port=(port) ⇒ Object
- .proxy_user ⇒ Object
- .proxy_user=(user) ⇒ Object
Instance Method Summary collapse
-
#calendar_list ⇒ Object
(also: #calendars)
get the list of user’s calendars and returns http response object.
-
#delete(feed, event) ⇒ Object
delete an event.
-
#insert(feed, event) ⇒ Object
insert an event.
-
#query(cal_url, conditions = nil) ⇒ Object
send query for events of a calendar and returns http response object.
-
#update(feed, event) ⇒ Object
update an event.
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
65 66 67 |
# File 'lib/googlecalendar/service_base.rb', line 65 def logger @logger end |
Class Method Details
.proxy_addr ⇒ Object
27 28 29 |
# File 'lib/googlecalendar/service_base.rb', line 27 def self.proxy_addr @@proxy_addr end |
.proxy_addr=(addr) ⇒ Object
31 32 33 |
# File 'lib/googlecalendar/service_base.rb', line 31 def self.proxy_addr=(addr) @@proxy_addr=addr end |
.proxy_pass ⇒ Object
57 58 59 |
# File 'lib/googlecalendar/service_base.rb', line 57 def self.proxy_pass @@proxy_pass end |
.proxy_pass=(pass) ⇒ Object
61 62 63 |
# File 'lib/googlecalendar/service_base.rb', line 61 def self.proxy_pass=(pass) @@proxy_pass = pass end |
.proxy_port ⇒ Object
37 38 39 |
# File 'lib/googlecalendar/service_base.rb', line 37 def self.proxy_port @@proxy_port end |
.proxy_port=(port) ⇒ Object
41 42 43 |
# File 'lib/googlecalendar/service_base.rb', line 41 def self.proxy_port=(port) @@proxy_port = port end |
.proxy_user ⇒ Object
47 48 49 |
# File 'lib/googlecalendar/service_base.rb', line 47 def self.proxy_user @@proxy_user end |
.proxy_user=(user) ⇒ Object
51 52 53 |
# File 'lib/googlecalendar/service_base.rb', line 51 def self.proxy_user=(user) @@proxy_user = user end |
Instance Method Details
#calendar_list ⇒ Object Also known as: calendars
get the list of user’s calendars and returns http response object
70 71 72 73 74 75 76 77 |
# File 'lib/googlecalendar/service_base.rb', line 70 def calendar_list logger.info("-- calendar list st --") if logger auth unless @auth uri = URI.parse(CALENDAR_LIST_PATH) res = do_get(uri, {}) logger.info("-- calendar list en(#{res.}) --") if logger res end |
#delete(feed, event) ⇒ Object
delete an event.
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/googlecalendar/service_base.rb', line 112 def delete(feed, event) logger.info("-- delete st --") if logger auth unless @auth uri = URI.parse(feed) res = do_post(uri, {"X-HTTP-Method-Override" => "DELETE", "Content-Type" => "application/atom+xml", "Content-Length" => event.length.to_s}, event) logger.info("-- delete en (#{res.}) --") if logger res end |
#insert(feed, event) ⇒ Object
insert an event
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/googlecalendar/service_base.rb', line 127 def insert(feed, event) logger.info("-- insert st --") if logger auth unless @auth uri = URI.parse(feed) res = do_post(uri, {"Content-Type" => "application/atom+xml", "Content-Length" => event.length.to_s}, event) logger.info("-- insert en (#{res.}) --") if logger res end |
#query(cal_url, conditions = nil) ⇒ Object
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
and so on. For detail, see code.google.com/apis/gdata/protocol.html#Queries
and http://code.google.com/apis/calendar/reference.html#Parameters
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/googlecalendar/service_base.rb', line 97 def query(cal_url, conditions = nil) logger.info("-- query st --") if logger 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("&") unless conditions.nil? res = do_get(uri, {}) logger.info("-- query en (#{res.}) --") if logger res end |
#update(feed, event) ⇒ Object
update an event.
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/googlecalendar/service_base.rb', line 141 def update(feed, event) logger.info("-- update st --") if logger auth unless @auth uri = URI.parse(feed) res = do_post(uri, {"X-HTTP-Method-Override" => "PUT", "Content-Type" => "application/atom+xml", "Content-Length" => event.length.to_s}, event) logger.info("-- update en (#{res.}) --") if logger res end |