blastramp 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/blastramp.rb CHANGED
@@ -11,6 +11,8 @@ require 'blastramp/order'
11
11
  require 'blastramp/order_item'
12
12
  require 'blastramp/order_upload'
13
13
  require 'blastramp/session'
14
+ require 'blastramp/error'
15
+
14
16
 
15
17
  module Blastramp
16
18
  end
@@ -0,0 +1,4 @@
1
+ module Blastramp
2
+ class SKUDoesNotExistError < StandardError
3
+ end
4
+ end
@@ -26,14 +26,18 @@ module Blastramp
26
26
  'Sku' => sku
27
27
  }
28
28
  end
29
-
30
- # Make sure we always have an array of handles even if the result only contains one
31
- handles = [response[:query_results][:counts][:inventory_count]].flatten.reject(&:blank?)
32
29
 
33
- # Create partial InventoryCount entities
34
- handles.collect do |handle|
35
- inventory_count = build(handle)
36
- inventory_count
30
+ if (response.to_hash[:result] == 'SUCCESS')
31
+ # Make sure we always have an array of handles even if the result only contains one
32
+ handles = [response[:query_results][:counts][:inventory_count]].flatten.reject(&:blank?)
33
+
34
+ # Create partial InventoryCount entities
35
+ handles.collect do |handle|
36
+ inventory_count = build(handle)
37
+ inventory_count
38
+ end
39
+ else
40
+ raise(SKUDoesNotExistError.new)
37
41
  end
38
42
 
39
43
  end
@@ -1,4 +1,4 @@
1
1
  module Blastramp
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
4
4
 
@@ -43,7 +43,27 @@ describe Blastramp::InventoryCountQuery do
43
43
  result.should be_instance_of(Blastramp::InventoryCount)
44
44
  end
45
45
  end
46
+
47
+ context "when SKU does not exist" do
48
+ before :each do
49
+ savon.stubs('InventoryCountQuery').returns(:sku_does_not_exist)
50
+ end
46
51
 
52
+ it "returns a SKUDoesNotExistError" do
53
+ expect{subject.find('XXXX-99-XX')}.to raise_error(Blastramp::SKUDoesNotExistError)
54
+ end
55
+ end
56
+
57
+ context "when one InventoryCount is requested and SKU does not exist" do
58
+ before :each do
59
+ savon.stubs('InventoryCountQuery').returns(:sku_does_not_exist)
60
+ end
61
+
62
+ it "returns a SKUDoesNotExistError" do
63
+ expect{subject.find_by_whid('AAA-01-XX','0001')}.to raise_error(Blastramp::SKUDoesNotExistError)
64
+ end
65
+ end
66
+
47
67
  end
48
68
 
49
69
  end
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
+ <soap:Body>
4
+ <InventoryCountQueryResponse xmlns="http://chrome52/webservices/">
5
+ <InventoryCountQueryResult>
6
+ <Result>FAILURE</Result>
7
+ <ErrorDesc>The Sku (ABAST01_2012-BLK-L) is not found.</ErrorDesc>
8
+ <ErrorNumber>20</ErrorNumber>
9
+ </InventoryCountQueryResult>
10
+ </InventoryCountQueryResponse>
11
+ </soap:Body>
12
+ </soap:Envelope>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - cnantais
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-06-29 00:00:00 -07:00
17
+ date: 2011-07-08 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -114,6 +114,7 @@ files:
114
114
  - lib/blastramp.rb
115
115
  - lib/blastramp/address.rb
116
116
  - lib/blastramp/entity.rb
117
+ - lib/blastramp/error.rb
117
118
  - lib/blastramp/inventory_count.rb
118
119
  - lib/blastramp/inventory_count_query.rb
119
120
  - lib/blastramp/order.rb
@@ -130,6 +131,7 @@ files:
130
131
  - spec/blastramp/order_upload_spec.rb
131
132
  - spec/blastramp/session_spec.rb
132
133
  - spec/fixtures/inventory_count_query/many.xml
134
+ - spec/fixtures/inventory_count_query/sku_does_not_exist.xml
133
135
  - spec/fixtures/order_upload/success.xml
134
136
  - spec/fixtures/wsdl.xml
135
137
  - spec/spec_helper.rb
@@ -174,6 +176,7 @@ test_files:
174
176
  - spec/blastramp/order_upload_spec.rb
175
177
  - spec/blastramp/session_spec.rb
176
178
  - spec/fixtures/inventory_count_query/many.xml
179
+ - spec/fixtures/inventory_count_query/sku_does_not_exist.xml
177
180
  - spec/fixtures/order_upload/success.xml
178
181
  - spec/fixtures/wsdl.xml
179
182
  - spec/spec_helper.rb