lib/google_apps/transport.rb in google_apps-0.3.10 vs lib/google_apps/transport.rb in google_apps-0.3.11
- old
+ new
@@ -37,13 +37,12 @@
@request = Net::HTTP::Post.new(uri.path)
@request.body = auth_body(account, pass)
set_headers :auth
@response = request(uri)
- @response.body.split("\n").grep(/auth=(.*)/i)
- @token = $1
+ set_auth_token
@response
end
# request_export performs the GoogleApps API call to
@@ -208,10 +207,12 @@
self.send(:delete, instance_variable_get("@#{$2}"), *args)
when "update"
self.send(:update, instance_variable_get("@#{$2}"), *args)
when "get"
self.send(:get, instance_variable_get("@#{$2}"), *args)
+ when "add"
+ self.send(:add, instance_variable_get("@#{$2}"), *args)
else
super
end
end
@@ -226,9 +227,18 @@
# auth_body returns a string in the form of HTTP
# query parameters.
def auth_body(account, pass)
"&Email=#{CGI::escape(account)}&Passwd=#{CGI::escape(pass)}&accountType=HOSTED&service=apps"
end
+
+
+ # Grab the auth token from the response body
+ def set_auth_token
+ @response.body.split("\n").grep(/auth=(.*)/i)
+
+ @token = $1
+ end
+
def request(uri)
# TODO: Clashes with @request reader
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(@request)
\ No newline at end of file