blastramp 0.0.9 → 0.0.10

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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blastramp (0.0.9)
4
+ blastramp (0.0.10)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -49,7 +49,7 @@ Usage example
49
49
  order_item.item_value = 12.99
50
50
  order.order_items << order_item
51
51
 
52
- order_upload = Blastramp::OrderUpload.new(blastramp, order)
52
+ order_upload = Blastramp::OrderUpload.new(blastramp, [order])
53
53
  order_upload.submit
54
54
 
55
55
 
@@ -2,11 +2,11 @@ module Blastramp
2
2
  class OrderUpload
3
3
  # Associations
4
4
  attr_reader :session
5
- attr_reader :order
5
+ attr_reader :orders
6
6
 
7
- def initialize(session, order)
7
+ def initialize(session, orders)
8
8
  @session = session
9
- @order = order
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 => order.soap_data}
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[:result]
25
+ response.to_hash[:orderids][:string]
26
26
  elsif (response.to_hash[:error] == 'Failed to Authenticate.')
27
27
  raise(AuthenticationFailure.new)
28
- end
28
+ else
29
+ raise "Blastramp: An unknown error occured"
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -1,4 +1,4 @@
1
1
  module Blastramp
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
4
4
 
@@ -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
9
- version: 0.0.9
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-12 00:00:00 -07:00
17
+ date: 2011-07-13 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency