spark_api 1.4.6 → 1.4.8

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
- YTY5NWM1MTcyNDk2OWE2ZjlkOWFmN2MwZDU4YTkxYTBiZGY1NzBlYQ==
4
+ NTNkMGYyYTRmYTcwMDNhYzA5MmNiN2IwMGQyNDFlZjJjZGIxN2IwZg==
5
5
  data.tar.gz: !binary |-
6
- NGM3ZWFhNWM1YjA1OGU3YTIxOTZjODI1ZDljZGViMGE5MTg3MmZkNw==
6
+ YzE0ZGIwNzJmNjg5NDAxN2IzNTI3ZTdmN2JlMWM2MmE1YTQzZTE0MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2MyYjMzMWE2MzA1MzU1OTJlNzcxNWNhZTM2OTE2MGU4NmY3YTk4YWNhZmU0
10
- NzVkNmE3MWVlNDc3Nzc5MTAwYmI5MmU1MjM4YjA2MzgxOGI0ZmMyNGVjYzA3
11
- NTEwNDU3MDQzMTQ4ZjE2NjNmZGNiMGU5ZGU4MzY2MDRjNTFhZmE=
9
+ NzA4MGYyNWQ5YjQyYjU1ZTZjMTIzMmUxNjQzZDJjYmUxY2ViZDhkMGRiMGYx
10
+ N2ZmMTZkZGY3Y2M4ZjkxYTA5YmY1Zjg1OWRiODNjMTBlYTM2ZTVkYmU2ZTU1
11
+ NTkxZjQ5Y2M2ZTYyN2IyZmFhNzM5ZWJhNzBhMzVjNTZkMDI2ZjQ=
12
12
  data.tar.gz: !binary |-
13
- MTc4ODFlZjE2YTAxYmZlZmIyOTZmNTFkMWNlN2UyOWNlZjBmNzJjNzA1OTE4
14
- NTg2MTk2NzllZTgxY2RkZjkxODQ0N2NjMWE0M2YwMWY5MDdlYzBhODA0ZmFj
15
- NWJkOTdiMmNjZGE5MDY2Y2FhYjAwNmY5YTFkODBjMjUxNGZkYWY=
13
+ NGI3ZTE1NTcxMmU2YjI3ZDMxZTVkZmIxZWFlOWZhMzljNjI5YjRhNjQ0M2Mz
14
+ YmJmZDQ4OTUxZTliMjRiZjY5ODBkNjVmMTFjZjdlYzEyY2RhZWExNTI4N2Nk
15
+ NjU1ZTVmZTIwNWMxN2VlOTkwNTg5N2JiZDZmZDJmYWQ5NzA1Yzc=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.6
1
+ 1.4.8
@@ -37,12 +37,16 @@ module SparkApi
37
37
  Listing.collect(connection.get("#{self.path}/#{self.Id}/listings", args))
38
38
  end
39
39
 
40
- def add_listing(listing)
41
- ids = listing.respond_to?(:Id) ? listing.Id : listing
42
- results = connection.post("#{self.resource_uri}", {"ListingIds" => Array(ids)})
40
+ def add_listings(listings)
41
+ ids = Array(listings).map do |listing|
42
+ listing.respond_to?(:Id) ? listing.Id : listing
43
+ end
44
+ results = connection.post("#{self.resource_uri}", {"ListingIds" => ids})
43
45
  self.ListingCount = results.first["ListingCount"]
44
46
  end
45
47
 
48
+ alias_method :add_listing, :add_listings
49
+
46
50
  def remove_listing(listing)
47
51
  id = listing.respond_to?(:Id) ? listing.Id : listing.to_s
48
52
  results = connection.delete("#{self.class.path}/#{self.Id}/listings/#{id}")
@@ -1,7 +1,7 @@
1
1
  module SparkApi
2
2
  # API Response interface
3
3
  module Response
4
- ATTRIBUTES = [:code, :message, :results, :success, :pagination, :details]
4
+ ATTRIBUTES = [:code, :message, :results, :success, :pagination, :details, :d]
5
5
  attr_accessor *ATTRIBUTES
6
6
  def success?
7
7
  @success
@@ -13,16 +13,16 @@ module SparkApi
13
13
  include SparkApi::Response
14
14
  def initialize(d)
15
15
  begin
16
- hash = d["D"]
17
- if hash.nil? || hash.empty?
16
+ self.d = d["D"]
17
+ if self.d.nil? || self.d.empty?
18
18
  raise InvalidResponse, "The server response could not be understood"
