zanders 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zanders/order.rb +53 -42
- data/lib/zanders/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f322c5bca40309ab0cb1a548e4dbe213c67377a2
|
4
|
+
data.tar.gz: 5467c31791ce482cde3eb8b606348b500c6833c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bf5de21a653979d233fdf9fe48d0f155f98cc8b64fa4766afe197824865d52f40e2521ce43bd1bbc86527c68a8af24551ac3f6290e6476fcbb567741272f9f1
|
7
|
+
data.tar.gz: d1f380b3f62c5ab9df6beea23d62f144c00b3c33faa31f10252958c3760f5b3ce8c8a6c8bb1ebcda41135863ec0cf9ecb84b16330e76f5258ca3163b1f8d2317
|
data/lib/zanders/order.rb
CHANGED
@@ -39,9 +39,11 @@ module Zanders
|
|
39
39
|
# purchase_order - internal identifier for the order
|
40
40
|
#
|
41
41
|
# Returns an order_number
|
42
|
-
def create_order(items, address,
|
42
|
+
def create_order(items, address, purchase_order_number, details = {})
|
43
43
|
order = build_order_data
|
44
|
-
order_items
|
44
|
+
order_items = Array.new
|
45
|
+
order[:order] = Hash.new
|
46
|
+
shipping_information = Array.new
|
45
47
|
|
46
48
|
items.each do |item|
|
47
49
|
order_items.push(item: [
|
@@ -51,50 +53,59 @@ module Zanders
|
|
51
53
|
])
|
52
54
|
end
|
53
55
|
|
54
|
-
|
56
|
+
shipping_information.push(*[
|
57
|
+
{ key: 'shipDate', value: Time.now.strftime("%Y-%m-%d") },
|
58
|
+
{ key: 'shipViaCode', value: 'UG' },
|
59
|
+
{ key: 'purchaseOrderNumber', value: purchase_order_number }
|
60
|
+
])
|
55
61
|
|
56
|
-
if
|
57
|
-
|
58
|
-
{ key: 'shipToNo', value: ship_to_number[:ship_to_number] },
|
59
|
-
{ key: 'shipDate', value: Time.now.strftime("%Y-%m-%d") },
|
60
|
-
{ key: 'shipViaCode', value: 'UG' },
|
61
|
-
{ key: 'purchaseOrderNumber', value: purchase_order }
|
62
|
-
]
|
62
|
+
if address[:fflno].present?
|
63
|
+
ship_to_number = Zanders::Address.ship_to_number(address, @options)
|
63
64
|
|
64
|
-
if
|
65
|
-
shipping_information.push(
|
66
|
-
{ key: 'shipInstructions', value: format_shipping_instructions(details[:name], details[:phone_number]) }
|
67
|
-
)
|
65
|
+
if ship_to_number[:success]
|
66
|
+
shipping_information.push({key: 'shipToNo', value: ship_to_number[:ship_to_number] })
|
68
67
|
end
|
68
|
+
else
|
69
|
+
shipping_information.push(*[
|
70
|
+
{ key: 'shipToAddress1', value: address[:address1] },
|
71
|
+
{ key: 'shipToAddress2', value: address[:address2] },
|
72
|
+
{ key: 'shipToCity', value: address[:city] },
|
73
|
+
{ key: 'shipToState', value: address[:state] },
|
74
|
+
{ key: 'shipToZip', value: address[:zip] }
|
75
|
+
])
|
76
|
+
end
|
69
77
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
78
|
+
if details[:name]
|
79
|
+
shipping_information.push(
|
80
|
+
{ key: 'shipInstructions', value: format_shipping_instructions(details[:name], details[:phone_number]) }
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
# NOTE-david
|
85
|
+
# order(ns2 map)
|
86
|
+
# item
|
87
|
+
# key
|
88
|
+
# value(ns2map)
|
89
|
+
# item - order item
|
90
|
+
# item - order item
|
91
|
+
# item
|
92
|
+
# "
|
93
|
+
#
|
94
|
+
order_items = {item: order_items, attributes!: { item: { "xsi:type" => "ns2:Map"}, value: {"SOAP-ENC:arrayType" => "ns2:Map[2]", "xsi:type" => "SOAP-ENV:Array"} }}
|
95
|
+
order[:order][:item] = shipping_information
|
96
|
+
|
97
|
+
order[:order][:item].push({
|
98
|
+
key: 'items',
|
99
|
+
value: order_items
|
100
|
+
})
|
101
|
+
|
102
|
+
response = soap_client(ORDER_API_URL).call(:create_order, message: order)
|
103
|
+
response = response.body[:create_order_response][:return][:item]
|
104
|
+
|
105
|
+
if response.first[:value] == "0"
|
106
|
+
{ success: true, order_number: response.last[:value] }
|
107
|
+
else
|
108
|
+
{ success: false, error_code: response.first[:value] }
|
98
109
|
end
|
99
110
|
end
|
100
111
|
|
data/lib/zanders/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zanders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Knight
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|