rex11 0.1.0 → 0.1.1

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.
@@ -214,6 +214,21 @@ module Rex11
214
214
  parse_receiving_ticket_add_response(commit(xml_request.target!))
215
215
  end
216
216
 
217
+ def receiving_ticket_by_receiving_ticket_id(receiving_ticket_id)
218
+ require_auth_token
219
+ xml_request = Builder::XmlMarkup.new
220
+ xml_request.instruct!
221
+ 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
222
+ xml_request.soap :Body do
223
+ xml_request.GetReceivingTicketObjectByTicketNo(:xmlns => "http://rex11.com/webmethods/") do |xml_request|
224
+ xml_request.AuthenticationString(@auth_token)
225
+ xml_request.AsnTicketNumber(receiving_ticket_id)
226
+ end
227
+ end
228
+ end
229
+ parse_get_receiving_ticket_object_by_ticket_number(commit(xml_request.target!))
230
+ end
231
+
217
232
  private
218
233
  def commit(xml_request)
219
234
  http = Net::HTTP.new(@host, 80)
@@ -262,19 +277,18 @@ module Rex11
262
277
  end
263
278
 
264
279
  def parse_get_pick_ticket_object_by_bar_code(xml_response)
265
- return_hash = {}
266
280
  response = XmlSimple.xml_in(xml_response, :ForceArray => ["Notification"])
267
281
  response_content = response["Body"]["GetPickTicketObjectByBarCodeResponse"]["GetPickTicketObjectByBarCodeResult"]
268
282
 
269
283
  pick_ticket_hash = response_content["PickTicket"]
270
284
  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
- })
285
+ return_hash = {
286
+ :pick_ticket_id => (value = pick_ticket_hash["PickTicketNumber"]) ? value["content"] : nil,
287
+ :pick_ticket_status => (value = pick_ticket_hash["ShipmentStatus"]) ? value["content"] : nil,
288
+ :pick_ticket_status_code => (value = pick_ticket_hash["ShipmentStatusCode"]) ? value["content"] : nil,
289
+ :shipping_charge => (value = pick_ticket_hash["FreightCharge"]) ? value["content"] : nil,
290
+ :tracking_number => (tracking_number = pick_ticket_hash["TrackingNumber"]) ? tracking_number["content"] : nil
291
+ }
278
292
  else
279
293
  error_string = parse_error(response_content)
280
294
  raise error_string unless error_string.empty?
@@ -294,6 +308,39 @@ module Rex11
294
308
  end
295
309
  end
296
310
 
311
+ def parse_get_receiving_ticket_object_by_ticket_number(xml_response)
312
+ response = XmlSimple.xml_in(xml_response, :ForceArray => ["Notification"])
313
+ response_content = response["Body"]["GetReceivingTicketObjectByTicketNoResponse"]["GetReceivingTicketObjectByTicketNoResult"]
314
+
315
+ receiving_ticket_hash = response_content["ReceivingTicketByTicketNo"]
316
+ if receiving_ticket_hash and !receiving_ticket_hash.empty?
317
+
318
+ items = []
319
+ receiving_ticket_hash["ReceivingTicket"]["Shipmentitemslist"].each do |item|
320
+ item_hash = {
321
+ :style => item["Style"]["content"],
322
+ :upc => item["UPC"]["content"],
323
+ :size => item["Size"]["content"],
324
+ :color => item["Color"]["content"],
325
+ :description => item["ProductDescription"]["content"],
326
+ :quantity => item["ExpectedQuantity"]["content"],
327
+ :comments => item["Comments"]["content"],
328
+ :shipment_type => item["ShipmentType"]["content"]
329
+ }
330
+ items << item_hash
331
+ end
332
+
333
+ return_hash = {
334
+ :receiving_ticket_status => (value = receiving_ticket_hash["ReceivingTicket"]["ReceivingStatus"]) ? value["content"] : nil,
335
+ :receiving_ticket_status_code => (value = receiving_ticket_hash["ReceivingTicket"]["ReceivingStatusCode"]) ? value["content"] : nil,
336
+ :items => items
337
+ }
338
+ else
339
+ error_string = parse_error(response_content)
340
+ raise error_string unless error_string.empty?
341
+ end
342
+ end
343
+
297
344
  def parse_error(response_content)
