soundcloud 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/soundcloud.rb +13 -13
- data/lib/soundcloud/version.rb +1 -1
- metadata +2 -2
data/lib/soundcloud.rb
CHANGED
@@ -74,7 +74,7 @@ class Soundcloud
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
class UnauthorizedResponseError < ResponseError; end
|
79
79
|
USER_AGENT = "SoundCloud Ruby Wrapper #{VERSION}"
|
80
80
|
|
@@ -101,11 +101,11 @@ class Soundcloud
|
|
101
101
|
raise ArgumentError, "At least a client_id or an access_token must be present" if client_id.nil? && access_token.nil?
|
102
102
|
end
|
103
103
|
|
104
|
-
def get (path, query={}, options={}); handle_response { self.class.get
|
105
|
-
def post (path, body={}, options={}); handle_response { self.class.post
|
106
|
-
def put (path, body={}, options={}); handle_response { self.class.put
|
107
|
-
def delete(path, query={}, options={}); handle_response { self.class.delete
|
108
|
-
def head (path, query={}, options={}); handle_response { self.class.head
|
104
|
+
def get (path, query={}, options={}); handle_response { self.class.get( *construct_query_arguments(path, options.merge(:query => query)) ) } end
|
105
|
+
def post (path, body={}, options={}); handle_response { self.class.post( *construct_query_arguments(path, options.merge(:body => body), :body) ) } end
|
106
|
+
def put (path, body={}, options={}); handle_response { self.class.put( *construct_query_arguments(path, options.merge(:body => body), :body) ) } end
|
107
|
+
def delete(path, query={}, options={}); handle_response { self.class.delete( *construct_query_arguments(path, options.merge(:query => query)) ) } end
|
108
|
+
def head (path, query={}, options={}); handle_response { self.class.head( *construct_query_arguments(path, options.merge(:query => query)) ) } end
|
109
109
|
|
110
110
|
# accessors for options
|
111
111
|
def client_id; @options[:client_id]; end
|
@@ -119,12 +119,12 @@ class Soundcloud
|
|
119
119
|
(expires_at.nil? || expires_at < Time.now)
|
120
120
|
end
|
121
121
|
|
122
|
-
def use_ssl?;
|
122
|
+
def use_ssl?;
|
123
123
|
!! @options[:use_ssl?] || access_token
|
124
124
|
end
|
125
125
|
|
126
126
|
def site; @options[:site]; end
|
127
|
-
|
127
|
+
|
128
128
|
def host; site; end
|
129
129
|
def api_host; [API_SUBHOST, host].join('.'); end
|
130
130
|
|
@@ -137,7 +137,7 @@ class Soundcloud
|
|
137
137
|
store_options(options)
|
138
138
|
"https://#{host}#{AUTHORIZE_PATH}?response_type=code_and_token&client_id=#{client_id}&redirect_uri=#{URI.escape redirect_uri}&#{additional_params}"
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
def exchange_token(options={})
|
142
142
|
store_options(options)
|
143
143
|
raise ArgumentError, 'client_id and client_secret is required to retrieve an access_token' if client_id.nil? || client_secret.nil?
|
@@ -172,14 +172,14 @@ private
|
|
172
172
|
# TODO it should return the original
|
173
173
|
handle_response(false, &block)
|
174
174
|
else
|
175
|
-
#raise ResponseError.new(response), ResponseError.message(response)
|
176
175
|
raise ResponseError.new(response)
|
177
|
-
#raise ResponseError.from(response)
|
178
176
|
end
|
179
177
|
elsif response.is_a? Hash
|
180
178
|
HashResponseWrapper.new(response)
|
181
179
|
elsif response.is_a? Array
|
182
180
|
ArrayResponseWrapper.new(response)
|
181
|
+
elsif response && response.success?
|
182
|
+
response
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
@@ -191,12 +191,12 @@ private
|
|
191
191
|
@options ||= DEFAULT_OPTIONS.dup
|
192
192
|
@options.merge! options
|
193
193
|
end
|
194
|
-
|
194
|
+
|
195
195
|
|
196
196
|
def construct_query_arguments(path_or_uri, options={}, body_or_query=:query)
|
197
197
|
uri = URI.parse(path_or_uri)
|
198
198
|
path = uri.path
|
199
|
-
|
199
|
+
|
200
200
|
scheme = use_ssl? ? 'https' : 'http'
|
201
201
|
options = options.dup
|
202
202
|
options[body_or_query] ||= {}
|
data/lib/soundcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|