soundcloud 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -42,11 +42,14 @@ It is providing simple methods to handle authorization and to execute HTTP calls
42
42
  client = Soundcloud.new({
43
43
  :client_id => YOUR_CLIENT_ID,
44
44
  :client_secret => YOUR_CLIENT_SECRET,
45
+ :redirect_uri => YOUR_REDIRECT_URI,
45
46
  })
46
47
 
47
- client.authorize_url(:redirect_uri => REDIRECT_URI)
48
- # => "https://soundcloud.com/connect?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=http://host/redirect"
49
- client.exchange_token(:redirect_uri => uri, :code => 'CODE')
48
+ redirect client.authorize_url()
49
+ # the user should be redirected to "https://soundcloud.com/connect?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=YOUR_REDIRECT_URI"
50
+ # after granting access he will be redirected back to YOUR_REDIRECT_URI
51
+ # in your respective handler you can build an exchange token from the transmitted code
52
+ client.exchange_token(:code => params[:code])
50
53
 
51
54
  #### OAuth2 refresh token flow, upload a track and print its link
52
55
  # register a new client which will exchange an existing refresh_token for an access_token
@@ -83,6 +86,13 @@ It is providing simple methods to handle authorization and to execute HTTP calls
83
86
  user_id_to_follow = 123
84
87
  client.put("/me/followings/#{user_id_to_follow}")
85
88
 
89
+ ### Initializing a client with an access token and updating the users profile description
90
+ # initializing a client with an access token
91
+ client = Soundcloud.new(:access_token => SOME_ACCESS_TOKEN)
92
+
93
+ # updating the users profile description
94
+ client.put("/me", :user => {:description => "a new description"})
95
+
86
96
  ## Interface
87
97
  #### Soundcloud.new(options={})
88
98
  Stores the passed options and call exchange_token in case options are passed that allow an exchange of tokens.
@@ -1,6 +1,7 @@
1
1
  require 'httmultiparty'
2
2
  require 'hashie'
3
3
  require 'uri'
4
+ require 'soundcloud/version'
4
5
 
5
6
  class Soundcloud
6
7
  class ResponseError < HTTParty::ResponseError
@@ -75,9 +76,9 @@ class Soundcloud
75
76
  end
76
77
 
77
78
  class UnauthorizedResponseError < ResponseError; end
79
+ USER_AGENT = "SoundCloud Ruby Wrapper #{VERSION}"
78
80
 
79
81
  include HTTMultiParty
80
-
81
82
  CLIENT_ID_PARAM_NAME = :client_id
82
83
  API_SUBHOST = 'api'
83
84
  AUTHORIZE_PATH = '/connect'
@@ -88,6 +89,7 @@ class Soundcloud
88
89
  }
89
90
 
90
91
  attr_accessor :options
92
+ headers({"User-Agent" => USER_AGENT})
91
93
 
92
94
  def initialize(options={})
93
95
  store_options(options)
@@ -100,9 +102,9 @@ class Soundcloud
100
102
  end
101
103
 
102
104
  def get (path, query={}, options={}); handle_response { self.class.get *construct_query_arguments(path, options.merge(:query => query)) } end
103
- def post (path, body={}, options={}); handle_response { self.class.post *construct_query_arguments(path, options.merge(:body => body), :body) } end
104
- def put (path, body={}, options={}); handle_response { self.class.put *construct_query_arguments(path, options.merge(:body => body), :body) } end
105
- def delete(path, query={}, options={}); handle_response { self.class.delete *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
106
108
  def head (path, query={}, options={}); handle_response { self.class.head *construct_query_arguments(path, options.merge(:query => query)) } end
107
109
 
108
110
  # accessors for options
@@ -213,4 +215,3 @@ end
213
215
 
214
216
  require 'soundcloud/array_response_wrapper'
215
217
  require 'soundcloud/hash_response_wrapper'
216
- require 'soundcloud/version'
@@ -1,3 +1,3 @@
1
1
  class Soundcloud
2
- VERSION = '0.2.7'
2
+ VERSION = '0.2.8'
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: soundcloud
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.7
5
+ version: 0.2.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Johannes Wagener
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-25 00:00:00 +02:00
13
+ date: 2011-10-07 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency