ingram_micro 0.1.3 → 0.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/ingram_micro/elements/sales_order_submission.rb +3 -3
- data/lib/ingram_micro/transmission.rb +8 -3
- data/lib/ingram_micro/transmissions/check_shipment_status.rb +1 -1
- data/lib/ingram_micro/transmissions/return_authorization.rb +1 -1
- data/lib/ingram_micro/transmissions/sales_order.rb +10 -4
- data/lib/ingram_micro/transmissions/standard_response.rb +1 -1
- data/lib/ingram_micro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae29cf578fd9c5601075983aae88cbb12ba141bd
|
4
|
+
data.tar.gz: a2db6217061f0febba1a4ff9c60117a18bf92532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c50b9315c2ffbe9bc8d0fbd82a883e64a8a942c8af3d070d79a2e9a2ec0762f002917ce94bd79597d727c7df5574ee15df0a3ed9452cc6325736f7a2ed40b367
|
7
|
+
data.tar.gz: db68618513f87dce397a6d65bc8f8b822b099d66e8f333354a81396bea34ba353a4448cb45d2921c8d70ce5874f004bf7495e3a902d3e49556ce261f4c1ada55
|
@@ -4,7 +4,7 @@ class IngramMicro::SalesOrderSubmission < IngramMicro::BaseElement
|
|
4
4
|
customer: nil,
|
5
5
|
sales_order_shipment_information: nil,
|
6
6
|
credit_card_information: nil,
|
7
|
-
|
7
|
+
sales_order_header: nil,
|
8
8
|
detail: nil,
|
9
9
|
line_items: [],
|
10
10
|
customer_id: nil,
|
@@ -21,7 +21,7 @@ class IngramMicro::SalesOrderSubmission < IngramMicro::BaseElement
|
|
21
21
|
@element[:customer] ||= IngramMicro::Customer.new
|
22
22
|
@element[:sales_order_shipment_information] ||= IngramMicro::SalesOrderShipmentInformation.new
|
23
23
|
@element[:credit_card_information] ||= IngramMicro::CreditCardInformation.new
|
24
|
-
@element[:
|
24
|
+
@element[:sales_order_header] ||= IngramMicro::SalesOrderHeader.new
|
25
25
|
check_line_items
|
26
26
|
@element[:detail] ||= IngramMicro::Detail.new({line_items: @element[:line_items]})
|
27
27
|
end
|
@@ -41,7 +41,7 @@ class IngramMicro::SalesOrderSubmission < IngramMicro::BaseElement
|
|
41
41
|
@element[:credit_card_information].build(builder)
|
42
42
|
end
|
43
43
|
builder.send('order-header') do
|
44
|
-
@element[:
|
44
|
+
@element[:sales_order_header].build(builder)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
builder.send('detail') do
|
@@ -21,7 +21,7 @@ class IngramMicro::Transmission
|
|
21
21
|
xsd = Nokogiri::XML::Schema(File.read("#{IngramMicro::GEM_DIR}/xsd/" +
|
22
22
|
XSD[self.transaction_name]))
|
23
23
|
valid = true
|
24
|
-
xsd.validate(self.
|
24
|
+
xsd.validate(self.xml_builder.doc).each do |error|
|
25
25
|
errors << error.message
|
26
26
|
valid = false
|
27
27
|
end
|
@@ -30,7 +30,12 @@ class IngramMicro::Transmission
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def order_builder
|
33
|
-
|
33
|
+
warn '[DEPRECATION] `order_builder` is deprecated. Please use `xml_builder` instead.'
|
34
|
+
xml_builder
|
35
|
+
end
|
36
|
+
|
37
|
+
def xml_builder
|
38
|
+
raise Exception('xml_builder needs to be implemented in subclass')
|
34
39
|
end
|
35
40
|
|
36
41
|
def add_transaction_info(builder)
|
@@ -45,6 +50,6 @@ class IngramMicro::Transmission
|
|
45
50
|
|
46
51
|
def send_request
|
47
52
|
client = IngramMicro::Client.new
|
48
|
-
client.post(self.
|
53
|
+
client.post(self.xml_builder.to_xml)
|
49
54
|
end
|
50
55
|
end
|
@@ -10,7 +10,7 @@ class IngramMicro::CheckShipmentStatus < IngramMicro::Transmission
|
|
10
10
|
@line_items = options[:line_items]
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def xml_builder
|
14
14
|
@builder ||= Nokogiri::XML::Builder.new do |builder|
|
15
15
|
builder.message do
|
16
16
|
add_message_header(builder)
|
@@ -13,7 +13,7 @@ class IngramMicro::ReturnAuthorization < IngramMicro::Transmission
|
|
13
13
|
@purchase_order_information = options[:purchase_order_information]
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def xml_builder
|
17
17
|
@builder ||= Nokogiri::XML::Builder.new do |builder|
|
18
18
|
builder.send('message') do
|
19
19
|
add_message_header(builder)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class IngramMicro::SalesOrder < IngramMicro::Transmission
|
2
|
-
attr_accessor :customer, :credit_card_information, :
|
2
|
+
attr_accessor :customer, :credit_card_information, :sales_order_header,
|
3
3
|
:sales_order_shipment_information, :detail, :carrier_name, :business_name,
|
4
4
|
:customer_id
|
5
5
|
|
@@ -9,14 +9,15 @@ class IngramMicro::SalesOrder < IngramMicro::Transmission
|
|
9
9
|
@customer = options[:customer]
|
10
10
|
@sales_order_shipment_information = options[:sales_order_shipment_information]
|
11
11
|
@credit_card_information = options[:credit_card_information]
|
12
|
-
@
|
12
|
+
@sales_order_header = options[:sales_order_header]
|
13
13
|
@detail = options[:detail]
|
14
14
|
@business_name = options[:business_name]
|
15
15
|
@customer_id = options[:customer_id]
|
16
16
|
@carrier_name = options[:carrier_name]
|
17
|
+
validate_options(options)
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
+
def xml_builder
|
20
21
|
@builder ||= Nokogiri::XML::Builder.new do |builder|
|
21
22
|
builder.message do
|
22
23
|
add_message_header(builder)
|
@@ -44,7 +45,7 @@ class IngramMicro::SalesOrder < IngramMicro::Transmission
|
|
44
45
|
carrier_name: @carrier_name,
|
45
46
|
customer: customer,
|
46
47
|
sales_order_shipment_information: sales_order_shipment_information,
|
47
|
-
|
48
|
+
sales_order_header: sales_order_header,
|
48
49
|
credit_card_information: credit_card_information
|
49
50
|
}
|
50
51
|
sos = IngramMicro::SalesOrderSubmission.new(sos_options)
|
@@ -53,4 +54,9 @@ class IngramMicro::SalesOrder < IngramMicro::Transmission
|
|
53
54
|
end
|
54
55
|
sos.valid?
|
55
56
|
end
|
57
|
+
|
58
|
+
def validate_options(options)
|
59
|
+
raise "use sales_order_shipment_information (IngramMicro::SalesOrderShipmentInformation" if options[:shipment_information]
|
60
|
+
raise "use sales_order_header (IngramMicro::SalesOrderHeader" if options[:order_header]
|
61
|
+
end
|
56
62
|
end
|
data/lib/ingram_micro/version.rb
CHANGED