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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ced56ce6b64dcb31798c34be03efc8e9637738b8
4
- data.tar.gz: bef3a1e41d54ebcbc42ca13a90b61c19d64ca433
3
+ metadata.gz: ae29cf578fd9c5601075983aae88cbb12ba141bd
4
+ data.tar.gz: a2db6217061f0febba1a4ff9c60117a18bf92532
5
5
  SHA512:
6
- metadata.gz: 3591785159a554ca1837e4af5cc0e73541d3220e3d18bfbee23303d9c44763609c02ef1b5b6484f00453a0092b78e9ad54ef0c4d24999cb2fc5ce07e806c684e
7
- data.tar.gz: a097e58b06d3ad2cde84e3feb02d79d4b739bf749340327d084e22dbbf31e4d5e1dfe2b8b93da64e94161054eaa917fe16485f728ddeb0cc07021b585dcc29bd
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
- order_header: nil,
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[:order_header] ||= IngramMicro::SalesOrderHeader.new
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[:order_header].build(builder)
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.order_builder.doc).each do |error|
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
- raise Exception('order_builder needs to be implemented in subclass')
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.order_builder.to_xml)
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 order_builder
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 order_builder
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, :order_header,
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
- @order_header = options[:order_header]
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 order_builder
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
- order_header: order_header,
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
@@ -12,7 +12,7 @@ class IngramMicro::StandardResponse < IngramMicro::Transmission
12
12
  @filename = options[:filename]
13
13
  end
14
14
 
15
- def order_builder
15
+ def xml_builder
16
16
  @builder ||= Nokogiri::XML::Builder.new do |builder|
17
17
  builder.message do
18
18
  add_message_header(builder)
@@ -1,3 +1,3 @@
1
1
  module IngramMicro
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ingram_micro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Christel