blastramp 0.0.1 → 0.0.2
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/README.md +3 -4
- data/lib/blastramp/inventory_count_query.rb +32 -0
- data/lib/blastramp/session.rb +18 -13
- data/lib/blastramp/version.rb +1 -1
- data/spec/blastramp/inventory_count_query_spec.rb +23 -0
- data/spec/blastramp/session_spec.rb +0 -7
- data/spec/fixtures/inventory_count_query/many.xml +64 -0
- data/spec/fixtures/wsdl.xml +114 -0
- metadata +8 -4
- data/spec/fixtures/connect/success.xml +0 -9
data/README.md
CHANGED
@@ -9,13 +9,12 @@ Usage example
|
|
9
9
|
-------------
|
10
10
|
|
11
11
|
blastramp = Blastramp::Session.new('vendor_code', 'vendor_access_key')
|
12
|
-
blastramp.connect
|
13
12
|
|
14
13
|
# Get array of inventory counts for a product SKU at all warehouses:
|
15
|
-
inventory_counts = blastramp.find_inventory_counts_for_sku('
|
16
|
-
|
14
|
+
inventory_counts = blastramp.inventory_counts.find_inventory_counts_for_sku('1000-BLK-M')
|
15
|
+
|
17
16
|
If a warehouse parameter is given, will return a single warehouse inventory_count
|
18
|
-
inventory_count = blastramp.find_inventory_counts_for_sku('AAA-01-XX','0001')
|
17
|
+
inventory_count = blastramp.inventory_counts.find_inventory_counts_for_sku('AAA-01-XX','0001')
|
19
18
|
|
20
19
|
# Create order:
|
21
20
|
order = Blastramp::OrderUpload.new
|
@@ -1,4 +1,36 @@
|
|
1
1
|
module Blastramp
|
2
2
|
class InventoryCountQuery
|
3
|
+
# Associations
|
4
|
+
attr_reader :session
|
5
|
+
|
6
|
+
def initialize(session)
|
7
|
+
@session = session
|
8
|
+
end
|
9
|
+
|
10
|
+
def find_inventory_counts_for_sku(sku)
|
11
|
+
# Get a list of InventoryCounts from Blastramp
|
12
|
+
response = session.request 'InventoryCountQuery' do
|
13
|
+
http.headers["SOAPAction"] = "http://chrome52/webservices/InventoryCountQuery"
|
14
|
+
|
15
|
+
soap.body = {
|
16
|
+
'VendorCode' => session.vendor_code,
|
17
|
+
'VendorAccessKey' => session.vendor_access_key,
|
18
|
+
'Sku' => sku
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# # Make sure we always have an array of handles even if the result only contains one
|
23
|
+
# handles = [response[:query_results][:counts][:inventory_count]].flatten.reject(&:blank?)
|
24
|
+
#
|
25
|
+
# # Create partial InventoryCount entities
|
26
|
+
# handles.collect do |handle|
|
27
|
+
# inventory_count = build
|
28
|
+
# inventory_count.persisted = true
|
29
|
+
# inventory_count.whid = handle[:whid]
|
30
|
+
# inventory_count
|
31
|
+
# end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
3
35
|
end
|
4
36
|
end
|
data/lib/blastramp/session.rb
CHANGED
@@ -10,25 +10,30 @@ module Blastramp
|
|
10
10
|
# Returns the Savon::Client used to connect to Blastramp
|
11
11
|
def client
|
12
12
|
@client ||= Savon::Client.new do
|
13
|
-
wsdl.
|
14
|
-
|
13
|
+
wsdl.document = "http://www.ioperate.net/ws/inventory/inventoryws.asmx?wsdl"
|
14
|
+
#
|
15
|
+
# wsdl.endpoint = "http://www.ioperate.net/ws/inventory/inventoryws.asmx"
|
16
|
+
# wsdl.namespace = "http://chrome52/webservices"
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
#
|
19
|
-
def connect
|
20
|
-
response = client.request :connect do
|
21
|
-
soap.body = {
|
22
|
-
'VendorCode' => self.vendor_code,
|
23
|
-
'VendorAccessKey' => self.vendor_access_key
|
24
|
-
}
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Provides access to the debtors
|
20
|
+
# Provides access to the inventory counts
|
29
21
|
def inventory_counts
|
30
22
|
@inventory_counts ||= InventoryCountQuery.new(self)
|
31
23
|
end
|
24
|
+
|
25
|
+
def request(action, &block)
|
26
|
+
response = client.request :soap, action, &block
|
27
|
+
response_hash = response.to_hash
|
28
|
+
|
29
|
+
response_key = "#{action}_response".intern
|
30
|
+
result_key = "#{action}_result".intern
|
31
|
+
if response_hash[response_key] && response_hash[response_key][result_key]
|
32
|
+
response_hash[response_key][result_key]
|
33
|
+
else
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
end
|
32
37
|
|
33
38
|
end
|
34
39
|
end
|
data/lib/blastramp/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
describe Blastramp::InventoryCountQuery do
|
4
|
+
let(:session) { stub_session }
|
5
|
+
subject { Blastramp::InventoryCountQuery.new(session) }
|
6
|
+
|
7
|
+
describe "new" do
|
8
|
+
it "stores session" do
|
9
|
+
subject.session.should === session
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "inventory_count_proxy" do
|
14
|
+
it "uses InventoryCountQuery on API" do
|
15
|
+
savon.expects('InventoryCountQuery').with(
|
16
|
+
'VendorCode' => 'ABC',
|
17
|
+
'VendorAccessKey' => 'TWX45IX2R9G35394',
|
18
|
+
'Sku' => 'AAA-01-XX').returns(:many)
|
19
|
+
subject.find_inventory_counts_for_sku('AAA-01-XX')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -17,13 +17,6 @@ describe Blastramp::Session do
|
|
17
17
|
subject.client.should be_instance_of(::Savon::Client)
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
describe "connect" do
|
22
|
-
it "connects to Blastramp" do
|
23
|
-
savon.expects('connect').with(has_entries('VendorCode' => 'ABC','VendorAccessKey' => 'TWX45IX2R9G35394')).returns(:success)
|
24
|
-
subject.connect
|
25
|
-
end
|
26
|
-
end
|
27
20
|
|
28
21
|
describe "inventory_counts" do
|
29
22
|
it "returns an InventoryCountQuery" do
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
3
|
+
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
4
|
+
<soap:Body>
|
5
|
+
<InventoryCountProxyResponse xmlns="http://chrome52/webservices/">
|
6
|
+
<InventoryCountProxyResult>
|
7
|
+
<Result>SUCCESS</Result>
|
8
|
+
<ErrorDesc></ErrorDesc>
|
9
|
+
<ErrorNumber>0</ErrorNumber>
|
10
|
+
<QueryResults>
|
11
|
+
<Sku>AAA-01-XX</Sku>
|
12
|
+
<Counts>
|
13
|
+
<InventoryCount>
|
14
|
+
<WHID>0001</WHID>
|
15
|
+
<AvailableToAllocate>0</AvailableToAllocate>
|
16
|
+
<AllocatedAndReleased>0</AllocatedAndReleased>
|
17
|
+
<Backordered>0</Backordered>
|
18
|
+
<Cancelled>0</Cancelled>
|
19
|
+
<Unreleased>0</Unreleased>
|
20
|
+
<BeingManufactured>0</BeingManufactured>
|
21
|
+
<TotalExpected>0</TotalExpected>
|
22
|
+
<TotalReceived>0</TotalReceived>
|
23
|
+
<TotalShipped>0</TotalShipped>
|
24
|
+
<StockTransferIn>0</StockTransferIn>
|
25
|
+
<StockTransferOut>0</StockTransferOut>
|
26
|
+
<OriginalPO>0</OriginalPO>
|
27
|
+
<AmendedPO>0</AmendedPO>
|
28
|
+
<UnshippedPO>0</UnshippedPO>
|
29
|
+
<ActiveShipment>0</ActiveShipment>
|
30
|
+
<AvailableToSell>0</AvailableToSell>
|
31
|
+
<CurrentInStock>0</CurrentInStock>
|
32
|
+
<TotalSalesOrder>0</TotalSalesOrder>
|
33
|
+
<ReceivingVariance>0</ReceivingVariance>
|
34
|
+
<WarehouseVariance>0</WarehouseVariance>
|
35
|
+
</InventoryCount>
|
36
|
+
<InventoryCount>
|
37
|
+
<WHID>0002</WHID>
|
38
|
+
<AvailableToAllocate>0</AvailableToAllocate>
|
39
|
+
<AllocatedAndReleased>0</AllocatedAndReleased>
|
40
|
+
<Backordered>0</Backordered>
|
41
|
+
<Cancelled>0</Cancelled>
|
42
|
+
<Unreleased>0</Unreleased>
|
43
|
+
<BeingManufactured>0</BeingManufactured>
|
44
|
+
<TotalExpected>0</TotalExpected>
|
45
|
+
<TotalReceived>0</TotalReceived>
|
46
|
+
<TotalShipped>0</TotalShipped>
|
47
|
+
<StockTransferIn>0</StockTransferIn>
|
48
|
+
<StockTransferOut>0</StockTransferOut>
|
49
|
+
<OriginalPO>0</OriginalPO>
|
50
|
+
<AmendedPO>0</AmendedPO>
|
51
|
+
<UnshippedPO>0</UnshippedPO>
|
52
|
+
<ActiveShipment>0</ActiveShipment>
|
53
|
+
<AvailableToSell>0</AvailableToSell>
|
54
|
+
<CurrentInStock>0</CurrentInStock>
|
55
|
+
<TotalSalesOrder>0</TotalSalesOrder>
|
56
|
+
<ReceivingVariance>0</ReceivingVariance>
|
57
|
+
<WarehouseVariance>0</WarehouseVariance>
|
58
|
+
</InventoryCount>
|
59
|
+
</Counts>
|
60
|
+
</QueryResults>
|
61
|
+
</InventoryCountProxyResult>
|
62
|
+
</InventoryCountProxyResponse>
|
63
|
+
</soap:Body>
|
64
|
+
</soap:Envelope>
|
@@ -0,0 +1,114 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://chrome52/webservices/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://chrome52/webservices/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
|
3
|
+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">A service for Chrome52 clients to query their inventory counts.</wsdl:documentation>
|
4
|
+
<wsdl:types>
|
5
|
+
<s:schema elementFormDefault="qualified" targetNamespace="http://chrome52/webservices/">
|
6
|
+
<s:element name="InventoryCountProxy">
|
7
|
+
<s:complexType>
|
8
|
+
<s:sequence>
|
9
|
+
<s:element minOccurs="0" maxOccurs="1" name="VendorCode" type="s:string" />
|
10
|
+
<s:element minOccurs="0" maxOccurs="1" name="VendorAccessKey" type="s:string" />
|
11
|
+
<s:element minOccurs="0" maxOccurs="1" name="Sku" type="s:string" />
|
12
|
+
</s:sequence>
|
13
|
+
</s:complexType>
|
14
|
+
</s:element>
|
15
|
+
<s:element name="InventoryCountProxyResponse">
|
16
|
+
<s:complexType>
|
17
|
+
<s:sequence>
|
18
|
+
<s:element minOccurs="0" maxOccurs="1" name="InventoryCountProxyResult" type="tns:InventoryCountProxyResult" />
|
19
|
+
</s:sequence>
|
20
|
+
</s:complexType>
|
21
|
+
</s:element>
|
22
|
+
<s:complexType name="InventoryCountProxyResult">
|
23
|
+
<s:sequence>
|
24
|
+
<s:element minOccurs="0" maxOccurs="1" name="Result" type="s:string" />
|
25
|
+
<s:element minOccurs="0" maxOccurs="1" name="ErrorDesc" type="s:string" />
|
26
|
+
<s:element minOccurs="1" maxOccurs="1" name="ErrorNumber" type="s:int" />
|
27
|
+
<s:element minOccurs="0" maxOccurs="1" name="QueryResults" type="tns:InventoryCounts" />
|
28
|
+
</s:sequence>
|
29
|
+
</s:complexType>
|
30
|
+
<s:complexType name="InventoryCounts">
|
31
|
+
<s:sequence>
|
32
|
+
<s:element minOccurs="0" maxOccurs="1" name="Sku" type="s:string" />
|
33
|
+
<s:element minOccurs="0" maxOccurs="1" name="Counts" type="tns:ArrayOfInventoryCount" />
|
34
|
+
</s:sequence>
|
35
|
+
</s:complexType>
|
36
|
+
<s:complexType name="ArrayOfInventoryCount">
|
37
|
+
<s:sequence>
|
38
|
+
<s:element minOccurs="0" maxOccurs="unbounded" name="InventoryCount" nillable="true" type="tns:InventoryCount" />
|
39
|
+
</s:sequence>
|
40
|
+
</s:complexType>
|
41
|
+
<s:complexType name="InventoryCount">
|
42
|
+
<s:sequence>
|
43
|
+
<s:element minOccurs="0" maxOccurs="1" name="WHID" type="s:string" />
|
44
|
+
<s:element minOccurs="1" maxOccurs="1" name="AvailableToAllocate" type="s:int" />
|
45
|
+
<s:element minOccurs="1" maxOccurs="1" name="AllocatedAndReleased" type="s:int" />
|
46
|
+
<s:element minOccurs="1" maxOccurs="1" name="Backordered" type="s:int" />
|
47
|
+
<s:element minOccurs="1" maxOccurs="1" name="Cancelled" type="s:int" />
|
48
|
+
<s:element minOccurs="1" maxOccurs="1" name="Unreleased" type="s:int" />
|
49
|
+
<s:element minOccurs="1" maxOccurs="1" name="BeingManufactured" type="s:int" />
|
50
|
+
<s:element minOccurs="1" maxOccurs="1" name="TotalExpected" type="s:int" />
|
51
|
+
<s:element minOccurs="1" maxOccurs="1" name="TotalReceived" type="s:int" />
|
52
|
+
<s:element minOccurs="1" maxOccurs="1" name="TotalShipped" type="s:int" />
|
53
|
+
<s:element minOccurs="1" maxOccurs="1" name="StockTransferIn" type="s:int" />
|
54
|
+
<s:element minOccurs="1" maxOccurs="1" name="StockTransferOut" type="s:int" />
|
55
|
+
<s:element minOccurs="1" maxOccurs="1" name="OriginalPO" type="s:int" />
|
56
|
+
<s:element minOccurs="1" maxOccurs="1" name="AmendedPO" type="s:int" />
|
57
|
+
<s:element minOccurs="1" maxOccurs="1" name="UnshippedPO" type="s:int" />
|
58
|
+
<s:element minOccurs="1" maxOccurs="1" name="ActiveShipment" type="s:int" />
|
59
|
+
<s:element minOccurs="1" maxOccurs="1" name="AvailableToSell" type="s:int" />
|
60
|
+
<s:element minOccurs="1" maxOccurs="1" name="CurrentInStock" type="s:int" />
|
61
|
+
<s:element minOccurs="1" maxOccurs="1" name="TotalSalesOrder" type="s:int" />
|
62
|
+
<s:element minOccurs="1" maxOccurs="1" name="ReceivingVariance" type="s:int" />
|
63
|
+
<s:element minOccurs="1" maxOccurs="1" name="WarehouseVariance" type="s:int" />
|
64
|
+
</s:sequence>
|
65
|
+
</s:complexType>
|
66
|
+
</s:schema>
|
67
|
+
</wsdl:types>
|
68
|
+
<wsdl:message name="InventoryCountProxySoapIn">
|
69
|
+
<wsdl:part name="parameters" element="tns:InventoryCountProxy" />
|
70
|
+
</wsdl:message>
|
71
|
+
<wsdl:message name="InventoryCountProxySoapOut">
|
72
|
+
<wsdl:part name="parameters" element="tns:InventoryCountProxyResponse" />
|
73
|
+
</wsdl:message>
|
74
|
+
<wsdl:portType name="InventoryWsSoap">
|
75
|
+
<wsdl:operation name="InventoryCountProxy">
|
76
|
+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Inventory counts.</wsdl:documentation>
|
77
|
+
<wsdl:input message="tns:InventoryCountProxySoapIn" />
|
78
|
+
<wsdl:output message="tns:InventoryCountProxySoapOut" />
|
79
|
+
</wsdl:operation>
|
80
|
+
</wsdl:portType>
|
81
|
+
<wsdl:binding name="InventoryWsSoap" type="tns:InventoryWsSoap">
|
82
|
+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
83
|
+
<wsdl:operation name="InventoryCountProxy">
|
84
|
+
<soap:operation soapAction="http://chrome52/webservices/InventoryCountProxy" style="document" />
|
85
|
+
<wsdl:input>
|
86
|
+
<soap:body use="literal" />
|
87
|
+
</wsdl:input>
|
88
|
+
<wsdl:output>
|
89
|
+
<soap:body use="literal" />
|
90
|
+
</wsdl:output>
|
91
|
+
</wsdl:operation>
|
92
|
+
</wsdl:binding>
|
93
|
+
<wsdl:binding name="InventoryWsSoap12" type="tns:InventoryWsSoap">
|
94
|
+
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
95
|
+
<wsdl:operation name="InventoryCountProxy">
|
96
|
+
<soap12:operation soapAction="http://chrome52/webservices/InventoryCountProxy" style="document" />
|
97
|
+
<wsdl:input>
|
98
|
+
<soap12:body use="literal" />
|
99
|
+
</wsdl:input>
|
100
|
+
<wsdl:output>
|
101
|
+
<soap12:body use="literal" />
|
102
|
+
</wsdl:output>
|
103
|
+
</wsdl:operation>
|
104
|
+
</wsdl:binding>
|
105
|
+
<wsdl:service name="InventoryWs">
|
106
|
+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">A service for Chrome52 clients to query their inventory counts.</wsdl:documentation>
|
107
|
+
<wsdl:port name="InventoryWsSoap" binding="tns:InventoryWsSoap">
|
108
|
+
<soap:address location="http://www.ioperate.net/ws/inventory/inventoryws.asmx" />
|
109
|
+
</wsdl:port>
|
110
|
+
<wsdl:port name="InventoryWsSoap12" binding="tns:InventoryWsSoap12">
|
111
|
+
<soap12:address location="http://www.ioperate.net/ws/inventory/inventoryws.asmx" />
|
112
|
+
</wsdl:port>
|
113
|
+
</wsdl:service>
|
114
|
+
</wsdl:definitions>
|
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
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- cnantais
|
@@ -100,8 +100,10 @@ files:
|
|
100
100
|
- lib/blastramp/inventory_count_query.rb
|
101
101
|
- lib/blastramp/session.rb
|
102
102
|
- lib/blastramp/version.rb
|
103
|
+
- spec/blastramp/inventory_count_query_spec.rb
|
103
104
|
- spec/blastramp/session_spec.rb
|
104
|
-
- spec/fixtures/
|
105
|
+
- spec/fixtures/inventory_count_query/many.xml
|
106
|
+
- spec/fixtures/wsdl.xml
|
105
107
|
- spec/spec_helper.rb
|
106
108
|
has_rdoc: true
|
107
109
|
homepage: http://zkron.com
|
@@ -136,6 +138,8 @@ signing_key:
|
|
136
138
|
specification_version: 3
|
137
139
|
summary: Blastramp Shipping Services Client Library
|
138
140
|
test_files:
|
141
|
+
- spec/blastramp/inventory_count_query_spec.rb
|
139
142
|
- spec/blastramp/session_spec.rb
|
140
|
-
- spec/fixtures/
|
143
|
+
- spec/fixtures/inventory_count_query/many.xml
|
144
|
+
- spec/fixtures/wsdl.xml
|
141
145
|
- spec/spec_helper.rb
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
3
|
-
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
4
|
-
<soap:Body>
|
5
|
-
<ConnectResponse xmlns="http://chrome52/webservices/">
|
6
|
-
<ConnectResult>SUCCESS</ConnectResult>
|
7
|
-
</ConnectResponse>
|
8
|
-
</soap:Body>
|
9
|
-
</soap:Envelope>
|