Class: Soundcloud2::Client

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

Direct Known Subclasses

Comments, Groups, Playlists, Tracks, Users

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
# File 'lib/soundcloud2.rb', line 10

def initialize(*args)
  options = args.extract_options!
  @api_key = args[0]
  @conn = Faraday.new(:url => "https://api.soundcloud.com/") do |builder|
    builder.use Faraday::Response::Mashify
    builder.use Faraday::Response::ParseJson
    builder.adapter Faraday.default_adapter
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



134
135
136
137
138
# File 'lib/soundcloud2.rb', line 134

def method_missing(sym, *args, &block)
  options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/#{sym.to_s}.json") { |req| req.params = options }
  args.nil? ? response.body.send(sym) : response.body
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/soundcloud2.rb', line 8

def api_key
  @api_key
end

#connObject (readonly)

Returns the value of attribute conn.



8
9
10
# File 'lib/soundcloud2.rb', line 8

def conn
  @conn
end

Instance Method Details

#groups(*args) ⇒ Object

PROPERTIES OF GROUPS API id integer ID 123 uri API resource URL api.soundcloud.com/comments/32562 created_at timestamp of creation “2009/08/13 18:30:10 +0000” permalink permalink of the resource “summer-of-69” permalink_url URL to the SoundCloud.com page “soundcloud.com/bryan/summer-of-69” artwork_url URL to a JPEG image “i1.sndcdn.com/a.…-large.jpg?142a848” name name of the group “Field Recordings” description description of the group “field recordings from across the world” short_description short description of the group “field recordings!” creator mini user representation of the owner 343, username: “Doctor Wilson”…



31
# File 'lib/soundcloud2.rb', line 31

def groups(*args); super; end

#playlists(*args) ⇒ Object

PROPERTIES OF PLAYLISTS API id integer ID 123 created_at timestamp of creation “2009/08/13 18:30:10 +0000” user-id user-id of the owner 343 user mini user representation of the owner 343, username: “Doctor Wilson”… title track title “Summer of 69” permalink permalink of the resource “summer-of-69” permalink_url URL to the SoundCloud.com page “soundcloud.com/bryan/summer-of-69” uri API resource URL “api.soundcloud.com/tracks/123” sharing public/private sharing “public” purchase_url external purchase link “amazon.com/buy/a43aj0b03” artwork_url URL to a JPEG image “i1.sndcdn.com/a.…-large.jpg?142a848” description HTML description “my first track” downloadable downloadable (boolean) false streamable streamable via API (boolean) true label label mini user object username: “BeatLabel”… duration duration in milliseconds 1203400 genre genre “HipHop” shared_to_count number of sharings (if private) 45 tag_list list of tags “tag1 "hip hop" geo:lat=32.444 geo:lon=55.33” label_id id of the label user 54677 label_name label name “BeatLabel” license creative common license “no-rights-reserved” release release number 3234 release_day day of the release 21 release_month month of the release 5 release_year year of the release 2001 ean EAN identifier for the playlist “123-4354345-43” playlist_type playlist type “recording”



62
# File 'lib/soundcloud2.rb', line 62

def playlists(*args); super; end

#tracks(*args) ⇒ Object

PROPERTIES OF TRACKS API id integer ID 123 created_at timestamp of creation “2009/08/13 18:30:10 +0000” user-id user-id of the owner 343 user mini user representation of the owner 343, username: “Doctor Wilson”… title track title “Summer of 69” permalink permalink of the resource “summer-of-69” permalink_url URL to the SoundCloud.com page “soundcloud.com/bryan/summer-of-69” uri API resource URL “api.soundcloud.com/tracks/123” sharing public/private sharing “public” purchase_url external purchase link “amazon.com/buy/a43aj0b03” artwork_url URL to a JPEG image “i1.sndcdn.com/a.…-large.jpg?142a848” description HTML description “my first track” downloadable downloadable (boolean) false streamable streamable via API (boolean) true label label mini user object username: “BeatLabel”… duration duration in milliseconds 1203400 genre genre “HipHop” shared_to_count number of sharings (if private) 45 tag_list list of tags “tag1 "hip hop" geo:lat=32.444 geo:lon=55.33” label_id id of the label user 54677 label_name label name “BeatLabel” license creative common license “no-rights-reserved” release release number 3234 release_day day of the release 21 release_month month of the release 5 release_year year of the release 2001 state encoding state “finished” track_type track type “recording” waveform_url URL to PNG waveform image “” download_url URL to original file “api.soundcloud.com/tracks/3/download” stream_url link to 128kbs mp3 stream “api.soundcloud.com/tracks/3/stream” bpm beats per minute 120 commentable track commentable (boolean) true isrc track ISRC “I123-545454” key_signature track key “Cmaj” comment_count track comment count 12 download_count track download count 45 playback_count track play count 435 favoritings_count track favoriting count 6 original_format file format of the original file “aiff” created_with the app that the track created “…”=>nil asset_data binary data of the audio file (only for uploading) artwork_data binary data of the artwork image (only for uploading) user_favorite track favorite of current user (boolean, authenticated requests only) 1



109
# File 'lib/soundcloud2.rb', line 109

def tracks(*args); super; end

#users(*args) ⇒ Object

PROPERTIES OF USERS API id integer ID 123 permalink permalink of the resource “summer-of-69” username username “Doctor Wilson” uri API resource URL api.soundcloud.com/comments/32562 permalink_url URL to the SoundCloud.com page “soundcloud.com/bryan/summer-of-69” avatar_url URL to a JPEG image “i1.sndcdn.com/a.…-large.jpg?142a848” country country “Germany” full_name first and last name “Tom Wilson” city city “Berlin” description description “Another brick in the wall” discogs-name Discogs name “myrandomband” myspace-name MySpace name “myrandomband” website a URL to the website “facebook.com/myrandomband” website-title a custom title for the website “myrandomband on Facebook” online online status (boolean) true track_count number of public tracks 4 playlist_count number of public playlists 5 followers_count number of followers 54 followings_count number of followed users 75 public_favorites_count number of favorited public tracks 7



132
# File 'lib/soundcloud2.rb', line 132

def users(*args); super; end