rex11 0.0.2 → 0.1.0
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/.gitignore +18 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +110 -0
- data/Rakefile +7 -0
- data/lib/rex11/client.rb +307 -0
- data/lib/rex11/version.rb +3 -0
- data/lib/rex11.rb +2 -5
- data/rex11.gemspec +25 -0
- data/spec/fixtures/authentication_token_get_request.xml +10 -0
- data/spec/fixtures/authentication_token_get_response_error.xml +9 -0
- data/spec/fixtures/authentication_token_get_response_success.xml +7 -0
- data/spec/fixtures/cancel_pick_ticket_request.xml +9 -0
- data/spec/fixtures/cancel_pick_ticket_response_error.xml +22 -0
- data/spec/fixtures/cancel_pick_ticket_response_success.xml +16 -0
- data/spec/fixtures/get_pick_ticket_object_by_bar_code_request.xml +9 -0
- data/spec/fixtures/get_pick_ticket_object_by_bar_code_response_error.xml +16 -0
- data/spec/fixtures/get_pick_ticket_object_by_bar_code_response_success.xml +106 -0
- data/spec/fixtures/pick_ticket_add_request.xml +52 -0
- data/spec/fixtures/pick_ticket_add_response_error.xml +27 -0
- data/spec/fixtures/pick_ticket_add_response_success.xml +16 -0
- data/spec/fixtures/receiving_ticket_add_request.xml +46 -0
- data/spec/fixtures/receiving_ticket_add_response_error.xml +22 -0
- data/spec/fixtures/receiving_ticket_add_response_success.xml +10 -0
- data/spec/fixtures/style_master_product_add_request.xml +20 -0
- data/spec/fixtures/style_master_product_add_response_error.xml +32 -0
- data/spec/fixtures/style_master_product_add_response_success.xml +16 -0
- data/spec/fixtures/text.xml +103 -0
- data/spec/lib/client_spec.rb +341 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/spec_helper_methods.rb +6 -0
- data/spec/test_run.rb +125 -0
- metadata +127 -7
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@rex11
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Andy Shin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Rex11
|
2
|
+
|
3
|
+
Ruby Library for REX11 Warehouse Management System
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rex11'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rex11
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Initialize Rex11 client:
|
22
|
+
|
23
|
+
require "rex11"
|
24
|
+
client = Rex11::Client.new("rex_username", "rex_password", "rex_web_address")
|
25
|
+
|
26
|
+
Create style master:
|
27
|
+
|
28
|
+
item = {
|
29
|
+
:style => "ABC123",
|
30
|
+
:upc => "ABC123",
|
31
|
+
:size => "LARGE",
|
32
|
+
:price => "100.0",
|
33
|
+
:color => "Black",
|
34
|
+
:description => "Chanel Red Skirt"
|
35
|
+
}
|
36
|
+
|
37
|
+
client.add_style(item)
|
38
|
+
|
39
|
+
Create pick ticket for items:
|
40
|
+
|
41
|
+
items = [
|
42
|
+
{:style => "ABC123",
|
43
|
+
:upc => "ABC123",
|
44
|
+
:size => "LARGE",
|
45
|
+
:color => "Black",
|
46
|
+
:description => "Chanel Red Skirt",
|
47
|
+
:quantity => "1",
|
48
|
+
:comments => "These are the comments.",
|
49
|
+
:shipment_type => "GOH"
|
50
|
+
},
|
51
|
+
{:style => "DEF123",
|
52
|
+
:upc => "DEF123",
|
53
|
+
:size => "SMALL",
|
54
|
+
:color => "Blue",
|
55
|
+
:description => "Balenciaga Purple Blouse",
|
56
|
+
:quantity => "1",
|
57
|
+
:comments => "Slightly damaged",
|
58
|
+
:shipment_type => "FLAT"
|
59
|
+
}
|
60
|
+
]
|
61
|
+
|
62
|
+
ship_to_address = {:first_name => "Joe",
|
63
|
+
:last_name => "Shmoe",
|
64
|
+
:company_name => "Time Magazine",
|
65
|
+
:address1 => "1271 Avenue of the Americas",
|
66
|
+
:city => "New York",
|
67
|
+
:state => "NY",
|
68
|
+
:zip => "10020",
|
69
|
+
:country => "US",
|
70
|
+
:phone => "212-522-1212",
|
71
|
+
:email => "time@magazine.com"
|
72
|
+
}
|
73
|
+
|
74
|
+
pick_ticket_id = "23022012012557"
|
75
|
+
pick_ticket_options = {
|
76
|
+
:pick_ticket_id => pick_ticket_id,
|
77
|
+
:warehouse => "The Warehouse",
|
78
|
+
:payment_terms => "NET",
|
79
|
+
:use_ups_account => "1",
|
80
|
+
:ship_via_account_number => "1AB345",
|
81
|
+
:ship_via => "UPS",
|
82
|
+
:ship_service => "UPS GROUND - Commercial",
|
83
|
+
:billing_option => "PREPAID",
|
84
|
+
:bill_to_address => {
|
85
|
+
:first_name => "Jane",
|
86
|
+
:last_name => "Smith",
|
87
|
+
:company_name => "Netaporter",
|
88
|
+
:address1 => "725 Darlington Avenue",
|
89
|
+
:city => "Mahwah",
|
90
|
+
:state => "NJ",
|
91
|
+
:zip => "07430",
|
92
|
+
:country => "US",
|
93
|
+
:phone => "212-522-1212",
|
94
|
+
:email => "net@netaporter.com"
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
client.create_pick_ticket(items, ship_to_address, pick_ticket_options)
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
## Contributing
|
105
|
+
|
106
|
+
1. Fork it
|
107
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
108
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
109
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
110
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/rex11/client.rb
ADDED
@@ -0,0 +1,307 @@
|
|
1
|
+
require "builder"
|
2
|
+
require 'xmlsimple'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Rex11
|
6
|
+
class Client
|
7
|
+
|
8
|
+
TEST_HOST = "sync.rex11.com"
|
9
|
+
TEST_PATH = "/ws/v2staging/publicapiws.asmx"
|
10
|
+
LIVE_HOST = "sync.rex11.com"
|
11
|
+
LIVE_PATH = "/ws/v2prod/publicapiws.asmx"
|
12
|
+
|
13
|
+
attr_accessor :auth_token
|
14
|
+
|
15
|
+
def initialize(username, password, web_address, testing = false, options = {})
|
16
|
+
raise "Username is required" unless username
|
17
|
+
raise "Password is required" unless password
|
18
|
+
|
19
|
+
default_options = {
|
20
|
+
:logging => true,
|
21
|
+
}
|
22
|
+
@options = default_options.update(options)
|
23
|
+
|
24
|
+
@username = username
|
25
|
+
@password = password
|
26
|
+
@web_address = web_address
|
27
|
+
|
28
|
+
@logging = options[:logging]
|
29
|
+
@host = testing ? TEST_HOST : LIVE_HOST
|
30
|
+
@path = testing ? TEST_PATH : LIVE_PATH
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def authenticate
|
35
|
+
xml = Builder::XmlMarkup.new
|
36
|
+
xml.instruct!
|
37
|
+
xml.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" do
|
38
|
+
xml.soap :Body do
|
39
|
+
xml.AuthenticationTokenGet(:xmlns => "http://rex11.com/webmethods/") do |xml|
|
40
|
+
xml.WebAddress(@web_address)
|
41
|
+
xml.UserName(@username)
|
42
|
+
xml.Password(@password)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
parse_authenticate_response(commit(xml.target!))
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_style(item)
|
50
|
+
require_auth_token
|
51
|
+
xml_request = Builder::XmlMarkup.new
|
52
|
+
xml_request.instruct!
|
53
|
+
xml_request.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" do
|
54
|
+
xml_request.soap :Body do
|
55
|
+
xml_request.StyleMasterProductAdd(:xmlns => "http://rex11.com/webmethods/") do |xml_request|
|
56
|
+
xml_request.AuthenticationString(@auth_token)
|
57
|
+
xml_request.products do |xml_request|
|
58
|
+
xml_request.StyleMasterProduct do |xml_request|
|
59
|
+
xml_request.Style(item[:style], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd")
|
60
|
+
xml_request.UPC(item[:upc], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd")
|
61
|
+
xml_request.Size(item[:size], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd")
|
62
|
+
xml_request.Color(item[:color], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd")
|
63
|
+
xml_request.Description(item[:description], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd")
|
64
|
+
xml_request.Price(item[:price], :xmlns => "http://rex11.com/swpublicapi/StyleMasterProduct.xsd")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
parse_add_style_response(commit(xml_request.target!))
|
71
|
+
end
|
72
|
+
|
73
|
+
def create_pick_ticket(items, ship_to_address, pick_ticket_options)
|
74
|
+
require_auth_token
|
75
|
+
xml_request = Builder::XmlMarkup.new
|
76
|
+
xml_request.instruct!
|
77
|
+
xml_request.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" do
|
78
|
+
xml_request.soap :Body do
|
79
|
+
xml_request.PickTicketAdd(:xmlns => "http://rex11.com/webmethods/") do |xml_request|
|
80
|
+
xml_request.AuthenticationString(@auth_token)
|
81
|
+
xml_request.PickTicket(:xmlns => "http://rex11.com/swpublicapi/PickTicket.xsd") do |xml_request|
|
82
|
+
xml_request.PickTicketNumber(pick_ticket_options[:pick_ticket_id])
|
83
|
+
xml_request.WareHouse(pick_ticket_options[:warehouse])
|
84
|
+
xml_request.PaymentTerms(pick_ticket_options[:payment_terms])
|
85
|
+
xml_request.UseAccountUPS(pick_ticket_options[:use_ups_account])
|
86
|
+
xml_request.ShipViaAccountNumber(pick_ticket_options[:ship_via_account_number])
|
87
|
+
xml_request.ShipVia(pick_ticket_options[:ship_via])
|
88
|
+
xml_request.ShipService(pick_ticket_options[:ship_service])
|
89
|
+
xml_request.BillingOption(pick_ticket_options[:billing_option])
|
90
|
+
xml_request.BillToAddress do |xml_request|
|
91
|
+
xml_request.FirstName(pick_ticket_options[:bill_to_address][:first_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
92
|
+
xml_request.LastName(pick_ticket_options[:bill_to_address][:last_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
93
|
+
xml_request.CompanyName(pick_ticket_options[:bill_to_address][:company_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
94
|
+
xml_request.Address1(pick_ticket_options[:bill_to_address][:address1], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
95
|
+
xml_request.Address2(pick_ticket_options[:bill_to_address][:address2], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
96
|
+
xml_request.City(pick_ticket_options[:bill_to_address][:city], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
97
|
+
xml_request.State(pick_ticket_options[:bill_to_address][:state], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
98
|
+
xml_request.Zip(pick_ticket_options[:bill_to_address][:zip], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
99
|
+
xml_request.Country(pick_ticket_options[:bill_to_address][:country], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
100
|
+
xml_request.Phone(pick_ticket_options[:bill_to_address][:phone], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
101
|
+
xml_request.Email(pick_ticket_options[:bill_to_address][:email], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
102
|
+
end
|
103
|
+
xml_request.ShipToAddress do |xml_request|
|
104
|
+
xml_request.FirstName(ship_to_address[:first_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
105
|
+
xml_request.LastName(ship_to_address[:last_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
106
|
+
xml_request.CompanyName(ship_to_address[:company_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
107
|
+
xml_request.Address1(ship_to_address[:address1], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
108
|
+
xml_request.Address2(ship_to_address[:address2], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
109
|
+
xml_request.City(ship_to_address[:city], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
110
|
+
xml_request.State(ship_to_address[:state], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
111
|
+
xml_request.Zip(ship_to_address[:zip], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
112
|
+
xml_request.Country(ship_to_address[:country], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
113
|
+
xml_request.Phone(ship_to_address[:phone], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
114
|
+
xml_request.Email(ship_to_address[:email], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
115
|
+
end
|
116
|
+
|
117
|
+
items.each do |item|
|
118
|
+
xml_request.LineItem do |xml_request|
|
119
|
+
xml_request.UPC(item[:upc], :xmlns => "http://rex11.com/swpublicapi/PickTicketDetails.xsd")
|
120
|
+
xml_request.Quantity(item[:quantity], :xmlns => "http://rex11.com/swpublicapi/PickTicketDetails.xsd")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
parse_pick_ticket_add_response(commit(xml_request.target!))
|
128
|
+
end
|
129
|
+
|
130
|
+
def cancel_pick_ticket(pick_ticket_id)
|
131
|
+
require_auth_token
|
132
|
+
xml_request = Builder::XmlMarkup.new
|
133
|
+
xml_request.instruct!
|
134
|
+
xml_request.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" do
|
135
|
+
xml_request.soap :Body do
|
136
|
+
xml_request.CancelPickTicket(:xmlns => "http://rex11.com/webmethods/") do |xml_request|
|
137
|
+
xml_request.AuthenticationString(@auth_token)
|
138
|
+
xml_request.PickTicketId(pick_ticket_id)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
parse_cancel_pick_ticket(commit(xml_request.target!))
|
143
|
+
end
|
144
|
+
|
145
|
+
def parse_cancel_pick_ticket(xml_response)
|
146
|
+
response = XmlSimple.xml_in(xml_response, :ForceArray => ["Notification"])
|
147
|
+
response_content = response["Body"]["CancelPickTicketResponse"]["CancelPickTicketResult"]
|
148
|
+
error_string = parse_error(response_content)
|
149
|
+
|
150
|
+
if error_string.empty?
|
151
|
+
true
|
152
|
+
else
|
153
|
+
raise error_string
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
def pick_ticket_by_number(pick_ticket_id)
|
159
|
+
require_auth_token
|
160
|
+
xml_request = Builder::XmlMarkup.new
|
161
|
+
xml_request.instruct!
|
162
|
+
xml_request.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" do
|
163
|
+
xml_request.soap :Body do
|
164
|
+
xml_request.GetPickTicketObjectByBarCode(:xmlns => "http://rex11.com/webmethods/") do |xml_request|
|
165
|
+
xml_request.AuthenticationString(@auth_token)
|
166
|
+
xml_request.ptbarcode(pick_ticket_id)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
parse_get_pick_ticket_object_by_bar_code(commit(xml_request.target!))
|
171
|
+
end
|
172
|
+
|
173
|
+
def create_receiving_ticket(items, receiving_ticket_options)
|
174
|
+
require_auth_token
|
175
|
+
xml_request = Builder::XmlMarkup.new
|
176
|
+
xml_request.instruct!
|
177
|
+
xml_request.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" do
|
178
|
+
xml_request.soap :Body do
|
179
|
+
xml_request.ReceivingTicketAdd(:xmlns => "http://rex11.com/webmethods/") do |xml_request|
|
180
|
+
xml_request.AuthenticationString(@auth_token)
|
181
|
+
xml_request.receivingTicket(:xmlns => "http://rex11.com/swpublicapi/ReceivingTicket.xsd") do |xml_request|
|
182
|
+
items.each do |item|
|
183
|
+
xml_request.Shipmentitemslist do |xml_request|
|
184
|
+
xml_request.Style(item[:style], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd")
|
185
|
+
xml_request.UPC(item[:upc], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd")
|
186
|
+
xml_request.Size(item[:size], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd")
|
187
|
+
xml_request.Color(item[:color], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd")
|
188
|
+
xml_request.ProductDescription(item[:description], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd")
|
189
|
+
xml_request.ExpectedQuantity(item[:quantity], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd")
|
190
|
+
xml_request.Comments(item[:comments], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd")
|
191
|
+
xml_request.ShipmentType(item[:shipment_type], :xmlns => "http://rex11.com/swpublicapi/ReceivingTicketItems.xsd")
|
192
|
+
end
|
193
|
+
xml_request.ShipmentTypelist(item[:shipment_type])
|
194
|
+
end
|
195
|
+
xml_request.Warehouse(receiving_ticket_options[:warehouse])
|
196
|
+
xml_request.Memo(receiving_ticket_options[:memo])
|
197
|
+
xml_request.Carrier(receiving_ticket_options[:carrier])
|
198
|
+
xml_request.SupplierDetails do |xml_request|
|
199
|
+
xml_request.CompanyName(receiving_ticket_options[:supplier][:company_name], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
200
|
+
xml_request.Address1(receiving_ticket_options[:supplier][:address1], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
201
|
+
xml_request.Address2(receiving_ticket_options[:supplier][:address2], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
202
|
+
xml_request.City(receiving_ticket_options[:supplier][:city], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
203
|
+
xml_request.State(receiving_ticket_options[:supplier][:state], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
204
|
+
xml_request.Zip(receiving_ticket_options[:supplier][:zip], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
205
|
+
xml_request.Country(receiving_ticket_options[:supplier][:country], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
206
|
+
xml_request.Phone(receiving_ticket_options[:supplier][:phone], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
207
|
+
xml_request.Email(receiving_ticket_options[:supplier][:email], :xmlns => "http://rex11.com/swpublicapi/CustomerOrder.xsd")
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
parse_receiving_ticket_add_response(commit(xml_request.target!))
|
215
|
+
end
|
216
|
+
|
217
|
+
private
|
218
|
+
def commit(xml_request)
|
219
|
+
http = Net::HTTP.new(@host, 80)
|
220
|
+
response = http.post(@path, xml_request, {'Content-Type' => 'text/xml'})
|
221
|
+
puts response.body if @options[:logging]
|
222
|
+
response.body
|
223
|
+
end
|
224
|
+
|
225
|
+
def require_auth_token
|
226
|
+
raise "Authentication required for api call" unless @auth_token
|
227
|
+
end
|
228
|
+
|
229
|
+
def parse_authenticate_response(xml_response)
|
230
|
+
response = XmlSimple.xml_in(xml_response, :ForceArray => false)
|
231
|
+
response_content = response["Body"]["AuthenticationTokenGetResponse"]["AuthenticationTokenGetResult"]
|
232
|
+
if response_content and !response_content.empty?
|
233
|
+
@auth_token = response_content
|
234
|
+
true
|
235
|
+
else
|
236
|
+
raise "Failed Authentication due invalid username, password, or endpoint"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def parse_add_style_response(xml_response)
|
241
|
+
response = XmlSimple.xml_in(xml_response, :ForceArray => ["Notification"])
|
242
|
+
response_content = response["Body"]["StyleMasterProductAddResponse"]["StyleMasterProductAddResult"]
|
243
|
+
error_string = parse_error(response_content)
|
244
|
+
|
245
|
+
if error_string.empty?
|
246
|
+
true
|
247
|
+
else
|
248
|
+
raise error_string
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
def parse_pick_ticket_add_response(xml_response)
|
253
|
+
response = XmlSimple.xml_in(xml_response, :ForceArray => ["Notification"])
|
254
|
+
response_content = response["Body"]["PickTicketAddResponse"]["PickTicketAddResult"]
|
255
|
+
error_string = parse_error(response_content)
|
256
|
+
|
257
|
+
if error_string.empty?
|
258
|
+
true
|
259
|
+
else
|
260
|
+
raise error_string
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def parse_get_pick_ticket_object_by_bar_code(xml_response)
|
265
|
+
return_hash = {}
|
266
|
+
response = XmlSimple.xml_in(xml_response, :ForceArray => ["Notification"])
|
267
|
+
response_content = response["Body"]["GetPickTicketObjectByBarCodeResponse"]["GetPickTicketObjectByBarCodeResult"]
|
268
|
+
|
269
|
+
pick_ticket_hash = response_content["PickTicket"]
|
270
|
+
if pick_ticket_hash and !pick_ticket_hash.empty?
|
271
|
+
return_hash.merge!({
|
272
|
+
:pick_ticket_id => (value = pick_ticket_hash["PickTicketNumber"]) ? value["content"] : nil,
|
273
|
+
:pick_ticket_status => (value = pick_ticket_hash["ShipmentStatus"]) ? value["content"] : nil,
|
274
|
+
:pick_ticket_status_code => (value = pick_ticket_hash["ShipmentStatusCode"]) ? value["content"] : nil,
|
275
|
+
:shipping_charge => (value = pick_ticket_hash["FreightCharge"]) ? value["content"] : nil,
|
276
|
+
:tracking_number => (tracking_number = pick_ticket_hash["TrackingNumber"]) ? tracking_number["content"] : nil
|
277
|
+
})
|
278
|
+
else
|
279
|
+
error_string = parse_error(response_content)
|
280
|
+
raise error_string unless error_string.empty?
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def parse_receiving_ticket_add_response(xml_response)
|
285
|
+
response = XmlSimple.xml_in(xml_response, :ForceArray => ["Notification"])
|
286
|
+
response_content = response["Body"]["ReceivingTicketAddResponse"]["ReceivingTicketAddResult"]
|
287
|
+
|
288
|
+
receiving_ticket_id = response_content["ReceivingTicketId"]
|
289
|
+
if receiving_ticket_id and !receiving_ticket_id.empty?
|
290
|
+
{:receiving_ticket_id => receiving_ticket_id}
|
291
|
+
else
|
292
|
+
error_string = parse_error(response_content)
|
293
|
+
raise error_string unless error_string.empty?
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def parse_error(response_content)
|
298
|
+
error_string = ""
|
299
|
+
response_content["Notifications"]["Notification"].each do |notification|
|
300
|
+
if notification["ErrorCode"] != "0"
|
301
|
+
error_string += "Error " + notification["ErrorCode"] + ": " + notification["Message"] + ". "
|
302
|
+
end
|
303
|
+
end
|
304
|
+
error_string
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
data/lib/rex11.rb
CHANGED
data/rex11.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rex11/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "rex11"
|
8
|
+
gem.version = Rex11::VERSION
|
9
|
+
gem.authors = ["Andy Shin"]
|
10
|
+
gem.email = ["andrewkshin@gmail.com"]
|
11
|
+
gem.description = "Ruby Library for REX11 Warehouse Management System"
|
12
|
+
gem.summary = "This is a library for interfacing with REX11 Warehouse Management System"
|
13
|
+
gem.homepage = "https://www.vaunte.com"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency('builder')
|
21
|
+
gem.add_dependency('xml-simple')
|
22
|
+
|
23
|
+
gem.add_development_dependency 'rake'
|
24
|
+
gem.add_development_dependency 'rspec'
|
25
|
+
end
|
@@ -0,0 +1,10 @@
|
|
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
|
+
<AuthenticationTokenGet xmlns="http://rex11.com/webmethods/">
|
5
|
+
<WebAddress>the_web_address</WebAddress>
|
6
|
+
<UserName>the_username</UserName>
|
7
|
+
<Password>the_password</Password>
|
8
|
+
</AuthenticationTokenGet>
|
9
|
+
</soap:Body>
|
10
|
+
</soap:Envelope>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
4
|
+
<soap:Body>
|
5
|
+
<AuthenticationTokenGetResponse xmlns="http://rex11.com/webmethods/">
|
6
|
+
<AuthenticationTokenGetResult/>
|
7
|
+
</AuthenticationTokenGetResponse>
|
8
|
+
</soap:Body>
|
9
|
+
</soap:Envelope>
|
@@ -0,0 +1,7 @@
|
|
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><AuthenticationTokenGetResponse xmlns="http://rex11.com/webmethods/">
|
4
|
+
<AuthenticationTokenGetResult>4vxVebc3D1zwsXjH9fkFpgpOhewauJbVu25WXjQ1gOo=</AuthenticationTokenGetResult>
|
5
|
+
</AuthenticationTokenGetResponse>
|
6
|
+
</soap:Body>
|
7
|
+
</soap:Envelope>
|
@@ -0,0 +1,9 @@
|
|
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
|
+
<CancelPickTicket xmlns="http://rex11.com/webmethods/">
|
5
|
+
<AuthenticationString>4vxVebc3D1zwsXjH9fkFpgpOhewauJbVu25WXjQ1gOo=</AuthenticationString>
|
6
|
+
<PickTicketId>the_pick_ticket_id</PickTicketId>
|
7
|
+
</CancelPickTicket>
|
8
|
+
</soap:Body>
|
9
|
+
</soap:Envelope>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
4
|
+
<soap:Body>
|
5
|
+
<CancelPickTicketResponse xmlns="http://rex11.com/webmethods/">
|
6
|
+
<CancelPickTicketResult>
|
7
|
+
<Notifications>
|
8
|
+
<Notification>
|
9
|
+
<ErrorCode>45</ErrorCode>
|
10
|
+
<Severity>PickTicketError</Severity>
|
11
|
+
<Message>PickTicket can not be cancelled</Message>
|
12
|
+
</Notification>
|
13
|
+
<Notification>
|
14
|
+
<ErrorCode>45</ErrorCode>
|
15
|
+
<Severity>PickTicketError</Severity>
|
16
|
+
<Message>PickTicket does not exist</Message>
|
17
|
+
</Notification>
|
18
|
+
</Notifications>
|
19
|
+
</CancelPickTicketResult>
|
20
|
+
</CancelPickTicketResponse>
|
21
|
+
</soap:Body>
|
22
|
+
</soap:Envelope>
|
@@ -0,0 +1,16 @@
|
|
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
|
+
<CancelPickTicketResponse xmlns="http://rex11.com/webmethods/">
|
5
|
+
<CancelPickTicketResult>
|
6
|
+
<Notifications>
|
7
|
+
<Notification>
|
8
|
+
<ErrorCode>0</ErrorCode>
|
9
|
+
<Severity>Success</Severity>
|
10
|
+
<Message>PickTicket cancelled</Message>
|
11
|
+
</Notification>
|
12
|
+
</Notifications>
|
13
|
+
</CancelPickTicketResult>
|
14
|
+
</CancelPickTicketResponse>
|
15
|
+
</soap:Body>
|
16
|
+
</soap:Envelope>
|
@@ -0,0 +1,9 @@
|
|
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
|
+
<GetPickTicketObjectByBarCode xmlns="http://rex11.com/webmethods/">
|
5
|
+
<AuthenticationString>4vxVebc3D1zwsXjH9fkFpgpOhewauJbVu25WXjQ1gOo=</AuthenticationString>
|
6
|
+
<ptbarcode>the_pick_ticket_id</ptbarcode>
|
7
|
+
</GetPickTicketObjectByBarCode>
|
8
|
+
</soap:Body>
|
9
|
+
</soap:Envelope>
|
@@ -0,0 +1,16 @@
|
|
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
|
+
<GetPickTicketObjectByBarCodeResponse xmlns="http://rex11.com/webmethods/">
|
5
|
+
<GetPickTicketObjectByBarCodeResult>
|
6
|
+
<Notifications>
|
7
|
+
<Notification>
|
8
|
+
<ErrorCode>83</ErrorCode>
|
9
|
+
<Severity>BarCodeError</Severity>
|
10
|
+
<Message>BarCode doesn't exist</Message>
|
11
|
+
</Notification>
|
12
|
+
</Notifications>
|
13
|
+
</GetPickTicketObjectByBarCodeResult>
|
14
|
+
</GetPickTicketObjectByBarCodeResponse>
|
15
|
+
</soap:Body>
|
16
|
+
</soap:Envelope>
|