blastramp 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/blastramp/order_upload.rb +8 -6
- data/lib/blastramp/version.rb +1 -1
- data/spec/blastramp/order_upload_spec.rb +15 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,11 +2,11 @@ module Blastramp
|
|
2
2
|
class OrderUpload
|
3
3
|
# Associations
|
4
4
|
attr_reader :session
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :orders
|
6
6
|
|
7
|
-
def initialize(session,
|
7
|
+
def initialize(session, orders)
|
8
8
|
@session = session
|
9
|
-
@
|
9
|
+
@orders = orders
|
10
10
|
end
|
11
11
|
|
12
12
|
def submit
|
@@ -18,14 +18,16 @@ module Blastramp
|
|
18
18
|
soap.body = {
|
19
19
|
'VendorCode' => session.vendor_code,
|
20
20
|
'VendorAccessKey' => session.vendor_access_key,
|
21
|
-
'Batch' => {:order =>
|
21
|
+
'Batch' => orders.collect {|o| {:order => o.soap_data}}
|
22
22
|
}
|
23
23
|
end
|
24
24
|
if (response.to_hash[:result] == 'SUCCESS')
|
25
|
-
response.to_hash[:
|
25
|
+
response.to_hash[:orderids][:string]
|
26
26
|
elsif (response.to_hash[:error] == 'Failed to Authenticate.')
|
27
27
|
raise(AuthenticationFailure.new)
|
28
|
-
|
28
|
+
else
|
29
|
+
raise "Blastramp: An unknown error occured"
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/lib/blastramp/version.rb
CHANGED
@@ -3,7 +3,7 @@ require './spec/spec_helper'
|
|
3
3
|
describe Blastramp::OrderUpload do
|
4
4
|
let(:session) { stub_session }
|
5
5
|
let(:order) { stub_order }
|
6
|
-
subject { Blastramp::OrderUpload.new(session, order) }
|
6
|
+
subject { Blastramp::OrderUpload.new(session, [order]) }
|
7
7
|
|
8
8
|
describe "new" do
|
9
9
|
it "stores session" do
|
@@ -17,7 +17,7 @@ describe Blastramp::OrderUpload do
|
|
17
17
|
savon.expects('OrderUpload').with(
|
18
18
|
'VendorCode' => 'ABC',
|
19
19
|
'VendorAccessKey' => 'TWX45IX2R9G35394',
|
20
|
-
'Batch' => {:order => order.soap_data}).returns(:success)
|
20
|
+
'Batch' => [{:order => order.soap_data}]).returns(:success)
|
21
21
|
subject.submit
|
22
22
|
end
|
23
23
|
|
@@ -30,6 +30,19 @@ describe Blastramp::OrderUpload do
|
|
30
30
|
expect{subject.submit}.to raise_error(Blastramp::AuthenticationFailure)
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
context "when Order response is successful" do
|
35
|
+
before :each do
|
36
|
+
savon.stubs('OrderUpload').returns(:success)
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:result) { subject.submit }
|
40
|
+
|
41
|
+
it "it should return array containing orderid of original order" do
|
42
|
+
result.should include('12345')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
33
46
|
end
|
34
47
|
|
35
48
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 10
|
9
|
+
version: 0.0.10
|
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-07-
|
17
|
+
date: 2011-07-13 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|