spark_api 1.4.10 → 1.4.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTFjNDIzMzZlZTliYWQ5ZmFhZTI0YzgxOTIzZGM4NjczMDExZjI2Nw==
4
+ ZWRkMjMxNzQ0ZGM1YWRmZDNhNjMyNDQ1ODk1ZTMzODQ1YTc3ZjY0Yw==
5
5
  data.tar.gz: !binary |-
6
- MzlkZTQ2YjlkNjBhMDExMTU2ZDA5NWQxOWE5NDRjMTAwNDFkZjQ4Yg==
6
+ OGQ4NjhjYmQ5NWM1MzM5YTQ1ZDgxOTc0MDAyNWQ3MThlYTM1NDg1NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDExMTM5MWMxNzA0MGFlMTdkNzVjYjdhZmJjOTcxYjRmMjc1ZGExNjkxOTcw
10
- MDdiNjAwZjY2N2MwNDY2ZjMxYjcyZWM2Y2NkNmU3MzI1Yjk2YWFlY2UxMWM2
11
- ZjA4ZmY2OWJkMjQzMmRkYWRmZGE2ZTEyZDA1MGNjZGIzNDFmMGE=
9
+ NmZlOTEyY2RiZmI1Y2I0MzcwZmY2Y2ZmZWZiODA3MjQ1OWRlNzE5OWFkZDEw
10
+ MWIwNmJjMTNhNWZkZmJiZjllY2RhNzZkYjA3MmQ3MzAyNjJkNGYxMzk4Mjgx
11
+ MGNmOWU0NDM3YWQ2YmY2OGVjMTIxMTRkOWE0MmJhMTU0NWY2YmM=
12
12
  data.tar.gz: !binary |-
13
- NDFmNjk3ZTY5NTQ5Y2FkNDFkZDAwYTk4Y2I4ZTNhODI0NTZhOGY4ZmYzYjA1
14
- ZWYwYzU3OWZmZjY4OWJiNzJhYWJlZjRiY2Q0OTlhNTFhZWJmOGZjYmY1NmVi
15
- OWQ4MmQ5ZWFhZGY0YTg5NzlmZTIxNWY1Y2U3ODY2ZGNhNzQ3ZTI=
13
+ OTk4MDAwOTVlOWQ5MDVlYjVmNDdmMjVhZTIyMjAyYTIxNmRkYjllYmE1ZTc5
14
+ NzhmMzkwOGE3NTU2YzhiYWJhMWIxNjRiZTg0MmRiNDA3MWZmYzkzY2FiZmNl
15
+ NzQ3ZTQyYTI0MDI3ZDMwYjZmZjliNGNjYmU0MTExNjMxYWY2MTQ=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.10
1
+ 1.4.11
@@ -188,7 +188,7 @@ module SparkApi
188
188
  false
189
189
  end
190
190
  def reorder_photos!(arguments={})
191
- results = connection.put "#{self.class.path}/#{self.Id}/photos", arguments
191
+ results = connection.put subresource_path("photos"), arguments
192
192
  true
193
193
  end
194
194
 
@@ -207,7 +207,7 @@ module SparkApi
207
207
  false
208
208
  end
209
209
  def reorder_photo!(photo_id, index)
210
- connection.put "#{self.class.path}/#{self.Id}/photos/#{photo_id}", "Photos" => [{"Order"=>index}]
210
+ connection.put subresource_path("photos") + "/#{photo_id}", "Photos" => [{"Order"=>index}]
211
211
  true
212
212
  end
213
213
 
@@ -235,6 +235,26 @@ module SparkApi
235
235
  end
236
236
  end
237
237
 
238
+ def delete_photos!(photoIds, args={})
239
+ connection.delete subresource_path("photos") + "/#{photoIds}", args
240
+ true
241
+ end
242
+
243
+ def delete_photos(photoIds, args={})
244
+ unless photoIds.is_a? String
245
+ raise ArgumentError, "Batch photo delete failed. '#{photoIds}' is not a string."
246
+ end
247
+
248
+ begin
249
+ return delete_photos!(photoIds, args)
250
+ rescue BadResourceRequest => e
251
+ SparkApi.logger.warn { "Failed to delete photos from resource #{self}: #{e.message}" }
252
+ rescue NotFound => e
253
+ SparkApi.logger.error { "Failed to delete photos from resource #{self}: #{e.message}" }
254
+ end
255
+ false
256
+ end
257
+
238
258
  private
239
259
 
240
260
  # TODO trim this down so we're only overriding the StandardFields access
@@ -272,6 +292,10 @@ module SparkApi
272
292
  end
273
293
  end
274
294
 
295
+ def subresource_path(subresource)
296
+ "#{self.class.path}/#{self.Id}/#{subresource}"
297
+ end
298
+
275
299
  end
276
300
  end
277
301
  end
@@ -351,6 +351,16 @@ describe Listing do
351
351
  l.editable?(:PriceChange).should eq(true)
352
352
  l.editable?(:Photos).should eq(false)
353
353
  end
354
+
355
+ on_delete_it "should bulk delete listing photos" do
356
+ list_id = "20060725224713296297000000"
357
+ stub_api_get("/listings/#{list_id}", 'listings/with_photos.json', { :_expand => "Photos" })
358
+ l = Listing.find(list_id, :_expand => "Photos")
359
+ photo_id1 = l.photos[0].Id
360
+ photo_id2 = l.photos[1].Id
361
+ stub_api_delete("/listings/#{list_id}/photos/#{photo_id1},#{photo_id2}", 'success.json')
362
+ l.delete_photos(photo_id1 + "," + photo_id2).should be(true)
363
+ end
354
364
  end
355
365
  end
356
366
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.10
4
+ version: 1.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Hornseth