298
345
  error_string = ""
299
346
  response_content["Notifications"]["Notification"].each do |notification|
@@ -1,3 +1,3 @@
1
1
  module Rex11
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
+ <GetReceivingTicketObjectByTicketNo xmlns="http://rex11.com/webmethods/">
5
+ <AuthenticationString>4vxVebc3D1zwsXjH9fkFpgpOhewauJbVu25WXjQ1gOo=</AuthenticationString>
6
+ <AsnTicketNumber>the_receiving_ticket_id</AsnTicketNumber>
7
+ </GetReceivingTicketObjectByTicketNo>
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
+ <GetReceivingTicketObjectByTicketNoResponse xmlns="http://rex11.com/webmethods/">
5
+ <GetReceivingTicketObjectByTicketNoResult>
6
+ <Notifications>
7
+ <Notification>
8
+ <ErrorCode>41</ErrorCode>
9
+ <Severity>InvalidAsnError</Severity>
10
+ <Message>Invalid ASN Ticket number</Message>
11
+ </Notification>
12
+ </Notifications>
13
+ </GetReceivingTicketObjectByTicketNoResult>
14
+ </GetReceivingTicketObjectByTicketNoResponse>
15
+ </soap:Body>
16
+ </soap:Envelope>
@@ -0,0 +1,53 @@
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
+ <GetReceivingTicketObjectByTicketNoResponse xmlns="http://rex11.com/webmethods/">
6
+ <GetReceivingTicketObjectByTicketNoResult>
7
+ <ReceivingTicketByTicketNo>
8
+ <ReceivingTicket>
9
+ <ReceivingStatus xmlns="http://rex11.com/swpublicapi/ReceivingTicket.xsd">the_receiving_status1</ReceivingStatus>
10
+ <ReceivingStatusCode xmlns="http://rex11.com/swpublicapi/ReceivingTicket.xsd">the_receiving_status_code1</ReceivingStatusCode>
11
+ <CreatedDate xmlns="http://rex11.com/swpublicapi/ReceivingTicket.xsd">the_created_date1</CreatedDate>
12
+ <Warehouse xmlns="http://rex11.com/swpublicapi/ReceivingTicket.xsd">the_warehouse</Warehouse>
13
+ <Carrier xmlns="http://rex11.com/swpublicapi/ReceivingTicket.xsd">the_carrier</Carrier>
14
+ <IMPORTSTATUSTEXT xmlns="http://rex11.com/swpublicapi/ReceivingTicket.xsd">the_import_status_text</IMPORTSTATUSTEXT>
15
+ <Shipmentitemslist>
16
+ <Style xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_style1</Style>
17
+ <UPC xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_upc1</UPC>
18
+ <Size xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_size1</Size>
19
+ <Color xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_color1</Color>
20
+ <ProductDescription xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_description1</ProductDescription>
21
+ <ExpectedQuantity xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_quantity1</ExpectedQuantity>
22
+ <Comments xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_comments1</Comments>
23
+ <ShipmentType xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_shipment_type1</ShipmentType>
24
+ </Shipmentitemslist>
25
+ <Shipmentitemslist>
26
+ <Style xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_style2</Style>
27
+ <UPC xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_upc2</UPC>
28
+ <Size xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_size2</Size>
29
+ <Color xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_color2</Color>
30
+ <ProductDescription xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_description2</ProductDescription>
31
+ <ExpectedQuantity xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_quantity2</ExpectedQuantity>
32
+ <Comments xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_comments2</Comments>
33
+ <ShipmentType xmlns="http://rex11.com/swpublicapi/ReceivingTicketItems.xsd">the_shipment_type2</ShipmentType>
34
+ </Shipmentitemslist>
35
+ <ShipmentTypelist xmlns="http://rex11.com/swpublicapi/ReceivingTicket.xsd">the_shipment_type_list1</ShipmentTypelist>
36
+ <ShipmentTypelist xmlns="http://rex11.com/swpublicapi/ReceivingTicket.xsd">the_shipment_type_list2</ShipmentTypelist>
37
+ <SupplierDetails>
38
+ <CompanyName xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_company_name</CompanyName>
39
+ <Address1 xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_address1</Address1>
40
+ <Address2 xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_address2</Address2>
41
+ <City xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_city</City>
42
+ <State xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_state</State>
43
+ <Zip xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_zip</Zip>
44
+ <Country xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_country</Country>
45
+ <Phone xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_phone</Phone>
46
+ <Email xmlns="http://rex11.com/swpublicapi/CustomerOrder.xsd">the_supplier_email</Email>
47
+ </SupplierDetails>
48
+ </ReceivingTicket>
49
+ </ReceivingTicketByTicketNo>
50
+ </GetReceivingTicketObjectByTicketNoResult>
51
+ </GetReceivingTicketObjectByTicketNoResponse>
52
+ </soap:Body>
53
+ </soap:Envelope>
@@ -324,6 +324,104 @@ describe Rex11::Client do
324
324
  end
