Module: OfficialFM::Users
- Included in:
- Client
- Defined in:
- lib/officialfm/users.rb
Instance Method Summary collapse
-
#dropbox ⇒ Hashie::Mash
Retrieve dropbox tracks of the logged in user.
-
#newsfeed ⇒ Hashie::Mash
Retrieve events of the logged in user’s newsfeed.
-
#own_playlists ⇒ Hashie::Mash
Retrieve playlists of the logged in user.
-
#own_tracks ⇒ Hashie::Mash
Retrieve tracks of the logged in user.
-
#picture!(path, mime) ⇒ Hashie::Mash
Upload a picture for authenticated user.
-
#profile ⇒ Hashie::Mash
Retrieve information about the logged in user.
-
#subscribe!(user_id) ⇒ Hashie::Mash
Subscribe the logged in user to a given user.
-
#unsubscribe!(user_id) ⇒ Hashie::Mash
Unsubscribe the logged in user from a given user.
-
#update_profile!(data = {}) ⇒ Hashie::Mash
Update information of the logged in user.
-
#user(user_id) ⇒ Hashie::Mash
Retrieve information about a specific user.
-
#user_contacts(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the contacts of a given user.
-
#user_playlists(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the playlists of a given user.
-
#user_subscribers(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the subscribers of a given user.
-
#user_subscriptions(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the subscriptions of a given user.
-
#user_tracks(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the tracks of a given user.
-
#users(search_param, options = {}) ⇒ Hashie::Mash
Search for users.
-
#voted_playlists(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the playlists a given user has voted for.
-
#voted_tracks(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the tracks a given user has voted for.
Instance Method Details
#dropbox ⇒ Hashie::Mash
Retrieve dropbox tracks of the logged in user
150 151 152 153 154 155 156 157 158 |
# File 'lib/officialfm/users.rb', line 150 def dropbox check_auth :dropbox response = connection.post do |req| req.url '/user/dropbox' req.body = { :format => @format } end response end |
#newsfeed ⇒ Hashie::Mash
Retrieve events of the logged in user’s newsfeed
176 177 178 179 180 181 182 183 184 |
# File 'lib/officialfm/users.rb', line 176 def newsfeed check_auth :newsfeed response = connection.post do |req| req.url '/user/newsfeed' req.body = { :format => @format } end response end |
#own_playlists ⇒ Hashie::Mash
Retrieve playlists of the logged in user
163 164 165 166 167 168 169 170 171 |
# File 'lib/officialfm/users.rb', line 163 def own_playlists check_auth :own_playlists response = connection.post do |req| req.url '/user/playlists' req.body = { :format => @format } end response end |
#own_tracks ⇒ Hashie::Mash
Retrieve tracks of the logged in user
137 138 139 140 141 142 143 144 145 |
# File 'lib/officialfm/users.rb', line 137 def own_tracks check_auth :own_tracks response = connection.post do |req| req.url '/user/tracks' req.body = { :format => @format } end response end |
#picture!(path, mime) ⇒ Hashie::Mash
Upload a picture for authenticated user
239 240 241 242 243 244 245 246 247 |
# File 'lib/officialfm/users.rb', line 239 def picture! (path, mime) check_auth :picture response = connection.post do |req| req.url "/user/picture" req.body = { :file => Faraday::UploadIO.new(path, mime), :format => @format } end response end |
#profile ⇒ Hashie::Mash
Retrieve information about the logged in user
124 125 126 127 128 129 130 131 132 |
# File 'lib/officialfm/users.rb', line 124 def profile check_auth :profile response = connection.post do |req| req.url '/user/profile' req.body = { :format => @format } end response.body[0] end |
#subscribe!(user_id) ⇒ Hashie::Mash
Subscribe the logged in user to a given user
210 211 212 213 214 215 216 217 218 |
# File 'lib/officialfm/users.rb', line 210 def subscribe! (user_id) check_auth :subscribe response = connection.post do |req| req.url "/user/subscribe/#{user_id}" req.body = { :format => @format } end response end |
#unsubscribe!(user_id) ⇒ Hashie::Mash
Unsubscribe the logged in user from a given user
224 225 226 227 228 229 230 231 232 |
# File 'lib/officialfm/users.rb', line 224 def unsubscribe! (user_id) check_auth :unsubscribe response = connection.post do |req| req.url "/user/unsubscribe/#{user_id}" req.body = { :format => @format } end response end |
#update_profile!(data = {}) ⇒ Hashie::Mash
Update information of the logged in user
196 197 198 199 200 201 202 203 204 |
# File 'lib/officialfm/users.rb', line 196 def update_profile! (data = {}) check_auth :update response = connection.put do |req| req.url '/user/update' req.body = { :format => @format }.merge(data) end response end |
#user(user_id) ⇒ Hashie::Mash
Retrieve information about a specific user
22 23 24 25 26 27 |
# File 'lib/officialfm/users.rb', line 22 def user(user_id) response = connection.get do |req| req.url "/user/#{user_id}", simple_params end response.body[0] end |
#user_contacts(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the contacts of a given user
86 87 88 89 90 91 |
# File 'lib/officialfm/users.rb', line 86 def user_contacts(user_id, ={}) response = connection.get do |req| req.url "/user/#{user_id}/contacts", simple_params() end response.body end |
#user_playlists(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the playlists of a given user
61 62 63 64 65 66 |
# File 'lib/officialfm/users.rb', line 61 def user_playlists(user_id, ={}) response = connection.get do |req| req.url "/user/#{user_id}/playlists", simple_params() end response.body end |
#user_subscribers(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the subscribers of a given user
98 99 100 101 102 103 |
# File 'lib/officialfm/users.rb', line 98 def user_subscribers(user_id, ={}) response = connection.get do |req| req.url "/user/#{user_id}/subscribers", simple_params() end response.body end |
#user_subscriptions(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the subscriptions of a given user
110 111 112 113 114 115 |
# File 'lib/officialfm/users.rb', line 110 def user_subscriptions(user_id, ={}) response = connection.get do |req| req.url "/user/#{user_id}/subscriptions", simple_params() end response.body end |
#user_tracks(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the tracks of a given user
35 36 37 38 39 40 |
# File 'lib/officialfm/users.rb', line 35 def user_tracks(user_id, ={}) response = connection.get do |req| req.url "/user/#{user_id}/tracks", simple_params() end response.body end |
#users(search_param, options = {}) ⇒ Hashie::Mash
Search for users
11 12 13 14 15 16 |
# File 'lib/officialfm/users.rb', line 11 def users(search_param, ={}) response = connection.get do |req| req.url "/search/users/#{CGI::escape(search_param)}", simple_params() end response.body end |
#voted_playlists(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the playlists a given user has voted for
74 75 76 77 78 79 |
# File 'lib/officialfm/users.rb', line 74 def voted_playlists(user_id, ={}) response = connection.get do |req| req.url "/user/#{user_id}/voted_playlists", simple_params() end response.body end |
#voted_tracks(user_id, options = {}) ⇒ Hashie::Mash
Retrieve a list of the tracks a given user has voted for
48 49 50 51 52 53 |
# File 'lib/officialfm/users.rb', line 48 def voted_tracks(user_id, ={}) response = connection.get do |req| req.url "/user/#{user_id}/voted_tracks", simple_params() end response.body end |