19
19
  end
20
- self.message = hash["Message"]
21
- self.code = hash["Code"]
22
- self.results = Array(hash["Results"])
23
- self.success = hash["Success"]
24
- self.pagination = hash["Pagination"]
25
- self.details = hash["Details"] || []
20
+ self.message = self.d["Message"]
21
+ self.code = self.d["Code"]
22
+ self.results = Array(self.d["Results"])
23
+ self.success = self.d["Success"]
24
+ self.pagination = self.d["Pagination"]
25
+ self.details = self.d["Details"] || []
26
26
  super(results)
27
27
  rescue Exception => e
28
28
  SparkApi.logger.error "Unable to understand the response! #{d}"
@@ -0,0 +1,13 @@
1
+ {
2
+ "D": {
3
+ "Success": true,
4
+ "Results": [
5
+ {
6
+ "ResourceUri": "/v1/listingcarts/20100912153422758914000000",
7
+ "Id": "20100912153422758914000000",
8
+ "Name": "My Listing Cart",
9
+ "ListingCount": 12
10
+ }
11
+ ]
12
+ }
13
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "D": {
3
+ "ListingIds": [ "20110621133454434543000000", "20110621133454434543000001" ]
4
+ }
5
+ }
@@ -76,6 +76,17 @@ describe ListingCart do
76
76
  resource.ListingCount.should eq(11)
77
77
  end
78
78
 
79
+ on_post_it "should add multiple listings to a cart" do
80
+ listing_ids = ["20110621133454434543000000", "20110621133454434543000001"]
81
+ stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
82
+ resource = subject.class.get.first
83
+ resource.Id.should eq("20100912153422758914000000")
84
+ stub_api_post("/#{subject.class.element_name}/#{resource.Id}",'listing_carts/add_listings_post.json', 'listing_carts/add_listings.json')
85
+ resource.ListingCount.should eq(10)
86
+ resource.add_listings(listing_ids)
87
+ resource.ListingCount.should eq(12)
88
+ end
89
+
79
90
  on_delete_it "should delete a listing cart" do
80
91
  stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
81
92
  resource = subject.class.get.first
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.6
4
+ version: 1.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Hornseth
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-13 00:00:00.000000000 Z
12
+ date: 2016-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -107,6 +107,20 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '1.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: public_suffix
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ~>
115
+ - !ruby/object:Gem::Version
116
+ version: 1.4.6
117
+ type: :runtime
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ~>
122
+ - !ruby/object:Gem::Version
123
+ version: 1.4.6
110
124
  - !ruby/object:Gem::Dependency
111
125
  name: rake
112
126
  requirement: !ruby/object:Gem::Requirement
@@ -397,6 +411,8 @@ files:
397
411
  - spec/fixtures/idx_links/get.json
398
412
  - spec/fixtures/listing_carts/add_listing.json
399
413
  - spec/fixtures/listing_carts/add_listing_post.json
414
+ - spec/fixtures/listing_carts/add_listings.json
415
+ - spec/fixtures/listing_carts/add_listings_post.json
400
416
  - spec/fixtures/listing_carts/add_portal_cart_listings.json
401
417
  - spec/fixtures/listing_carts/add_portal_cart_listings_post.json
402
418
  - spec/fixtures/listing_carts/empty.json
@@ -613,6 +629,7 @@ test_files:
613
629
  - spec/fixtures/listing_carts/post.json
614
630
  - spec/fixtures/listing_carts/add_portal_cart_listings_post.json
615
631
  - spec/fixtures/listing_carts/post_portal_cart.json
632
+ - spec/fixtures/listing_carts/add_listings.json
616
633
  - spec/fixtures/listing_carts/add_listing_post.json
617
634
  - spec/fixtures/listing_carts/add_portal_cart_listings.json
618
635
  - spec/fixtures/listing_carts/empty.json
@@ -622,6 +639,7 @@ test_files:
622
639
  - spec/fixtures/listing_carts/remove_listing.json
623
640
  - spec/fixtures/listing_carts/listing_portal_cart.json
624
641
  - spec/fixtures/listing_carts/listing_cart.json
642
+ - spec/fixtures/listing_carts/add_listings_post.json
625
643
  - spec/fixtures/listing_carts/new_portal_cart.json
626
644
  - spec/fixtures/listing_carts/put_name.json
627
645
  - spec/fixtures/listing_carts/put_ids.json