325
325
  end
326
326
 
327
+ context "receiving_ticket_by_receiving_ticket_id" do
328
+ before do
329
+ @receiving_ticket_id = "the_receiving_ticket_id"
330
+ @items = [{:style => "the_style1",
331
+ :upc => "the_upc1",
332
+ :size => "the_size1",
333
+ :color => "the_color1",
334
+ :description => "the_description1",
335
+ :quantity => "the_quantity1",
336
+ :comments => "the_comments1",
337
+ :shipment_type => "the_shipment_type1"
338
+ },
339
+ {:style => "the_style2",
340
+ :upc => "the_upc2",
341
+ :size => "the_size2",
342
+ :color => "the_color2",
343
+ :description => "the_description2",
344
+ :quantity => "the_quantity2",
345
+ :comments => "the_comments2",
346
+ :shipment_type => "the_shipment_type2"
347
+ }
348
+ ]
349
+
350
+ @receiving_ticket_options = {
351
+ :warehouse => "the_warehouse",
352
+ :carrier => "the_carrier",
353
+ :memo => "the_memo",
354
+ :supplier => {:company_name => "the_supplier_company_name",
355
+ :address1 => "the_supplier_address1",
356
+ :address2 => "the_supplier_address2",
357
+ :city => "the_supplier_city",
358
+ :state => "the_supplier_state",
359
+ :zip => "the_supplier_zip",
360
+ :country => "the_supplier_country",
361
+ :phone => "the_supplier_phone",
362
+ :email => "the_supplier_email"
363
+ }
364
+ }
365
+
366
+ @client.auth_token = "4vxVebc3D1zwsXjH9fkFpgpOhewauJbVu25WXjQ1gOo="
367
+ end
368
+
369
+ it "should require_auth_token" do
370
+ @client.should_receive(:commit).and_return(xml_fixture("get_receiving_ticket_object_by_ticket_number_response_success"))
371
+ @client.should_receive(:require_auth_token)
372
+ @client.receiving_ticket_by_receiving_ticket_id(@receiving_ticket_id)
373
+ end
374
+
375
+ context "request" do
376
+ it "should form correct request" do
377
+ @client.should_receive(:commit).with(squeeze_xml(xml_fixture("get_receiving_ticket_object_by_ticket_number_request"))).and_return(xml_fixture("get_receiving_ticket_object_by_ticket_number_response_success"))
378
+ @client.receiving_ticket_by_receiving_ticket_id(@receiving_ticket_id)
379
+ end
380
+ end
381
+
382
+ context "response" do
383
+ context "when success" do
384
+ it "should return the receiving ticket id" do
385
+ @client.should_receive(:commit).and_return(xml_fixture("get_receiving_ticket_object_by_ticket_number_response_success"))
386
+
387
+ @client.receiving_ticket_by_receiving_ticket_id(@receiving_ticket_id).should == {
388
+ :receiving_ticket_status=>"the_receiving_status1",
389
+ :receiving_ticket_status_code=>"the_receiving_status_code1",
390
+ :items => [
391
+ {:style=>"the_style1",
392
+ :upc=>"the_upc1",
393
+ :size => "the_size1",
394
+ :color => "the_color1",
395
+ :description => "the_description1",
396
+ :quantity => "the_quantity1",
397
+ :comments => "the_comments1",
398
+ :shipment_type => "the_shipment_type1"
399
+ },
400
+ {:style=>"the_style2",
401
+ :upc=>"the_upc2",
402
+ :size => "the_size2",
403
+ :color => "the_color2",
404
+ :description => "the_description2",
405
+ :quantity => "the_quantity2",
406
+ :comments => "the_comments2",
407
+ :shipment_type => "the_shipment_type2"
408
+ }
409
+ ]
410
+ }
411
+ end
412
+ end
413
+
414
+ context "when error" do
415
+ it "should raise error" do
416
+ @client.should_receive(:commit).and_return(xml_fixture("get_receiving_ticket_object_by_ticket_number_response_error"))
417
+ lambda {
418
+ @client.receiving_ticket_by_receiving_ticket_id(@receiving_ticket_id)
419
+ }.should raise_error("Error 41: Invalid ASN Ticket number. ")
420
+ end
421
+ end
422
+ end
423
+ end
424
+
327
425
  context "require_auth_token" do
328
426
  it "should raise error if auth_token is not set" do
329
427
  lambda {
@@ -1,11 +1,12 @@
1
1
  require 'rex11'
2
2
 
3
- USERNAME = "xx"
4
- PASSWORD = "xx"
5
- WEB_ADDRESS = "xx"
3
+ USERNAME = "yoram"
4
+ PASSWORD = "not_set"
5
+ WEB_ADDRESS = "www.yoramtestaccount.atworkweb.com"
6
6
  TESTING = true
7
7
 
8
- item = {
8
+
9
+ item1 = {
9
10
  :style => "ABC123",
10
11
  :upc => "ABC123",
11
12
  :size => "LARGE",
@@ -24,20 +25,12 @@ item2 = {
24
25
  }
25
26
 
26
27
  items = [
27
- {:style => "ABC123",
28
- :upc => "ABC123",
29
- :size => "LARGE",
30
- :color => "Black",
31
- :description => "Chanel Red Skirt",
28
+ {:upc => item1[:upc],
32
29
  :quantity => "1",
33
30
  :comments => "These are the comments.",
34
31
  :shipment_type => "GOH"
35
32
  },
36
- {:style => "DEF123",
37
- :upc => "DEF123",
38
- :size => "SMALL",
39
- :color => "Blue",
40
- :description => "Balenciaga Purple Blouse",
33
+ {:upc => item2[:upc],
41
34
  :quantity => "1",
42
35
  :comments => "Slightly damaged",
43
36
  :shipment_type => "FLAT"
@@ -100,26 +93,32 @@ client = Rex11::Client.new(USERNAME, PASSWORD, WEB_ADDRESS, TESTING, :logging =>
100
93
  result = client.authenticate
101
94
  puts "Authenticated: #{result}\n\n"
102
95
 
103
- puts "Creating Style Master..."
104
- result = client.add_style(item)
105
- puts "Added Style Master: #{result}"
96
+ #puts "Creating Style Master..."
97
+ #result = client.add_style(item1)
98
+ #puts "Added Style Master: #{result}"
99
+ #
100
+ #puts "Creating Style Master..."
101
+ #result = client.add_style(item2)
102
+ #puts "Added Style Master: #{result}\n\n"
106
103
 
107
- puts "Creating Style Master..."
108
- result = client.add_style(item2)
109
- puts "Added Style Master: #{result}\n\n"
104
+ #puts "Creating Pick Tickets.."
105
+ #response = client.create_pick_ticket(items, ship_to_address, pick_ticket_options)
106
+ #puts "Created Pick Tickets: #{response}\n\n"
110
107
 
111
- puts "Creating Pick Tickets.."
112
- response = client.create_pick_ticket(items, ship_to_address, pick_ticket_options)
113
- puts "Created Pick Tickets: #{response}\n\n"
108
+ #puts "Canceling Pick Ticket.."
109
+ #response = client.cancel_pick_ticket(pick_ticket_id)
110
+ #puts "Canceled Pick Ticket: #{response}\n\n"
114
111
 
115
- puts "Canceling Pick Ticket.."
116
- response = client.cancel_pick_ticket(pick_ticket_id)
117
- puts "Canceled Pick Ticket: #{response}\n\n"
112
+ #puts "Getting Pick Tickets by number.."
113
+ #response = client.pick_ticket_by_number(pick_ticket_id)
114
+ #puts "Completed Pick Tickets by number: #{response}\n\n"
118
115
 
119
- puts "Getting Pick Tickets by number.."
120
- response = client.pick_ticket_by_number(pick_ticket_id)
121
- puts "Completed Pick Tickets by number: #{response}\n\n"
116
+ #puts "Creating Receiving Ticket.."
117
+ #response = client.create_receiving_ticket(items, receiving_ticket_options)
118
+ #receiving_ticket_id = response["receiving_ticket_id"]
119
+ #puts "Created Receiving Ticket: #{response}"
122
120
 
123
- puts "Creating Receiving Ticket.."
124
- response = client.create_receiving_ticket(items, receiving_ticket_options)
125
- puts "Created Receiving Ticket: #{response}"
121
+ receiving_ticket_id = "WHRTN304245"
122
+ puts "Getting Receiving Ticket By Receiving Ticket ID.."
123
+ response = client.receiving_ticket_by_receiving_ticket_id(receiving_ticket_id)
124
+ puts "Completed Receiving Ticket By Receiving Ticket ID: #{response}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex11
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-02 00:00:00.000000000 Z
12
+ date: 2013-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -101,6 +101,9 @@ files:
101
101
  - spec/fixtures/get_pick_ticket_object_by_bar_code_request.xml
102
102
  - spec/fixtures/get_pick_ticket_object_by_bar_code_response_error.xml
103
103
  - spec/fixtures/get_pick_ticket_object_by_bar_code_response_success.xml
104
+ - spec/fixtures/get_receiving_ticket_object_by_ticket_number_request.xml
105
+ - spec/fixtures/get_receiving_ticket_object_by_ticket_number_response_error.xml
106
+ - spec/fixtures/get_receiving_ticket_object_by_ticket_number_response_success.xml
104
107
  - spec/fixtures/pick_ticket_add_request.xml
105
108
  - spec/fixtures/pick_ticket_add_response_error.xml
106
109
  - spec/fixtures/pick_ticket_add_response_success.xml
@@ -149,6 +152,9 @@ test_files:
149
152
  - spec/fixtures/get_pick_ticket_object_by_bar_code_request.xml
150
153
  - spec/fixtures/get_pick_ticket_object_by_bar_code_response_error.xml
151
154
  - spec/fixtures/get_pick_ticket_object_by_bar_code_response_success.xml
155
+ - spec/fixtures/get_receiving_ticket_object_by_ticket_number_request.xml
156
+ - spec/fixtures/get_receiving_ticket_object_by_ticket_number_response_error.xml
157
+ - spec/fixtures/get_receiving_ticket_object_by_ticket_number_response_success.xml
152
158
  - spec/fixtures/pick_ticket_add_request.xml
153
159
  - spec/fixtures/pick_ticket_add_response_error.xml
154
160
  - spec/fixtures/pick_ticket_add_response_success.xml