infomeme_client 0.1.4 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- metadata +26 -165
- data/.document +0 -5
- data/.gitignore +0 -21
- data/LICENSE +0 -20
- data/README.rdoc +0 -8
- data/Rakefile +0 -55
- data/VERSION +0 -1
- data/lib/infomeme_client.rb +0 -22
- data/lib/infomeme_client/base.rb +0 -77
- data/lib/infomeme_client/communication.rb +0 -75
- data/lib/infomeme_client/entity_hash.rb +0 -66
- data/lib/infomeme_client/entity_hash/comment.rb +0 -2
- data/lib/infomeme_client/entity_hash/invoice.rb +0 -2
- data/lib/infomeme_client/entity_hash/meme.rb +0 -45
- data/lib/infomeme_client/entity_hash/meme_type.rb +0 -2
- data/lib/infomeme_client/entity_hash/transaction.rb +0 -2
- data/lib/infomeme_client/entity_hash/user.rb +0 -2
- data/lib/infomeme_client/errors.rb +0 -22
- data/lib/infomeme_client/functions.rb +0 -16
- data/lib/infomeme_client/functions/meme.rb +0 -23
- data/lib/infomeme_client/functions/user.rb +0 -79
- data/lib/infomeme_client/functions/user_meme.rb +0 -127
- data/lib/infomeme_client/functions/user_order.rb +0 -31
- data/lib/infomeme_client/meme_application.rb +0 -18
- data/lib/infomeme_client/permissions.rb +0 -22
- data/lib/infomeme_client/response.rb +0 -52
- data/test/fixtures/memes/comments.json +0 -1
- data/test/fixtures/memes/meme.json +0 -1
- data/test/fixtures/memes/memes.json +0 -1
- data/test/fixtures/memes/types.json +0 -1
- data/test/fixtures/oauth/access_token.json +0 -1
- data/test/fixtures/oauth/authorize.json +0 -1
- data/test/fixtures/oauth/permissions.json +0 -1
- data/test/fixtures/oauth/request_token.json +0 -1
- data/test/fixtures/oauth/verify_access.json +0 -1
- data/test/fixtures/response/error.json +0 -1
- data/test/fixtures/response/ok.json +0 -1
- data/test/fixtures/response/test.json +0 -1
- data/test/fixtures/response/test_extract.json +0 -1
- data/test/fixtures/users/invoice.json +0 -1
- data/test/fixtures/users/invoices.json +0 -1
- data/test/fixtures/users/memes.json +0 -1
- data/test/fixtures/users/order_paypal.json +0 -1
- data/test/fixtures/users/permissions.json +0 -1
- data/test/fixtures/users/transactions.json +0 -1
- data/test/fixtures/users/user.json +0 -1
- data/test/fixtures/users/user_public.json +0 -1
- data/test/helper.rb +0 -69
- data/test/test_authorization.rb +0 -56
- data/test/test_communication.rb +0 -46
- data/test/test_entity_hash.rb +0 -15
- data/test/test_meme_functions.rb +0 -46
- data/test/test_permissions.rb +0 -25
- data/test/test_user_functions.rb +0 -15
- data/test/test_user_meme_functions.rb +0 -47
- data/test/test_user_order_functions.rb +0 -45
metadata
CHANGED
@@ -1,185 +1,46 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: infomeme_client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 4
|
10
|
-
version: 0.1.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Infomeme Ltd.
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2010-09-04 00:00:00 +02:00
|
12
|
+
date: 2011-03-24 00:00:00.000000000 +01:00
|
19
13
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
33
|
-
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: json
|
37
|
-
prerelease: false
|
38
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 3
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
47
|
-
type: :runtime
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: multipart-post
|
51
|
-
prerelease: false
|
52
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
|
-
requirements:
|
55
|
-
- - ">="
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
hash: 3
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
version: "0"
|
61
|
-
type: :runtime
|
62
|
-
version_requirements: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: mime-types
|
65
|
-
prerelease: false
|
66
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
|
-
requirements:
|
69
|
-
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
hash: 3
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
version: "0"
|
75
|
-
type: :runtime
|
76
|
-
version_requirements: *id004
|
77
|
-
description: A RubyGem for implementing both Infomeme client and meme applications.
|
78
|
-
email: infomeme@infomeme.com
|
14
|
+
dependencies: []
|
15
|
+
description: Coming soon...
|
16
|
+
email: gem_info@infomeme.com
|
79
17
|
executables: []
|
80
|
-
|
81
18
|
extensions: []
|
82
|
-
|
83
|
-
|
84
|
-
- LICENSE
|
85
|
-
- README.rdoc
|
86
|
-
files:
|
87
|
-
- .document
|
88
|
-
- .gitignore
|
89
|
-
- LICENSE
|
90
|
-
- README.rdoc
|
91
|
-
- Rakefile
|
92
|
-
- VERSION
|
93
|
-
- lib/infomeme_client.rb
|
94
|
-
- lib/infomeme_client/base.rb
|
95
|
-
- lib/infomeme_client/communication.rb
|
96
|
-
- lib/infomeme_client/entity_hash.rb
|
97
|
-
- lib/infomeme_client/entity_hash/comment.rb
|
98
|
-
- lib/infomeme_client/entity_hash/invoice.rb
|
99
|
-
- lib/infomeme_client/entity_hash/meme.rb
|
100
|
-
- lib/infomeme_client/entity_hash/meme_type.rb
|
101
|
-
- lib/infomeme_client/entity_hash/transaction.rb
|
102
|
-
- lib/infomeme_client/entity_hash/user.rb
|
103
|
-
- lib/infomeme_client/errors.rb
|
104
|
-
- lib/infomeme_client/functions.rb
|
105
|
-
- lib/infomeme_client/functions/meme.rb
|
106
|
-
- lib/infomeme_client/functions/user.rb
|
107
|
-
- lib/infomeme_client/functions/user_meme.rb
|
108
|
-
- lib/infomeme_client/functions/user_order.rb
|
109
|
-
- lib/infomeme_client/meme_application.rb
|
110
|
-
- lib/infomeme_client/permissions.rb
|
111
|
-
- lib/infomeme_client/response.rb
|
112
|
-
- test/fixtures/memes/comments.json
|
113
|
-
- test/fixtures/memes/meme.json
|
114
|
-
- test/fixtures/memes/memes.json
|
115
|
-
- test/fixtures/memes/types.json
|
116
|
-
- test/fixtures/oauth/access_token.json
|
117
|
-
- test/fixtures/oauth/authorize.json
|
118
|
-
- test/fixtures/oauth/permissions.json
|
119
|
-
- test/fixtures/oauth/request_token.json
|
120
|
-
- test/fixtures/oauth/verify_access.json
|
121
|
-
- test/fixtures/response/error.json
|
122
|
-
- test/fixtures/response/ok.json
|
123
|
-
- test/fixtures/response/test.json
|
124
|
-
- test/fixtures/response/test_extract.json
|
125
|
-
- test/fixtures/users/invoice.json
|
126
|
-
- test/fixtures/users/invoices.json
|
127
|
-
- test/fixtures/users/memes.json
|
128
|
-
- test/fixtures/users/order_paypal.json
|
129
|
-
- test/fixtures/users/permissions.json
|
130
|
-
- test/fixtures/users/transactions.json
|
131
|
-
- test/fixtures/users/user.json
|
132
|
-
- test/fixtures/users/user_public.json
|
133
|
-
- test/helper.rb
|
134
|
-
- test/test_authorization.rb
|
135
|
-
- test/test_communication.rb
|
136
|
-
- test/test_entity_hash.rb
|
137
|
-
- test/test_meme_functions.rb
|
138
|
-
- test/test_permissions.rb
|
139
|
-
- test/test_user_functions.rb
|
140
|
-
- test/test_user_meme_functions.rb
|
141
|
-
- test/test_user_order_functions.rb
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files: []
|
142
21
|
has_rdoc: true
|
143
|
-
homepage: https://
|
22
|
+
homepage: https://github.com/Infomeme/infomeme_client
|
144
23
|
licenses: []
|
145
|
-
|
146
24
|
post_install_message:
|
147
|
-
rdoc_options:
|
148
|
-
|
149
|
-
require_paths:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
150
27
|
- lib
|
151
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
29
|
none: false
|
153
|
-
requirements:
|
154
|
-
- -
|
155
|
-
- !ruby/object:Gem::Version
|
156
|
-
|
157
|
-
|
158
|
-
- 0
|
159
|
-
version: "0"
|
160
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
35
|
none: false
|
162
|
-
requirements:
|
163
|
-
- -
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
|
166
|
-
segments:
|
167
|
-
- 0
|
168
|
-
version: "0"
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
169
40
|
requirements: []
|
170
|
-
|
171
41
|
rubyforge_project:
|
172
|
-
rubygems_version: 1.3
|
42
|
+
rubygems_version: 1.5.3
|
173
43
|
signing_key:
|
174
44
|
specification_version: 3
|
175
45
|
summary: A RubyGem for implementing both Infomeme client and meme applications.
|
176
|
-
test_files:
|
177
|
-
- test/helper.rb
|
178
|
-
- test/test_authorization.rb
|
179
|
-
- test/test_communication.rb
|
180
|
-
- test/test_entity_hash.rb
|
181
|
-
- test/test_meme_functions.rb
|
182
|
-
- test/test_permissions.rb
|
183
|
-
- test/test_user_functions.rb
|
184
|
-
- test/test_user_meme_functions.rb
|
185
|
-
- test/test_user_order_functions.rb
|
46
|
+
test_files: []
|
data/.document
DELETED
data/.gitignore
DELETED
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 Infomeme Ltd.
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
data/Rakefile
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "infomeme_client"
|
8
|
-
gem.summary = "A RubyGem for implementing both Infomeme client and meme applications."
|
9
|
-
gem.description = gem.summary
|
10
|
-
gem.email = "infomeme@infomeme.com"
|
11
|
-
gem.homepage = "https://api.infomeme.com"
|
12
|
-
gem.authors = ["Infomeme Ltd."]
|
13
|
-
gem.add_dependency "oauth"
|
14
|
-
gem.add_dependency "json"
|
15
|
-
gem.add_dependency "multipart-post"
|
16
|
-
gem.add_dependency "mime-types"
|
17
|
-
end
|
18
|
-
Jeweler::GemcutterTasks.new
|
19
|
-
rescue LoadError
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
-
end
|
22
|
-
|
23
|
-
require 'rake/testtask'
|
24
|
-
Rake::TestTask.new(:test) do |test|
|
25
|
-
test.libs << 'lib' << 'test'
|
26
|
-
test.pattern = 'test/**/test_*.rb'
|
27
|
-
test.verbose = true
|
28
|
-
end
|
29
|
-
|
30
|
-
begin
|
31
|
-
require 'rcov/rcovtask'
|
32
|
-
Rcov::RcovTask.new do |test|
|
33
|
-
test.libs << 'test'
|
34
|
-
test.pattern = 'test/**/test_*.rb'
|
35
|
-
test.verbose = true
|
36
|
-
end
|
37
|
-
rescue LoadError
|
38
|
-
task :rcov do
|
39
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
task :test => :check_dependencies
|
44
|
-
|
45
|
-
task :default => :test
|
46
|
-
|
47
|
-
require 'rake/rdoctask'
|
48
|
-
Rake::RDocTask.new do |rdoc|
|
49
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
-
|
51
|
-
rdoc.rdoc_dir = 'rdoc'
|
52
|
-
rdoc.title = "infomeme_client #{version}"
|
53
|
-
rdoc.rdoc_files.include('README*')
|
54
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.4
|
data/lib/infomeme_client.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require "oauth"
|
2
|
-
require "json"
|
3
|
-
require "net/http/post/multipart"
|
4
|
-
require "mime/types"
|
5
|
-
|
6
|
-
class InfomemeClient
|
7
|
-
require "infomeme_client/errors"
|
8
|
-
|
9
|
-
autoload :EntityHash, "infomeme_client/entity_hash"
|
10
|
-
autoload :Response, "infomeme_client/response"
|
11
|
-
autoload :Base, "infomeme_client/base"
|
12
|
-
autoload :Communication, "infomeme_client/communication"
|
13
|
-
autoload :Permissions, "infomeme_client/permissions"
|
14
|
-
autoload :Functions, "infomeme_client/functions"
|
15
|
-
|
16
|
-
autoload :MemeApplication, "infomeme_client/meme_application"
|
17
|
-
|
18
|
-
include Base
|
19
|
-
include Communication
|
20
|
-
include Permissions
|
21
|
-
include Functions
|
22
|
-
end
|
data/lib/infomeme_client/base.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
module InfomemeClient::Base
|
2
|
-
def initialize(options = {})
|
3
|
-
self.consumer = OAuth::Consumer.new(options[:api_key] || ::INFOMEME_API_KEY, options[:api_secret] || ::INFOMEME_API_SECRET, :site => options[:site] || ::INFOMEME_API_SITE)
|
4
|
-
self.default_language = options[:language] || "en"
|
5
|
-
case
|
6
|
-
when options.key?(:token) && options.key?(:secret) then authorize_with_token(options[:token], options[:secret])
|
7
|
-
when options.key?(:login) && options.key?(:password) then authorize_with_credentials(options[:login], options[:password])
|
8
|
-
else deauthorize
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def request_authorization
|
13
|
-
response = handle_response :get, consumer.request_token_url
|
14
|
-
response.request_token
|
15
|
-
end
|
16
|
-
|
17
|
-
def authorize_url(token, permissions = [])
|
18
|
-
"https://infomeme.com/authorize?token=#{token}&permissions=#{permissions.join(',')}"
|
19
|
-
end
|
20
|
-
|
21
|
-
def authorize_with_verifier(token, secret, verifier)
|
22
|
-
req_token = OAuth::RequestToken.new(consumer, token, secret)
|
23
|
-
response = token_request(req_token, :get, finalize_get_url(consumer.access_token_url, {:oauth_verifier => verifier})) #do request with request_token
|
24
|
-
return false if response.error?
|
25
|
-
authorize_with_token(response.access_token.token, response.access_token.secret)
|
26
|
-
end
|
27
|
-
|
28
|
-
def authorize_with_token(token, secret)
|
29
|
-
access_token = OAuth::AccessToken.new(consumer, token, secret)
|
30
|
-
response = token_request(access_token, :get, "/oauth/verify_access")
|
31
|
-
return false if response.error?
|
32
|
-
self.verified_user = response.user_id
|
33
|
-
self.token = access_token
|
34
|
-
refresh_user_data
|
35
|
-
self
|
36
|
-
end
|
37
|
-
|
38
|
-
def authorize_with_credentials(login, password, permissions = nil)
|
39
|
-
req_token = request_authorization
|
40
|
-
response = put(consumer.authorize_url, {:oauth_token => req_token.token, :login => login, :password => password, :permissions => permissions || all_permissions.collect {|perm| perm.id}})
|
41
|
-
return false if response.error?
|
42
|
-
authorize_with_verifier(req_token.token, req_token.secret, response.verifier)
|
43
|
-
end
|
44
|
-
|
45
|
-
def deauthorize
|
46
|
-
self.verified_user = nil
|
47
|
-
self.token = OAuth::AccessToken.new(consumer)
|
48
|
-
refresh_user_data
|
49
|
-
self
|
50
|
-
end
|
51
|
-
|
52
|
-
def authorized?
|
53
|
-
! verified_user.nil?
|
54
|
-
end
|
55
|
-
|
56
|
-
def credentials(just = nil)
|
57
|
-
creds = {
|
58
|
-
:login => verified_user,
|
59
|
-
:token => token.token,
|
60
|
-
:secret => token.secret,
|
61
|
-
}
|
62
|
-
creds.key?(just) ? creds[just] : creds
|
63
|
-
end
|
64
|
-
|
65
|
-
def inspect
|
66
|
-
@all_permissions ||= all_permissions
|
67
|
-
"#<#{self.class.name}: #{authorized? ? credentials.merge({:permissions => (@all_permissions || []).select {|perm| has_permission?(perm.id)}.collect {|perm| perm.name}}).inspect : 'not authorized'}>"
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
attr_accessor :consumer, :token, :verified_user
|
72
|
-
|
73
|
-
def refresh_user_data
|
74
|
-
refresh_settings
|
75
|
-
refresh_permissions
|
76
|
-
end
|
77
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module InfomemeClient::Communication
|
2
|
-
def get(path, headers = {})
|
3
|
-
request(:get, path, headers)
|
4
|
-
end
|
5
|
-
|
6
|
-
def post(path, body = "", headers = {})
|
7
|
-
request(:post, path, body, headers)
|
8
|
-
end
|
9
|
-
|
10
|
-
def put(path, body = "", headers = {})
|
11
|
-
request(:put, path, body, headers)
|
12
|
-
end
|
13
|
-
|
14
|
-
def request(method, path, *args)
|
15
|
-
token_request(token, method, path, *args)
|
16
|
-
end
|
17
|
-
|
18
|
-
def handle_response(method, path, *args, &block)
|
19
|
-
response = request(method, path, *args)
|
20
|
-
response.raise_error
|
21
|
-
if block_given?
|
22
|
-
if block.arity == 1
|
23
|
-
yield response
|
24
|
-
else
|
25
|
-
yield unless response.error?
|
26
|
-
end
|
27
|
-
else
|
28
|
-
response
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def extract_from_response(extract, method, path, *args)
|
33
|
-
handle_response(method, path, *args) do |resp|
|
34
|
-
resp.extract(extract) unless resp.error?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def extract_or_response(extract, method, path, options, headers = {})
|
39
|
-
no_extract = options[:no_extract] || false
|
40
|
-
options.delete(:no_extract)
|
41
|
-
if [:put, :post].include?(method.to_sym)
|
42
|
-
args = [method, path, options, headers]
|
43
|
-
else
|
44
|
-
args = [method, finalize_get_url(path, options), headers]
|
45
|
-
end
|
46
|
-
if no_extract
|
47
|
-
handle_response *args
|
48
|
-
else
|
49
|
-
extract_from_response *args.unshift(extract)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
def token_request(token, method, path, *args)
|
55
|
-
body = [:post, :put].include?(method.to_sym) ? (args.shift || {}) : {}
|
56
|
-
headers = args.shift || {}
|
57
|
-
headers.store("Accept", "application/json") #override to use json
|
58
|
-
if [:post, :put].include?(method.to_sym) && (! headers.key?("Content-Type") || headers["Content-Type"] == "application/json")
|
59
|
-
body = JSON.generate(body) unless body.is_a?(String)
|
60
|
-
headers.store("Content-Type", "application/json")
|
61
|
-
end
|
62
|
-
args.unshift headers
|
63
|
-
args.unshift body if [:post, :put].include?(method.to_sym)
|
64
|
-
begin
|
65
|
-
resp = token.request(method, path, *args).body
|
66
|
-
InfomemeClient::Response.new JSON.parse(resp)
|
67
|
-
rescue => e
|
68
|
-
InfomemeClient::Response.new e
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def finalize_get_url(url, params)
|
73
|
-
url + (url.include?("?") ? "&" : "?") + params.collect {|key, val| "#{key.to_s}=#{val.to_s}"}.join("&")
|
74
|
-
end
|
75
|
-
end
|