soundcloud 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -93,6 +93,30 @@ It is providing simple methods to handle authorization and to execute HTTP calls
93
93
  # updating the users profile description
94
94
  client.put("/me", :user => {:description => "a new description"})
95
95
 
96
+
97
+ ### Add a track to a playlist / set
98
+ client = Soundcloud.new(:access_token => "A_VALID_TOKEN")
99
+
100
+ # get my last playlist
101
+ playlist = client.get("/me/playlists").first
102
+
103
+ # get ids of contained tracks
104
+ track_ids = playlist.tracks.map(&:id) # => [22448500, 21928809]
105
+
106
+ # adding a new track 21778201
107
+ track_ids << 21778201 # => [22448500, 21928809, 21778201]
108
+
109
+ # map array of ids to array of track objects:
110
+ tracks = track_ids.map { |id| {:id => id} } # => [{:id=>22448500}, {:id=>21928809}, {:id=>21778201}]
111
+
112
+ # send update/put request to playlist
113
+ playlist = client.put(playlist.uri, :playlist => {
114
+ :tracks => tracks
115
+ })
116
+
117
+ # print the list of track ids of the updated playlist:
118
+ p playlist.tracks.map(&:id)
119
+
96
120
  ## Interface
97
121
  #### Soundcloud.new(options={})
98
122
  Stores the passed options and call exchange_token in case options are passed that allow an exchange of tokens.
@@ -1,6 +1,6 @@
1
1
  class Soundcloud::ArrayResponseWrapper < Array
2
2
  attr_reader :response
3
- def initialize(response)
3
+ def initialize(response=[])
4
4
  mashes = response.map { |o| Hashie::Mash.new(o) }
5
5
  self.replace(mashes)
6
6
  @response = response
@@ -1,6 +1,6 @@
1
1
  class Soundcloud::HashResponseWrapper < Hashie::Mash
2
2
  attr_reader :response
3
- def initialize(response, *args)
3
+ def initialize(response=nil, *args)
4
4
  super(response, *args)
5
5
  @response = response
6
6
  end
@@ -1,3 +1,3 @@
1
1
  class Soundcloud
2
- VERSION = '0.2.8'
2
+ VERSION = '0.2.9'
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.8
5
+ version: 0.2.9
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-10-07 00:00:00 -07:00
13
+ date: 2011-10-27 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency