Class: Soundcloud2::Users

Inherits:
Client
  • Object
show all
Defined in:
lib/soundcloud2/users.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Client

#groups, #method_missing, #playlists, #tracks

Constructor Details

#initialize(*args) ⇒ Users

Initialize on the Soundcloud::Client class



6
7
8
# File 'lib/soundcloud2/users.rb', line 6

def initialize(*args)
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Soundcloud2::Client

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



3
4
5
# File 'lib/soundcloud2/users.rb', line 3

def api_key
  @api_key
end

#connObject (readonly)

Returns the value of attribute conn.



3
4
5
# File 'lib/soundcloud2/users.rb', line 3

def conn
  @conn
end

Instance Method Details

#users(*args) ⇒ Object

GET /users/id a user



11
12
13
14
15
# File 'lib/soundcloud2/users.rb', line 11

def users(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/users/#{args[0]}.json") { |req| req.params = options }
  args.nil? ? response.body.send(sym) : response.body
end

#users_comments(*args) ⇒ Object

GET /users/id/comments list of comments from this user



48
49
50
51
52
# File 'lib/soundcloud2/users.rb', line 48

def users_comments(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/users/#{args[0]}/comments.json") { |req| req.params = options }
  args.nil? ? response.body.send(sym) : response.body
end

#users_favorites(*args) ⇒ Object

GET /users/id/favorites users favorites GET /users/id/favorites/id track favorited by the user



56
57
58
59
60
# File 'lib/soundcloud2/users.rb', line 56

def users_favorites(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  args[1].nil? ? (response = conn.get("/users/#{args[0]}/favorites.json") { |req| req.params = options }) : (response = conn.get("/users/#{args[0]}/favorites/#{args[1]}.json") { |req| req.params = options })
  args.nil? ? response.body.send(sym) : response.body
end

#users_followers(*args) ⇒ Object

GET /users/id/followers a users followers GET /users/id/followers/id user who is following the user



41
42
43
44
45
# File 'lib/soundcloud2/users.rb', line 41

def users_followers(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  args[1].nil? ? (response = conn.get("/users/#{args[0]}/followers.json") { |req| req.params = options }) : (response = conn.get("/users/#{args[0]}/followers/#{args[1]}.json") { |req| req.params = options })
  args.nil? ? response.body.send(sym) : response.body
end

#users_followings(*args) ⇒ Object

GET /users/id/followings a users followings GET /users/id/followings/id a user who is followed by the user



33
34
35
36
37
# File 'lib/soundcloud2/users.rb', line 33

def users_followings(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  args[1].nil? ? (response = conn.get("/users/#{args[0]}/followings.json") { |req| req.params = options }) : (response = conn.get("/users/#{args[0]}/followings/#{args[1]}.json") { |req| req.params = options })
  args.nil? ? response.body.send(sym) : response.body
end

#users_groups(*args) ⇒ Object

GET /users/id/groups list of joined groups



63
64
65
66
67
# File 'lib/soundcloud2/users.rb', line 63

def users_groups(*args)
			options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/users/#{args[0]}/groups.json") { |req| req.params = options }
  args.nil? ? response.body.send(sym) : response.body
end

#users_playlists(*args) ⇒ Object

GET /users/id/playlists list of playlists (sets) of the user



25
26
27
28
29
# File 'lib/soundcloud2/users.rb', line 25

def users_playlists(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/users/#{args[0]}/playlists.json") { |req| req.params = options }
  args.nil? ? response.body.send(sym) : response.body
end

#users_tracks(*args) ⇒ Object

GET /users/id/tracks list of tracks of the user



18
19
20
21
22
# File 'lib/soundcloud2/users.rb', line 18

def users_tracks(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/users/#{args[0]}/tracks.json") { |req| req.params = options }
  args.nil? ? response.body.send(sym) : response.body
end