chdorner-gdocsapi-wrapper 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
data/gdocsapi-wrapper.gemspec
CHANGED
data/lib/gdocsapi-wrapper.rb
CHANGED
@@ -19,29 +19,5 @@
|
|
19
19
|
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
20
|
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# Identifying the application which uses the GDocsAPIWrapper
|
26
|
-
attr_accessor :source
|
27
|
-
attr_accessor :login_handler
|
28
|
-
|
29
|
-
def initialize(options = {})
|
30
|
-
options.each do |key, value|
|
31
|
-
self.send("#{key}=", value)
|
32
|
-
end
|
33
|
-
|
34
|
-
@source ||= 'UndefinedApplication'
|
35
|
-
end
|
36
|
-
|
37
|
-
# Performs login on GDocsAPIWrapper:Auth
|
38
|
-
def login(username, password)
|
39
|
-
source = GDocsAPIWrapper::Auth::SOURCE_PREFIX + @source
|
40
|
-
|
41
|
-
@login_handler = GDocsAPIWrapper::Auth::Login.new
|
42
|
-
@login_handler.perform_login(username, password, source)
|
43
|
-
|
44
|
-
puts 'Token: ' + @login_handler.token
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
22
|
+
require 'gdocsapi-wrapper/client/client'
|
23
|
+
require 'gdocsapi-wrapper/client/service'
|
@@ -29,6 +29,7 @@ module GDocsAPIWrapper
|
|
29
29
|
attr_accessor :url
|
30
30
|
attr_accessor :body
|
31
31
|
attr_accessor :method
|
32
|
+
attr_accessor :headers
|
32
33
|
|
33
34
|
def initialize(url, options = {})
|
34
35
|
@url = url
|
@@ -37,6 +38,7 @@ module GDocsAPIWrapper
|
|
37
38
|
end
|
38
39
|
|
39
40
|
@method ||= :get
|
41
|
+
@headers ||= {}
|
40
42
|
end
|
41
43
|
|
42
44
|
def send_request
|
@@ -69,7 +71,11 @@ module GDocsAPIWrapper
|
|
69
71
|
else
|
70
72
|
req.body = @body.to_s
|
71
73
|
end
|
72
|
-
|
74
|
+
|
75
|
+
@headers.each do |key, value|
|
76
|
+
req[key] = value
|
77
|
+
end
|
78
|
+
req['GData-Version'] ||= '2.0'
|
73
79
|
|
74
80
|
res = http.request(req)
|
75
81
|
|