gdata_19 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.hgtags +5 -0
- data/LICENSE +202 -0
- data/README +97 -0
- data/Rakefile +82 -0
- data/VERSION +1 -0
- data/bin/test_captcha.rb +52 -0
- data/doc/classes/GData/Auth/AuthSub.html +349 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000020.html +29 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000021.html +29 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000022.html +31 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000023.html +29 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000024.html +32 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000025.html +26 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000026.html +29 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000038.html +28 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000039.html +29 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000040.html +31 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000041.html +29 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000042.html +32 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000043.html +28 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000044.html +29 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000045.html +31 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000046.html +28 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000047.html +28 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000048.html +29 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000049.html +31 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000050.html +28 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000051.html +31 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000052.html +25 -0
- data/doc/classes/GData/Auth/AuthSub.src/M000053.html +29 -0
- data/doc/classes/GData/Auth/ClientLogin.html +232 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000027.html +27 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000028.html +47 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000029.html +22 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000045.html +29 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000046.html +49 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000047.html +22 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000050.html +29 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000051.html +49 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000052.html +22 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000053.html +29 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000054.html +29 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000055.html +49 -0
- data/doc/classes/GData/Auth/ClientLogin.src/M000056.html +22 -0
- data/doc/classes/GData/Auth.html +133 -0
- data/doc/classes/GData/Client/Apps.html +146 -0
- data/doc/classes/GData/Client/Apps.src/M000027.html +19 -0
- data/doc/classes/GData/Client/Apps.src/M000028.html +19 -0
- data/doc/classes/GData/Client/AuthorizationError.html +113 -0
- data/doc/classes/GData/Client/BadRequestError.html +113 -0
- data/doc/classes/GData/Client/Base.html +453 -0
- data/doc/classes/GData/Client/Base.src/M000002.html +21 -0
- data/doc/classes/GData/Client/Base.src/M000003.html +55 -0
- data/doc/classes/GData/Client/Base.src/M000004.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000005.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000006.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000007.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000008.html +22 -0
- data/doc/classes/GData/Client/Base.src/M000009.html +26 -0
- data/doc/classes/GData/Client/Base.src/M000010.html +22 -0
- data/doc/classes/GData/Client/Base.src/M000011.html +25 -0
- data/doc/classes/GData/Client/Base.src/M000012.html +25 -0
- data/doc/classes/GData/Client/Base.src/M000013.html +33 -0
- data/doc/classes/GData/Client/Base.src/M000014.html +44 -0
- data/doc/classes/GData/Client/Base.src/M000015.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000016.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000017.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000018.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000019.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000020.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000021.html +25 -0
- data/doc/classes/GData/Client/Base.src/M000022.html +28 -0
- data/doc/classes/GData/Client/Base.src/M000023.html +22 -0
- data/doc/classes/GData/Client/Base.src/M000024.html +18 -0
- data/doc/classes/GData/Client/Base.src/M000025.html +22 -0
- data/doc/classes/GData/Client/Blogger.html +146 -0
- data/doc/classes/GData/Client/Blogger.src/M000002.html +20 -0
- data/doc/classes/GData/Client/BookSearch.html +146 -0
- data/doc/classes/GData/Client/BookSearch.src/M000010.html +20 -0
- data/doc/classes/GData/Client/BookSearch.src/M000011.html +20 -0
- data/doc/classes/GData/Client/Calendar.html +221 -0
- data/doc/classes/GData/Client/Calendar.src/M000030.html +20 -0
- data/doc/classes/GData/Client/Calendar.src/M000031.html +20 -0
- data/doc/classes/GData/Client/Calendar.src/M000032.html +19 -0
- data/doc/classes/GData/Client/Calendar.src/M000033.html +25 -0
- data/doc/classes/GData/Client/Calendar.src/M000034.html +21 -0
- data/doc/classes/GData/Client/CaptchaError.html +167 -0
- data/doc/classes/GData/Client/CaptchaError.src/M000001.html +19 -0
- data/doc/classes/GData/Client/CaptchaError.src/M000005.html +19 -0
- data/doc/classes/GData/Client/Contacts.html +146 -0
- data/doc/classes/GData/Client/Contacts.src/M000003.html +20 -0
- data/doc/classes/GData/Client/DocList.html +146 -0
- data/doc/classes/GData/Client/DocList.src/M000006.html +20 -0
- data/doc/classes/GData/Client/DocList.src/M000007.html +20 -0
- data/doc/classes/GData/Client/Error.html +118 -0
- data/doc/classes/GData/Client/Finance.html +146 -0
- data/doc/classes/GData/Client/Finance.src/M000029.html +20 -0
- data/doc/classes/GData/Client/Finance.src/M000030.html +20 -0
- data/doc/classes/GData/Client/GBase.html +146 -0
- data/doc/classes/GData/Client/GBase.src/M000004.html +20 -0
- data/doc/classes/GData/Client/GMail.html +146 -0
- data/doc/classes/GData/Client/GMail.src/M000028.html +20 -0
- data/doc/classes/GData/Client/GMail.src/M000029.html +20 -0
- data/doc/classes/GData/Client/Health.html +146 -0
- data/doc/classes/GData/Client/Health.src/M000031.html +20 -0
- data/doc/classes/GData/Client/Health.src/M000034.html +20 -0
- data/doc/classes/GData/Client/Health.src/M000035.html +20 -0
- data/doc/classes/GData/Client/Notebook.html +146 -0
- data/doc/classes/GData/Client/Notebook.src/M000009.html +20 -0
- data/doc/classes/GData/Client/Notebook.src/M000010.html +20 -0
- data/doc/classes/GData/Client/Photos.html +146 -0
- data/doc/classes/GData/Client/Photos.src/M000008.html +21 -0
- data/doc/classes/GData/Client/Photos.src/M000009.html +21 -0
- data/doc/classes/GData/Client/RequestError.html +167 -0
- data/doc/classes/GData/Client/RequestError.src/M000006.html +20 -0
- data/doc/classes/GData/Client/ServerError.html +113 -0
- data/doc/classes/GData/Client/Spreadsheets.html +146 -0
- data/doc/classes/GData/Client/Spreadsheets.src/M000001.html +20 -0
- data/doc/classes/GData/Client/UnknownError.html +113 -0
- data/doc/classes/GData/Client/VersionConflictError.html +113 -0
- data/doc/classes/GData/Client/WebmasterTools.html +146 -0
- data/doc/classes/GData/Client/WebmasterTools.src/M000007.html +20 -0
- data/doc/classes/GData/Client/WebmasterTools.src/M000008.html +20 -0
- data/doc/classes/GData/Client/YouTube.html +192 -0
- data/doc/classes/GData/Client/YouTube.src/M000013.html +19 -0
- data/doc/classes/GData/Client/YouTube.src/M000014.html +24 -0
- data/doc/classes/GData/Client/YouTube.src/M000025.html +22 -0
- data/doc/classes/GData/Client/YouTube.src/M000026.html +22 -0
- data/doc/classes/GData/Client/YouTube.src/M000027.html +24 -0
- data/doc/classes/GData/Client.html +198 -0
- data/doc/classes/GData/HTTP/DefaultService.html +150 -0
- data/doc/classes/GData/HTTP/DefaultService.src/M000019.html +48 -0
- data/doc/classes/GData/HTTP/DefaultService.src/M000037.html +63 -0
- data/doc/classes/GData/HTTP/DefaultService.src/M000042.html +66 -0
- data/doc/classes/GData/HTTP/DefaultService.src/M000045.html +66 -0
- data/doc/classes/GData/HTTP/DefaultService.src/M000046.html +66 -0
- data/doc/classes/GData/HTTP/MimeBody.html +202 -0
- data/doc/classes/GData/HTTP/MimeBody.src/M000032.html +22 -0
- data/doc/classes/GData/HTTP/MimeBody.src/M000033.html +31 -0
- data/doc/classes/GData/HTTP/MimeBody.src/M000034.html +18 -0
- data/doc/classes/GData/HTTP/MimeBody.src/M000035.html +22 -0
- data/doc/classes/GData/HTTP/MimeBody.src/M000036.html +22 -0
- data/doc/classes/GData/HTTP/MimeBody.src/M000037.html +31 -0
- data/doc/classes/GData/HTTP/MimeBody.src/M000038.html +18 -0
- data/doc/classes/GData/HTTP/MimeBodyString.html +164 -0
- data/doc/classes/GData/HTTP/MimeBodyString.src/M000036.html +19 -0
- data/doc/classes/GData/HTTP/MimeBodyString.src/M000037.html +27 -0
- data/doc/classes/GData/HTTP/MimeBodyString.src/M000039.html +19 -0
- data/doc/classes/GData/HTTP/MimeBodyString.src/M000040.html +19 -0
- data/doc/classes/GData/HTTP/MimeBodyString.src/M000041.html +27 -0
- data/doc/classes/GData/HTTP/Request.html +243 -0
- data/doc/classes/GData/HTTP/Request.src/M000015.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000016.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000017.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000018.html +24 -0
- data/doc/classes/GData/HTTP/Request.src/M000033.html +24 -0
- data/doc/classes/GData/HTTP/Request.src/M000034.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000035.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000036.html +25 -0
- data/doc/classes/GData/HTTP/Request.src/M000038.html +24 -0
- data/doc/classes/GData/HTTP/Request.src/M000039.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000040.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000041.html +24 -0
- data/doc/classes/GData/HTTP/Request.src/M000042.html +24 -0
- data/doc/classes/GData/HTTP/Request.src/M000043.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000044.html +22 -0
- data/doc/classes/GData/HTTP/Request.src/M000045.html +25 -0
- data/doc/classes/GData/HTTP/Response.html +179 -0
- data/doc/classes/GData/HTTP/Response.src/M000032.html +26 -0
- data/doc/classes/GData/HTTP/Response.src/M000035.html +26 -0
- data/doc/classes/GData/HTTP/Response.src/M000038.html +26 -0
- data/doc/classes/GData/HTTP/Response.src/M000039.html +26 -0
- data/doc/classes/GData/HTTP.html +127 -0
- data/doc/classes/GData.html +226 -0
- data/doc/created.rid +1 -0
- data/doc/files/README.html +214 -0
- data/doc/files/lib/gdata/auth/authsub_rb.html +131 -0
- data/doc/files/lib/gdata/auth/clientlogin_rb.html +129 -0
- data/doc/files/lib/gdata/auth_rb.html +130 -0
- data/doc/files/lib/gdata/client/apps_rb.html +122 -0
- data/doc/files/lib/gdata/client/base_rb.html +122 -0
- data/doc/files/lib/gdata/client/blogger_rb.html +122 -0
- data/doc/files/lib/gdata/client/booksearch_rb.html +122 -0
- data/doc/files/lib/gdata/client/calendar_rb.html +122 -0
- data/doc/files/lib/gdata/client/contacts_rb.html +122 -0
- data/doc/files/lib/gdata/client/doclist_rb.html +122 -0
- data/doc/files/lib/gdata/client/finance_rb.html +122 -0
- data/doc/files/lib/gdata/client/gbase_rb.html +122 -0
- data/doc/files/lib/gdata/client/gdata_rb.html +129 -0
- data/doc/files/lib/gdata/client/gmail_rb.html +122 -0
- data/doc/files/lib/gdata/client/health_rb.html +122 -0
- data/doc/files/lib/gdata/client/notebook_rb.html +122 -0
- data/doc/files/lib/gdata/client/photos_rb.html +122 -0
- data/doc/files/lib/gdata/client/spreadsheets_rb.html +122 -0
- data/doc/files/lib/gdata/client/webmaster_tools_rb.html +122 -0
- data/doc/files/lib/gdata/client/youtube_rb.html +122 -0
- data/doc/files/lib/gdata/client_rb.html +144 -0
- data/doc/files/lib/gdata/http/default_service_rb.html +131 -0
- data/doc/files/lib/gdata/http/mime_body_rb.html +122 -0
- data/doc/files/lib/gdata/http/request_rb.html +129 -0
- data/doc/files/lib/gdata/http/response_rb.html +129 -0
- data/doc/files/lib/gdata/http_rb.html +132 -0
- data/doc/files/lib/gdata_rb.html +132 -0
- data/doc/fr_class_index.html +61 -0
- data/doc/fr_file_index.html +53 -0
- data/doc/fr_method_index.html +82 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/gdata19.gemspec +294 -0
- data/lib/gdata/auth/authsub.rb +162 -0
- data/lib/gdata/auth/clientlogin.rb +103 -0
- data/lib/gdata/auth.rb +23 -0
- data/lib/gdata/client/apps.rb +28 -0
- data/lib/gdata/client/base.rb +183 -0
- data/lib/gdata/client/blogger.rb +29 -0
- data/lib/gdata/client/booksearch.rb +29 -0
- data/lib/gdata/client/calendar.rb +59 -0
- data/lib/gdata/client/contacts.rb +29 -0
- data/lib/gdata/client/doclist.rb +29 -0
- data/lib/gdata/client/finance.rb +29 -0
- data/lib/gdata/client/gbase.rb +29 -0
- data/lib/gdata/client/gmail.rb +29 -0
- data/lib/gdata/client/health.rb +29 -0
- data/lib/gdata/client/notebook.rb +29 -0
- data/lib/gdata/client/photos.rb +30 -0
- data/lib/gdata/client/spreadsheets.rb +29 -0
- data/lib/gdata/client/webmaster_tools.rb +29 -0
- data/lib/gdata/client/youtube.rb +48 -0
- data/lib/gdata/client.rb +85 -0
- data/lib/gdata/http/default_service.rb +83 -0
- data/lib/gdata/http/mime_body.rb +101 -0
- data/lib/gdata/http/request.rb +75 -0
- data/lib/gdata/http/response.rb +45 -0
- data/lib/gdata/http.rb +19 -0
- data/lib/gdata.rb +24 -0
- data/pkg/gdata19-1.1.2.gem +0 -0
- data/test/tc_gdata_auth_authsub.rb +53 -0
- data/test/tc_gdata_auth_clientlogin.rb +59 -0
- data/test/tc_gdata_client_base.rb +37 -0
- data/test/tc_gdata_client_calendar.rb +40 -0
- data/test/tc_gdata_client_photos.rb +65 -0
- data/test/tc_gdata_client_youtube.rb +77 -0
- data/test/tc_gdata_http_mime_body.rb +47 -0
- data/test/tc_gdata_http_request.rb +36 -0
- data/test/test_config.yml.example +7 -0
- data/test/test_helper.rb +47 -0
- data/test/testimage.jpg +0 -0
- data/test/ts_gdata.rb +48 -0
- data/test/ts_gdata_auth.rb +25 -0
- data/test/ts_gdata_client.rb +29 -0
- data/test/ts_gdata_http.rb +25 -0
- metadata +320 -0
@@ -0,0 +1,183 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# A client object used to interact with different Google Data APIs.
|
20
|
+
class Base
|
21
|
+
|
22
|
+
# A subclass of GData::Auth that handles authentication signing.
|
23
|
+
attr_accessor :auth_handler
|
24
|
+
# A subclass of GData::HTTP that handles making HTTP requests.
|
25
|
+
attr_accessor :http_service
|
26
|
+
# Headers to include in every request.
|
27
|
+
attr_accessor :headers
|
28
|
+
# The API version being used.
|
29
|
+
attr_accessor :version
|
30
|
+
# The default URL for ClientLogin.
|
31
|
+
attr_accessor :clientlogin_url
|
32
|
+
# A default service name for ClientLogin (overriden by subclasses).
|
33
|
+
attr_accessor :clientlogin_service
|
34
|
+
# The broadest AuthSub scope for working with an API.
|
35
|
+
# This is overriden by the service-specific subclasses.
|
36
|
+
attr_accessor :authsub_scope
|
37
|
+
# A short string identifying the current application.
|
38
|
+
attr_accessor :source
|
39
|
+
|
40
|
+
def initialize(options = {})
|
41
|
+
options.each do |key, value|
|
42
|
+
self.send("#{key}=", value)
|
43
|
+
end
|
44
|
+
|
45
|
+
@headers ||= {}
|
46
|
+
@http_service ||= GData::HTTP::DefaultService
|
47
|
+
@version ||= '2'
|
48
|
+
@source ||= 'AnonymousApp'
|
49
|
+
end
|
50
|
+
|
51
|
+
# Sends an HTTP request with the given file as a stream
|
52
|
+
def make_file_request(method, url, file_path, mime_type, entry = nil)
|
53
|
+
if not File.readable?(file_path)
|
54
|
+
raise ArgumentError, "File #{file_path} is not readable."
|
55
|
+
end
|
56
|
+
file = File.open(file_path, 'rb')
|
57
|
+
@headers['Slug'] = File.basename(file_path)
|
58
|
+
if entry
|
59
|
+
@headers['MIME-Version'] = '1.0'
|
60
|
+
body = GData::HTTP::MimeBody.new(entry, file, mime_type)
|
61
|
+
@headers['Content-Type'] = body.content_type
|
62
|
+
response = self.make_request(method, url, body)
|
63
|
+
else
|
64
|
+
@headers['Content-Type'] = mime_type
|
65
|
+
response = self.make_request(method, url, file)
|
66
|
+
end
|
67
|
+
file.close
|
68
|
+
return response
|
69
|
+
end
|
70
|
+
|
71
|
+
# Sends an HTTP request and return the response.
|
72
|
+
def make_request(method, url, body = '')
|
73
|
+
headers = self.prepare_headers
|
74
|
+
request = GData::HTTP::Request.new(url, :headers => headers,
|
75
|
+
:method => method, :body => body)
|
76
|
+
|
77
|
+
if @auth_handler and @auth_handler.respond_to?(:sign_request!)
|
78
|
+
@auth_handler.sign_request!(request)
|
79
|
+
end
|
80
|
+
|
81
|
+
service = http_service.new
|
82
|
+
response = service.make_request(request)
|
83
|
+
|
84
|
+
case response.status_code
|
85
|
+
when 200, 201, 302
|
86
|
+
#Do nothing, it's a success.
|
87
|
+
when 401, 403
|
88
|
+
raise AuthorizationError.new(response)
|
89
|
+
when 400
|
90
|
+
raise BadRequestError.new(response)
|
91
|
+
when 409
|
92
|
+
raise VersionConflictError.new(response)
|
93
|
+
when 500
|
94
|
+
raise ServerError.new(response)
|
95
|
+
else
|
96
|
+
raise UnknownError.new(response)
|
97
|
+
end
|
98
|
+
|
99
|
+
return response
|
100
|
+
end
|
101
|
+
|
102
|
+
# Performs an HTTP GET against the API.
|
103
|
+
def get(url)
|
104
|
+
return self.make_request(:get, url)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Performs an HTTP PUT against the API.
|
108
|
+
def put(url, body)
|
109
|
+
return self.make_request(:put, url, body)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Performs an HTTP PUT with the given file
|
113
|
+
def put_file(url, file_path, mime_type, entry = nil)
|
114
|
+
return self.make_file_request(:put, url, file_path, mime_type, entry)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Performs an HTTP POST against the API.
|
118
|
+
def post(url, body)
|
119
|
+
return self.make_request(:post, url, body)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Performs an HTTP POST with the given file
|
123
|
+
def post_file(url, file_path, mime_type, entry = nil)
|
124
|
+
return self.make_file_request(:post, url, file_path, mime_type, entry)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Performs an HTTP DELETE against the API.
|
128
|
+
def delete(url)
|
129
|
+
return self.make_request(:delete, url)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Constructs some necessary headers for every request.
|
133
|
+
def prepare_headers
|
134
|
+
headers = @headers
|
135
|
+
headers['GData-Version'] = @version
|
136
|
+
headers['User-Agent'] = GData::Auth::SOURCE_LIB_STRING + @source
|
137
|
+
# by default we assume we are sending Atom entries
|
138
|
+
if not headers.has_key?('Content-Type')
|
139
|
+
headers['Content-Type'] = 'application/atom+xml'
|
140
|
+
end
|
141
|
+
return headers
|
142
|
+
end
|
143
|
+
|
144
|
+
# Performs ClientLogin for the service. See GData::Auth::ClientLogin
|
145
|
+
# for details.
|
146
|
+
def clientlogin(username, password, captcha_token = nil,
|
147
|
+
captcha_answer = nil, service = nil, account_type = nil)
|
148
|
+
if service.nil?
|
149
|
+
service = @clientlogin_service
|
150
|
+
end
|
151
|
+
options = { :account_type => account_type }
|
152
|
+
self.auth_handler = GData::Auth::ClientLogin.new(service, options)
|
153
|
+
if @clientlogin_url
|
154
|
+
@auth_handler.auth_url = @clientlogin_url
|
155
|
+
end
|
156
|
+
source = GData::Auth::SOURCE_LIB_STRING + @source
|
157
|
+
@auth_handler.get_token(username, password, source, captcha_token, captcha_answer)
|
158
|
+
end
|
159
|
+
|
160
|
+
def authsub_url(next_url, secure = false, session = true, domain = nil,
|
161
|
+
scope = nil)
|
162
|
+
if scope.nil?
|
163
|
+
scope = @authsub_scope
|
164
|
+
end
|
165
|
+
GData::Auth::AuthSub.get_url(next_url, scope, secure, session, domain)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Sets an AuthSub token for the service.
|
169
|
+
def authsub_token=(token)
|
170
|
+
self.auth_handler = GData::Auth::AuthSub.new(token)
|
171
|
+
end
|
172
|
+
|
173
|
+
# Sets a private key to use with AuthSub requests.
|
174
|
+
def authsub_private_key=(key)
|
175
|
+
if @auth_handler.class == GData::Auth::AuthSub
|
176
|
+
@auth_handler.private_key = key
|
177
|
+
else
|
178
|
+
raise Error, "An AuthSub token must be set first."
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Blogger API.
|
20
|
+
class Blogger < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'blogger'
|
24
|
+
options[:authsub_scope] ||= 'http://www.blogger.com/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Book Search Data API.
|
20
|
+
class BookSearch < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'print'
|
24
|
+
options[:authsub_scope] ||= 'http://www.google.com/books/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Calendar Data API.
|
20
|
+
class Calendar < Base
|
21
|
+
|
22
|
+
# Holds on to a session cookie
|
23
|
+
attr_accessor :session_cookie
|
24
|
+
|
25
|
+
def initialize(options = {})
|
26
|
+
options[:clientlogin_service] ||= 'cl'
|
27
|
+
options[:authsub_scope] ||= 'http://www.google.com/calendar/feeds/'
|
28
|
+
super(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Overrides auth_handler= so if the authentication changes,
|
32
|
+
# the session cookie is cleared.
|
33
|
+
def auth_handler=(handler)
|
34
|
+
@session_cookie = nil
|
35
|
+
return super(handler)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Overrides make_request to handle 302 redirects with a session cookie.
|
39
|
+
def make_request(method, url, body = '', retries = 4)
|
40
|
+
response = super(method, url, body)
|
41
|
+
if response.status_code == 302 and retries > 0
|
42
|
+
@session_cookie = response.headers['set-cookie']
|
43
|
+
return self.make_request(method, url, body,
|
44
|
+
retries - 1)
|
45
|
+
else
|
46
|
+
return response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Custom prepare_headers to include the session cookie if it exists
|
51
|
+
def prepare_headers
|
52
|
+
if @session_cookie
|
53
|
+
@headers['cookie'] = @session_cookie
|
54
|
+
end
|
55
|
+
super
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Contacts API.
|
20
|
+
class Contacts < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'cp'
|
24
|
+
options[:authsub_scope] ||= 'http://www.google.com/m8/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Documents List Data API.
|
20
|
+
class DocList < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'writely'
|
24
|
+
options[:authsub_scope] ||= 'http://docs.google.com/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Finance API.
|
20
|
+
class Finance < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'finance'
|
24
|
+
options[:authsub_scope] ||= 'http://finance.google.com/finance/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Google Base API.
|
20
|
+
class GBase < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'gbase'
|
24
|
+
options[:authsub_scope] ||= 'http://www.google.com/base/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the GMail Atom Feed.
|
20
|
+
class GMail < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'mail'
|
24
|
+
options[:authsub_scope] ||= 'https://mail.google.com/mail/feed/atom/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Health API.
|
20
|
+
class Health < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'health'
|
24
|
+
options[:authsub_scope] ||= 'https://www.google.com/health/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Notebook Data API.
|
20
|
+
class Notebook < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'notebook'
|
24
|
+
options[:authsub_scope] ||= 'http://www.google.com/notebook/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Picasa Web Albums API.
|
20
|
+
class Photos < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'lh2'
|
24
|
+
options[:authsub_scope] ||= 'http://picasaweb.google.com/data/'
|
25
|
+
options[:version] ||= '1'
|
26
|
+
super(options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Spreadsheets API.
|
20
|
+
class Spreadsheets < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'wise'
|
24
|
+
options[:authsub_scope] ||= 'http://spreadsheets.google.com/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the Webmaster Tools API.
|
20
|
+
class WebmasterTools < Base
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
options[:clientlogin_service] ||= 'sitemaps'
|
24
|
+
options[:authsub_scope] ||= 'http://www.google.com/webmasters/tools/feeds/'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Copyright (C) 2008 Google Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module GData
|
17
|
+
module Client
|
18
|
+
|
19
|
+
# Client class to wrap working with the YouTube API. Sets some
|
20
|
+
# YouTube-specific options.
|
21
|
+
class YouTube < Base
|
22
|
+
|
23
|
+
# The YouTube developer key being used.
|
24
|
+
attr_accessor :developer_key
|
25
|
+
# The YouTube ClientID being used.
|
26
|
+
attr_accessor :client_id
|
27
|
+
|
28
|
+
def initialize(options = {})
|
29
|
+
options[:clientlogin_service] ||= 'youtube'
|
30
|
+
options[:clientlogin_url] ||= 'https://www.google.com/youtube/accounts/ClientLogin'
|
31
|
+
options[:authsub_scope] ||= 'http://gdata.youtube.com'
|
32
|
+
options[:version] ||= '2'
|
33
|
+
super(options)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Custom prepare_headers to include the developer key and clientID
|
37
|
+
def prepare_headers
|
38
|
+
if @client_id
|
39
|
+
@headers['X-GData-Client'] = @client_id
|
40
|
+
end
|
41
|
+
if @developer_key
|
42
|
+
@headers['X-GData-Key'] = "key=#{@developer_key}"
|
43
|
+
end
|
44
|
+
super
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|