ingram_micro 0.1.4 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/ingram_micro.gemspec +3 -1
  3. data/lib/ingram_micro.rb +5 -0
  4. data/lib/ingram_micro/base_element.rb +0 -7
  5. data/lib/ingram_micro/elements/credit_card_information.rb +0 -1
  6. data/lib/ingram_micro/elements/outbound_purchase_order_information.rb +21 -0
  7. data/lib/ingram_micro/elements/{shipment_information.rb → outbound_shipment_information.rb} +1 -1
  8. data/lib/ingram_micro/elements/return_authorization_submission.rb +2 -2
  9. data/lib/ingram_micro/elements/sales_order_shipment_information.rb +1 -1
  10. data/lib/ingram_micro/elements/sales_order_submission.rb +7 -2
  11. data/lib/ingram_micro/inbound_base_element.rb +16 -0
  12. data/lib/ingram_micro/inbound_elements/inbound_detail.rb +12 -0
  13. data/lib/ingram_micro/inbound_elements/inbound_line_item.rb +110 -0
  14. data/lib/ingram_micro/inbound_elements/inbound_order_header.rb +67 -0
  15. data/lib/ingram_micro/inbound_elements/inbound_purchase_order_information.rb +23 -0
  16. data/lib/ingram_micro/inbound_elements/inbound_shipment_information.rb +75 -0
  17. data/lib/ingram_micro/inbound_elements/inventory_sync.rb +16 -0
  18. data/lib/ingram_micro/inbound_elements/inventory_sync_detail.rb +12 -0
  19. data/lib/ingram_micro/inbound_elements/inventory_sync_line_item.rb +47 -0
  20. data/lib/ingram_micro/inbound_elements/sales_order_rejection.rb +27 -0
  21. data/lib/ingram_micro/inbound_elements/sales_order_success.rb +27 -0
  22. data/lib/ingram_micro/inbound_elements/serial_numbers.rb +58 -0
  23. data/lib/ingram_micro/inbound_elements/ship_advice.rb +27 -0
  24. data/lib/ingram_micro/inbound_transmission_factory.rb +52 -0
  25. data/lib/ingram_micro/transmission.rb +3 -3
  26. data/lib/ingram_micro/transmissions/check_shipment_status.rb +1 -0
  27. data/lib/ingram_micro/transmissions/failure_response.rb +9 -0
  28. data/lib/ingram_micro/transmissions/return_authorization.rb +2 -0
  29. data/lib/ingram_micro/transmissions/sales_order.rb +7 -2
  30. data/lib/ingram_micro/transmissions/standard_response.rb +8 -2
  31. data/lib/ingram_micro/transmissions/success_response.rb +9 -0
  32. data/lib/ingram_micro/version.rb +1 -1
  33. data/xsd/{BPXML_InventoryStatus.xsd → inbound/BPXML_InventoryStatus.xsd} +0 -0
  34. data/xsd/{inbound → outbound}/BPXML-StandardResponse.xsd +0 -0
  35. metadata +53 -9
  36. data/lib/ingram_micro/elements/purchase_order_information.rb +0 -15
  37. data/lib/ingram_micro/request_processor.rb +0 -11
  38. data/xsd/xml_samples/Sales_order_sample.xml +0 -143
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae29cf578fd9c5601075983aae88cbb12ba141bd
4
- data.tar.gz: a2db6217061f0febba1a4ff9c60117a18bf92532
3
+ metadata.gz: 5fb97a0c9a6fe546e93cfe1bde2430d821f1831d
4
+ data.tar.gz: 7c8ab7fe0e9f17c022de3fc1ca3858ac12f40e33
5
5
  SHA512:
6
- metadata.gz: c50b9315c2ffbe9bc8d0fbd82a883e64a8a942c8af3d070d79a2e9a2ec0762f002917ce94bd79597d727c7df5574ee15df0a3ed9452cc6325736f7a2ed40b367
7
- data.tar.gz: db68618513f87dce397a6d65bc8f8b822b099d66e8f333354a81396bea34ba353a4448cb45d2921c8d70ce5874f004bf7495e3a902d3e49556ce261f4c1ada55
6
+ metadata.gz: 9aeadaf84533aacbde526c281da6ce65052483ba6443020c95ba380ac4ea8f5be6c6b97f755925a117d96e726bb18d034d70572b913d0946918950de5dfc1e32
7
+ data.tar.gz: a69df711be7acf6bba396369f4557bbb0fd9cca4f3cd539826a6a677b199a24f3e1cf577e338cee16c2e50ec9a8fe6864fea90d6fa420b30060ee9222e66a34f
@@ -6,7 +6,7 @@ require 'ingram_micro/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ingram_micro"
8
8
  spec.version = IngramMicro::VERSION
9
- spec.authors = ["Ben Christel", "Rachel Heaton", "Colby Holliday", "Joseph Nguyen"]
9
+ spec.authors = ["Ben Christel", "Khaaliq DeJan", "Rachel Heaton", "Colby Holliday", "Joseph Nguyen", "Shola Oyedele"]
10
10
  spec.email = ["webops@walkerandcobrands.com"]
11
11
 
12
12
  spec.summary = %q{Rubygem wrapper for Ingram Micro API}
@@ -30,10 +30,12 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "faraday_middleware"
31
31
  spec.add_dependency "nokogiri", "~> 1.6"
32
32
  spec.add_dependency "require_all"
33
+ spec.add_dependency "nori"
33
34
  spec.add_development_dependency "bundler", "~> 1.10"
34
35
  spec.add_development_dependency "rake", "~> 10.0"
35
36
  spec.add_development_dependency "rspec"
36
37
  spec.add_development_dependency "pry"
37
38
  spec.add_development_dependency "fabrication"
38
39
  spec.add_development_dependency "faker"
40
+ spec.add_development_dependency "rubocop"
39
41
  end
@@ -2,6 +2,7 @@ require "nokogiri"
2
2
  require "faraday"
3
3
  require "faraday_middleware"
4
4
  require "require_all"
5
+ require "securerandom"
5
6
  require_rel 'ingram_micro/**/*.rb'
6
7
 
7
8
  module IngramMicro
@@ -15,4 +16,8 @@ module IngramMicro
15
16
  yield configuration
16
17
  configuration.assert_valid
17
18
  end
19
+
20
+ def self.generate_order_number(prefix='')
21
+ "#{prefix}#{SecureRandom.random_number(89999) + 10000}"
22
+ end
18
23
  end
@@ -18,13 +18,6 @@ class IngramMicro::BaseElement
18
18
  end
19
19
  end
20
20
 
21
- def parse(message_hash)
22
- defaults.each do |field|
23
- element_name = field.to_s.gsub('_', '-')
24
- @element[field] = message_hash[element_name]
25
- end
26
- end
27
-
28
21
  def self.format(field, formatter)
29
22
  @formatters ||= {}
30
23
  @formatters[field] = formatter
@@ -11,7 +11,6 @@ class IngramMicro::CreditCardInformation < IngramMicro::BaseElement
11
11
  card_holder_state: nil,
12
12
  card_holder_post_code: nil,
13
13
  card_holder_country_code: nil,
14
- authorized_amount: 0.0,
15
14
  billing_sequence_number: nil,
16
15
  billing_authorization_response: nil,
17
16
  billing_address_match: nil,
@@ -0,0 +1,21 @@
1
+ class IngramMicro::OutboundPurchaseOrderInformation < IngramMicro::BaseElement
2
+ DEFAULTS = {
3
+ purchase_order_number: nil,
4
+ account_description: nil,
5
+ purchase_order_amount: 0.0,
6
+ purchase_order_event: nil,
7
+ currency_code: nil,
8
+ comments: nil
9
+ }
10
+
11
+ def initialize(options = {})
12
+ super(options)
13
+
14
+ # customer_id is always set by BaseElement, but we don't need it here
15
+ self.element.delete(:customer_id)
16
+ end
17
+
18
+ def defaults
19
+ DEFAULTS
20
+ end
21
+ end
@@ -1,4 +1,4 @@
1
- class IngramMicro::ShipmentInformation < IngramMicro::BaseElement
1
+ class IngramMicro::OutboundShipmentInformation < IngramMicro::BaseElement
2
2
 
3
3
  SHIPPING_METHODS = {
4
4
  'FX01' => 'FedEx Standard Overnight',
@@ -19,10 +19,10 @@ class IngramMicro::ReturnAuthorizationSubmission < IngramMicro::BaseElement
19
19
  def initialize(options={})
20
20
  super
21
21
  @element[:customer] ||= IngramMicro::Customer.new
22
- @element[:shipment_information] ||= IngramMicro::ShipmentInformation.new
22
+ @element[:shipment_information] ||= IngramMicro::OutboundShipmentInformation.new
23
23
  @element[:credit_card_information] ||= IngramMicro::CreditCardInformation.new
24
24
  @element[:order_header] ||= IngramMicro::ReturnAuthorizationOrderHeader.new
25
- @element[:purchase_order_information] ||= IngramMicro::PurchaseOrderInformation.new
25
+ @element[:purchase_order_information] ||= IngramMicro::OutboundPurchaseOrderInformation.new
26
26
  @element[:detail] ||= IngramMicro::Detail.new
27
27
  end
28
28
 
@@ -1,4 +1,4 @@
1
- class IngramMicro::SalesOrderShipmentInformation < IngramMicro::ShipmentInformation
1
+ class IngramMicro::SalesOrderShipmentInformation < IngramMicro::OutboundShipmentInformation
2
2
 
3
3
  DEFAULTS = DEFAULTS.merge({ ship_no_later: nil,
4
4
  no_ship_before: nil,
@@ -1,5 +1,4 @@
1
1
  class IngramMicro::SalesOrderSubmission < IngramMicro::BaseElement
2
-
3
2
  DEFAULTS = {
4
3
  customer: nil,
5
4
  sales_order_shipment_information: nil,
@@ -9,7 +8,8 @@ class IngramMicro::SalesOrderSubmission < IngramMicro::BaseElement
9
8
  line_items: [],
10
9
  customer_id: nil,
11
10
  business_name: nil,
12
- carrier_name: nil
11
+ carrier_name: nil,
12
+ purchase_order_information: nil
13
13
  }
14
14
 
15
15
  def defaults
@@ -37,6 +37,11 @@ class IngramMicro::SalesOrderSubmission < IngramMicro::BaseElement
37
37
  builder.send('shipment-information') do
38
38
  @element[:sales_order_shipment_information].build(builder)
39
39
  end
40
+ if @element[:purchase_order_information]
41
+ builder.send('purchase-order-information') do
42
+ @element[:purchase_order_information].build(builder)
43
+ end
44
+ end
40
45
  builder.send('credit-card-information') do
41
46
  @element[:credit_card_information].build(builder)
42
47
  end
@@ -0,0 +1,16 @@
1
+ class IngramMicro::InboundBaseElement
2
+ attr_accessor :hash
3
+
4
+ def initialize(hash)
5
+ @hash = hash
6
+ end
7
+
8
+ def ==(other)
9
+ self.class == other.class &&
10
+ @hash == other.hash
11
+ end
12
+
13
+ def transaction_name
14
+ return @hash['message']['message_header']['transaction_name']
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ class IngramMicro::InboundDetail < IngramMicro::InboundBaseElement
2
+
3
+ def line_items
4
+ if hash['line_item'].is_a?(Array)
5
+ hash['line_item'].map do |line_item|
6
+ IngramMicro::InboundLineItem.new(line_item)
7
+ end
8
+ else
9
+ [IngramMicro::InboundLineItem.new(hash['line_item'])]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,110 @@
1
+ class IngramMicro::InboundLineItem < IngramMicro::InboundBaseElement
2
+
3
+ def base_price
4
+ hash['base_price']
5
+ end
6
+
7
+ def bill_of_lading
8
+ hash['bill_of_lading']
9
+ end
10
+
11
+ def container_id
12
+ hash['container_id']
13
+ end
14
+
15
+ def comments
16
+ hash['comments']
17
+ end
18
+
19
+ def customer_order_date
20
+ hash['customer_order_date']
21
+ end
22
+
23
+ def line_discount
24
+ hash['line_discount']
25
+ end
26
+
27
+ def line_tax1
28
+ hash['line_tax1']
29
+ end
30
+
31
+ def line_tax2
32
+ hash['line_tax2']
33
+ end
34
+
35
+ def line_tax3
36
+ hash['line_tax3']
37
+ end
38
+
39
+ def serial_numbers
40
+ if hash['serial_list']
41
+ serial_numbers_hash = hash['serial_list']['serial_numbers']
42
+ IngramMicro::SerialNumbers.new(serial_numbers_hash)
43
+ end
44
+ end
45
+
46
+ def item_code
47
+ hash['item_code']
48
+ end
49
+
50
+ def line_no
51
+ hash['line_no']
52
+ end
53
+
54
+ def line_reference
55
+ hash['line_reference']
56
+ end
57
+
58
+ def line_status
59
+ hash['line_status'] || ''
60
+ end
61
+
62
+ def brightpoint_line_no
63
+ hash['brightpoint_line_no']
64
+ end
65
+
66
+ def market_id
67
+ hash['market_id']
68
+ end
69
+
70
+ def pallet_id
71
+ hash['pallet_id']
72
+ end
73
+
74
+ def product_name
75
+ hash['product_name']
76
+ end
77
+
78
+ def quantity
79
+ hash['quantity']
80
+ end
81
+
82
+ def backorder_quantity
83
+ hash['backorder_quantity']
84
+ end
85
+
86
+ def rejection_date
87
+ hash['rejection_date']
88
+ end
89
+
90
+ def scac
91
+ hash['scac']
92
+ end
93
+
94
+ def ship_quantity
95
+ hash['ship_quantity']
96
+ end
97
+
98
+ def special_message
99
+ hash['special_message']
100
+ end
101
+
102
+ def unit_of_measure
103
+ hash['unit_of_measure']
104
+ end
105
+
106
+ def universal_product_code
107
+ hash['universal_product_code']
108
+ end
109
+
110
+ end
@@ -0,0 +1,67 @@
1
+ class IngramMicro::InboundOrderHeader < IngramMicro::InboundBaseElement
2
+
3
+ def customer_order_number
4
+ hash['customer_order_number']
5
+ end
6
+
7
+ def customer_order_date
8
+ hash['customer_order_date']
9
+ end
10
+
11
+ def order_sub_total
12
+ hash['order_sub_total']
13
+ end
14
+
15
+ def order_discount
16
+ hash['order_discount']
17
+ end
18
+
19
+ def order_tax1
20
+ hash['order_tax1']
21
+ end
22
+
23
+ def order_tax2
24
+ hash['order_tax2']
25
+ end
26
+
27
+ def order_tax3
28
+ hash['order_tax3']
29
+ end
30
+
31
+ def order_shipment_charge
32
+ hash['order_shipment_charge']
33
+ end
34
+
35
+ def order_total_net
36
+ hash['order_total_net']
37
+ end
38
+
39
+ def order_status
40
+ hash['order_status']
41
+ end
42
+
43
+ def order_type
44
+ hash['order_type']
45
+ end
46
+
47
+ def brightpoint_order_number
48
+ hash['brightpoint_order_number']
49
+ end
50
+
51
+ def warehouse_id
52
+ hash['warehouse_id']
53
+ end
54
+
55
+ def ship_date
56
+ hash['ship_date']
57
+ end
58
+
59
+ def order_reference
60
+ hash['order_reference']
61
+ end
62
+
63
+ def gift_flag
64
+ hash['gift_flag']
65
+ end
66
+
67
+ end
@@ -0,0 +1,23 @@
1
+ class IngramMicro::InboundPurchaseOrderInformation < IngramMicro::InboundBaseElement
2
+
3
+ def purchase_order_number
4
+ hash['purchase_order_number']
5
+ end
6
+
7
+ def account_description
8
+ hash['account_description']
9
+ end
10
+
11
+ def purchase_order_amount
12
+ hash['purchase_order_amount']
13
+ end
14
+
15
+ def currency_code
16
+ hash['currency_code']
17
+ end
18
+
19
+ def comments
20
+ hash['comments']
21
+ end
22
+
23
+ end
@@ -0,0 +1,75 @@
1
+ class IngramMicro::InboundShipmentInformation < IngramMicro::InboundBaseElement
2
+
3
+ def ship_first_name
4
+ hash['ship_first_name']
5
+ end
6
+
7
+ def ship_last_name
8
+ hash['ship_last_name']
9
+ end
10
+
11
+ def ship_middle_initial
12
+ hash['ship_middle_initial']
13
+ end
14
+
15
+ def ship_address1
16
+ hash['ship_address1']
17
+ end
18
+
19
+ def ship_address2
20
+ hash['ship_address2']
21
+ end
22
+
23
+ def ship_address3
24
+ hash['ship_address3']
25
+ end
26
+
27
+ def ship_city
28
+ hash['ship_city']
29
+ end
30
+
31
+ def ship_state
32
+ hash['ship_state']
33
+ end
34
+
35
+ def ship_post_code
36
+ hash['ship_post_code']
37
+ end
38
+
39
+ def ship_country_code
40
+ hash['ship_country_code']
41
+ end
42
+
43
+ def ship_phone1
44
+ hash['ship_phone1']
45
+ end
46
+
47
+ def ship_phone2
48
+ hash['ship_phone2']
49
+ end
50
+
51
+ def ship_fax
52
+ hash['ship_fax']
53
+ end
54
+
55
+ def ship_email
56
+ hash['ship_email']
57
+ end
58
+
59
+ def ship_via
60
+ hash['ship_via']
61
+ end
62
+
63
+ def ship_request_date
64
+ hash['ship_request_date']
65
+ end
66
+
67
+ def ship_request_from
68
+ hash['ship_request_from']
69
+ end
70
+
71
+ def ship_request_warehouse
72
+ hash['ship_request_warehouse']
73
+ end
74
+
75
+ end
@@ -0,0 +1,16 @@
1
+ class IngramMicro::InventorySync < IngramMicro::InboundBaseElement
2
+
3
+ def message_header
4
+ @hash['message']['message_header']
5
+ end
6
+
7
+ def inventory_status
8
+ @hash['message']['inventory_synchronization']
9
+ end
10
+
11
+ def detail
12
+ detail = @hash['message']['inventory_synchronization']['detail']
13
+ IngramMicro::InventorySyncDetail.new(detail)
14
+ end
15
+
16
+ end
@@ -0,0 +1,12 @@
1
+ class IngramMicro::InventorySyncDetail < IngramMicro::InboundBaseElement
2
+
3
+ def line_items
4
+ if hash['line_item'].is_a?(Array)
5
+ hash['line_item'].map do |line_item|
6
+ IngramMicro::InventorySyncLineItem.new(line_item)
7
+ end
8
+ else
9
+ [IngramMicro::InventorySyncLineItem.new(hash['line_item'])]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,47 @@
1
+ class IngramMicro::InventorySyncLineItem < IngramMicro::InboundBaseElement
2
+
3
+ def line_no
4
+ hash['line_no'].to_i
5
+ end
6
+
7
+ def transaction_document_number
8
+ hash['transaction_document_number']
9
+ end
10
+
11
+ def item_code
12
+ hash['item_code']
13
+ end
14
+
15
+ def universal_product_code
16
+ hash['universal_product_code'].to_i
17
+ end
18
+
19
+ def warehouse_id
20
+ hash['warehouse_id']
21
+ end
22
+
23
+ def unit_of_measure
24
+ hash['unit_of_measure']
25
+ end
26
+
27
+ def quantity_on_hand
28
+ hash['quantity_on_hand'].to_i
29
+ end
30
+
31
+ def quantity_committed
32
+ hash['quantity_committed'].to_i
33
+ end
34
+
35
+ def quantity_available
36
+ hash['quantity_available'].to_i
37
+ end
38
+
39
+ def quantity_on_back_order
40
+ hash['quantity_on_back_order'].to_i
41
+ end
42
+
43
+ def synchronization_timestamp
44
+ hash['synchronization_timestamp'].to_i
45
+ end
46
+
47
+ end
@@ -0,0 +1,27 @@
1
+ class IngramMicro::SalesOrderRejection < IngramMicro::InboundBaseElement
2
+
3
+ def customer_id
4
+ hash['message']['sales_order_rejection']['header']['customer_id']
5
+ end
6
+
7
+ def shipment_information
8
+ shipment_information_hash = hash['message']['sales_order_rejection']['header']['shipment_information']
9
+ IngramMicro::InboundShipmentInformation.new(shipment_information_hash)
10
+ end
11
+
12
+ def purchase_order_information
13
+ purchase_order_information_hash = hash['message']['sales_order_rejection']['header']['purchase_order_information']
14
+ IngramMicro::InboundPurchaseOrderInformation.new(purchase_order_information_hash)
15
+ end
16
+
17
+ def order_header
18
+ order_header_hash = hash['message']['sales_order_rejection']['header']['order_header']
19
+ IngramMicro::InboundOrderHeader.new(order_header_hash)
20
+ end
21
+
22
+ def detail
23
+ detail_hash = hash['message']['sales_order_rejection']['detail']
24
+ IngramMicro::InboundDetail.new(detail_hash)
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ class IngramMicro::SalesOrderSuccess < IngramMicro::InboundBaseElement
2
+
3
+ def customer_id
4
+ hash['message']['sales_order_success']['header']['customer_id']
5
+ end
6
+
7
+ def shipment_information
8
+ shipment_information_hash = hash['message']['sales_order_success']['header']['shipment_information']
9
+ IngramMicro::InboundShipmentInformation.new(shipment_information_hash)
10
+ end
11
+
12
+ def purchase_order_information
13
+ purchase_order_information_hash = hash['message']['sales_order_success']['header']['purchase_order_information']
14
+ IngramMicro::InboundPurchaseOrderInformation.new(purchase_order_information_hash)
15
+ end
16
+
17
+ def order_header
18
+ order_header_hash = hash['message']['sales_order_success']['header']['order_header']
19
+ IngramMicro::InboundOrderHeader.new(order_header_hash)
20
+ end
21
+
22
+ def detail
23
+ detail_hash = hash['message']['sales_order_success']['detail']
24
+ IngramMicro::InboundDetail.new(detail_hash)
25
+ end
26
+
27
+ end
@@ -0,0 +1,58 @@
1
+ class IngramMicro::SerialNumbers < IngramMicro::InboundBaseElement
2
+
3
+ def min
4
+ hash['min']
5
+ end
6
+
7
+ def sid
8
+ hash['sid']
9
+ end
10
+
11
+ def mdn
12
+ hash['mdn']
13
+ end
14
+
15
+ def esn
16
+ hash['esn']
17
+ end
18
+
19
+ def sim
20
+ hash['sim']
21
+ end
22
+
23
+ def imei
24
+ hash['imei']
25
+ end
26
+
27
+ def sublock1
28
+ hash['sublock1']
29
+ end
30
+
31
+ def sublock2
32
+ hash['sublock2']
33
+ end
34
+
35
+ def sublock3
36
+ hash['sublock3']
37
+ end
38
+
39
+ def irdb
40
+ hash['irdb']
41
+ end
42
+
43
+ def meid
44
+ hash['meid']
45
+ end
46
+
47
+ def iccid
48
+ hash['iccid']
49
+ end
50
+
51
+ def macid
52
+ hash['macid']
53
+ end
54
+
55
+ def pesn
56
+ hash['pesn']
57
+ end
58
+ end
@@ -0,0 +1,27 @@
1
+ class IngramMicro::ShipAdvice < IngramMicro::InboundBaseElement
2
+
3
+ def customer_id
4
+ @hash['message']['ship_advice']['header']['customer_id']
5
+ end
6
+
7
+ def shipment_information
8
+ shipment_information_hash = @hash['message']['ship_advice']['header']['shipment_information']
9
+ IngramMicro::InboundShipmentInformation.new(shipment_information_hash)
10
+ end
11
+
12
+ def purchase_order_information
13
+ purchase_order_information_hash = @hash['message']['ship_advice']['header']['purchase_order_information']
14
+ IngramMicro::InboundPurchaseOrderInformation.new(purchase_order_information_hash)
15
+ end
16
+
17
+ def order_header
18
+ order_header_hash = @hash['message']['ship_advice']['header']['order_header']
19
+ IngramMicro::InboundOrderHeader.new(order_header_hash)
20
+ end
21
+
22
+ def detail
23
+ detail_hash = @hash['message']['ship_advice']['detail']
24
+ IngramMicro::InboundDetail.new(detail_hash)
25
+ end
26
+
27
+ end
@@ -0,0 +1,52 @@
1
+ require 'nori'
2
+
3
+ class IngramMicro::InboundTransmissionFactory
4
+ attr_reader :request_body_string
5
+
6
+ def self.from_xml(request_body_string)
7
+ new(request_body_string).from_xml
8
+ end
9
+
10
+ def initialize(request_body_string)
11
+ begin
12
+ Nokogiri::XML(request_body_string) do |config|
13
+ config.options = Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NONET
14
+ end
15
+ rescue Nokogiri::SyntaxError => e
16
+ raise Error, "#{self.class.name} received malformed XML: #{request_body_string}: #{e.message}"
17
+ end
18
+
19
+ @request_body_string = request_body_string
20
+ end
21
+
22
+ def from_xml
23
+ inbound_transmission_class.new(request_hash)
24
+ end
25
+
26
+ private
27
+
28
+ def inbound_transmission_class
29
+ case transaction_name
30
+ when 'sales-order-success'
31
+ IngramMicro::SalesOrderSuccess
32
+ when 'sales-order-rejection'
33
+ IngramMicro::SalesOrderRejection
34
+ when 'ship-advice'
35
+ IngramMicro::ShipAdvice
36
+ when 'inventory-synchronization'
37
+ IngramMicro::InventorySync
38
+ else
39
+ raise Error, "#{self.class.name} received unrecognized transaction-name: #{transaction_name}"
40
+ end
41
+ end
42
+
43
+ def transaction_name
44
+ request_hash['message']['message_header']['transaction_name']
45
+ end
46
+
47
+ def request_hash
48
+ @request_hash ||= Nori.new.parse(request_body_string)
49
+ end
50
+
51
+ class Error < StandardError; end
52
+ end
@@ -4,11 +4,11 @@ class IngramMicro::Transmission
4
4
  'sales-order-submission' => 'outbound/BPXML-SalesOrder.xsd',
5
5
  'shipment-status' => 'outbound/BPXML-ShipmentStatus.xsd',
6
6
  'return-authorization' => 'outbound/BPXML-ReturnAuthorization.xsd',
7
+ 'standard-response' => 'outbound/BPXML-StandardResponse.xsd',
7
8
  'load-reject' => 'inbound/BPXML-LoadReject.xsd',
8
9
  'load-success' => 'inbound/BPXML-LoadSuccess.xsd',
9
10
  'return-receipt' => 'inbound/BPXML-ReturnReceipt.xsd',
10
- 'ship-advice' => 'inbound/BPXML-ShipAdvice.xsd',
11
- 'standard-response' => 'inbound/BPXML-StandardResponse.xsd',
11
+ 'ship-advice' => 'inbound/BPXML-ShipAdvice.xsd'
12
12
  }
13
13
 
14
14
  attr_reader :errors, :transaction_name
@@ -19,7 +19,7 @@ class IngramMicro::Transmission
19
19
 
20
20
  def schema_valid?
21
21
  xsd = Nokogiri::XML::Schema(File.read("#{IngramMicro::GEM_DIR}/xsd/" +
22
- XSD[self.transaction_name]))
22
+ XSD[self.class::TRANSMISSION_FILENAME]))
23
23
  valid = true
24
24
  xsd.validate(self.xml_builder.doc).each do |error|
25
25
  errors << error.message
@@ -1,4 +1,5 @@
1
1
  class IngramMicro::CheckShipmentStatus < IngramMicro::Transmission
2
+ TRANSMISSION_FILENAME = 'shipment-status'
2
3
 
3
4
  attr_accessor :business_name, :customer_id, :line_items
4
5
 
@@ -0,0 +1,9 @@
1
+ class IngramMicro::FailureResponse < IngramMicro::StandardResponse
2
+ DESCRIPTION = "Message Failure"
3
+
4
+ def initialize(options={})
5
+ options[:status_code] = -1
6
+ options[:status_description] = DESCRIPTION
7
+ super(options)
8
+ end
9
+ end
@@ -1,4 +1,6 @@
1
1
  class IngramMicro::ReturnAuthorization < IngramMicro::Transmission
2
+ TRANSMISSION_FILENAME = 'return-authorization'
3
+
2
4
  attr_accessor :customer, :credit_card_information, :order_header,
3
5
  :shipment_information, :detail, :purchase_order_information
4
6
 
@@ -1,7 +1,9 @@
1
1
  class IngramMicro::SalesOrder < IngramMicro::Transmission
2
+ TRANSMISSION_FILENAME = 'sales-order-submission'
3
+
2
4
  attr_accessor :customer, :credit_card_information, :sales_order_header,
3
5
  :sales_order_shipment_information, :detail, :carrier_name, :business_name,
4
- :customer_id
6
+ :customer_id, :purchase_order_information
5
7
 
6
8
  def initialize(options={})
7
9
  super(options)
@@ -14,6 +16,8 @@ class IngramMicro::SalesOrder < IngramMicro::Transmission
14
16
  @business_name = options[:business_name]
15
17
  @customer_id = options[:customer_id]
16
18
  @carrier_name = options[:carrier_name]
19
+ @purchase_order_information = options[:purchase_order_information]
20
+
17
21
  validate_options(options)
18
22
  end
19
23
 
@@ -46,7 +50,8 @@ class IngramMicro::SalesOrder < IngramMicro::Transmission
46
50
  customer: customer,
47
51
  sales_order_shipment_information: sales_order_shipment_information,
48
52
  sales_order_header: sales_order_header,
49
- credit_card_information: credit_card_information
53
+ credit_card_information: credit_card_information,
54
+ purchase_order_information: purchase_order_information
50
55
  }
51
56
  sos = IngramMicro::SalesOrderSubmission.new(sos_options)
52
57
  builder.send('sales-order-submission') do
@@ -1,10 +1,12 @@
1
1
  class IngramMicro::StandardResponse < IngramMicro::Transmission
2
+ TRANSMISSION_FILENAME = 'standard-response'
3
+
2
4
  attr_accessor :status_code, :status_description, :comments,
3
- :response_timestamp, :filename
5
+ :response_timestamp, :filename, :transaction_name
4
6
 
5
7
  def initialize(options={})
6
8
  super(options)
7
- @transaction_name = 'standard-response'
9
+ @transaction_name = options[:transaction_name]
8
10
  @status_code = options[:status_code]
9
11
  @status_description = options[:status_description]
10
12
  @comments = options[:comments]
@@ -12,6 +14,10 @@ class IngramMicro::StandardResponse < IngramMicro::Transmission
12
14
  @filename = options[:filename]
13
15
  end
14
16
 
17
+ def to_xml(opts={})
18
+ xml_builder.to_xml
19
+ end
20
+
15
21
  def xml_builder
16
22
  @builder ||= Nokogiri::XML::Builder.new do |builder|
17
23
  builder.message do
@@ -0,0 +1,9 @@
1
+ class IngramMicro::SuccessResponse < IngramMicro::StandardResponse
2
+ DESCRIPTION = "Message Success"
3
+
4
+ def initialize(options={})
5
+ options[:status_code] = 0
6
+ options[:status_description] = DESCRIPTION
7
+ super(options)
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module IngramMicro
2
- VERSION = "0.1.4"
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,17 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ingram_micro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Christel
8
+ - Khaaliq DeJan
8
9
  - Rachel Heaton
9
10
  - Colby Holliday
10
11
  - Joseph Nguyen
12
+ - Shola Oyedele
11
13
  autorequire:
12
14
  bindir: exe
13
15
  cert_chain: []
14
- date: 2016-06-29 00:00:00.000000000 Z
16
+ date: 2016-08-09 00:00:00.000000000 Z
15
17
  dependencies:
16
18
  - !ruby/object:Gem::Dependency
17
19
  name: faraday
@@ -69,6 +71,20 @@ dependencies:
69
71
  - - ">="
70
72
  - !ruby/object:Gem::Version
71
73
  version: '0'
74
+ - !ruby/object:Gem::Dependency
75
+ name: nori
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ type: :runtime
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
72
88
  - !ruby/object:Gem::Dependency
73
89
  name: bundler
74
90
  requirement: !ruby/object:Gem::Requirement
@@ -153,6 +169,20 @@ dependencies:
153
169
  - - ">="
154
170
  - !ruby/object:Gem::Version
155
171
  version: '0'
172
+ - !ruby/object:Gem::Dependency
173
+ name: rubocop
174
+ requirement: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ type: :development
180
+ prerelease: false
181
+ version_requirements: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
156
186
  description:
157
187
  email:
158
188
  - webops@walkerandcobrands.com
@@ -184,7 +214,8 @@ files:
184
214
  - lib/ingram_micro/elements/message_header_no_pw.rb
185
215
  - lib/ingram_micro/elements/message_header_pw.rb
186
216
  - lib/ingram_micro/elements/message_status.rb
187
- - lib/ingram_micro/elements/purchase_order_information.rb
217
+ - lib/ingram_micro/elements/outbound_purchase_order_information.rb
218
+ - lib/ingram_micro/elements/outbound_shipment_information.rb
188
219
  - lib/ingram_micro/elements/return_authorization_line_item.rb
189
220
  - lib/ingram_micro/elements/return_authorization_order_header.rb
190
221
  - lib/ingram_micro/elements/return_authorization_submission.rb
@@ -192,29 +223,42 @@ files:
192
223
  - lib/ingram_micro/elements/sales_order_line_item.rb
193
224
  - lib/ingram_micro/elements/sales_order_shipment_information.rb
194
225
  - lib/ingram_micro/elements/sales_order_submission.rb
195
- - lib/ingram_micro/elements/shipment_information.rb
196
226
  - lib/ingram_micro/elements/shipment_status.rb
197
227
  - lib/ingram_micro/elements/shipment_status_line_item.rb
198
228
  - lib/ingram_micro/errors/invalid_type.rb
199
229
  - lib/ingram_micro/errors/missing_field.rb
230
+ - lib/ingram_micro/inbound_base_element.rb
231
+ - lib/ingram_micro/inbound_elements/inbound_detail.rb
232
+ - lib/ingram_micro/inbound_elements/inbound_line_item.rb
233
+ - lib/ingram_micro/inbound_elements/inbound_order_header.rb
234
+ - lib/ingram_micro/inbound_elements/inbound_purchase_order_information.rb
235
+ - lib/ingram_micro/inbound_elements/inbound_shipment_information.rb
236
+ - lib/ingram_micro/inbound_elements/inventory_sync.rb
237
+ - lib/ingram_micro/inbound_elements/inventory_sync_detail.rb
238
+ - lib/ingram_micro/inbound_elements/inventory_sync_line_item.rb
239
+ - lib/ingram_micro/inbound_elements/sales_order_rejection.rb
240
+ - lib/ingram_micro/inbound_elements/sales_order_success.rb
241
+ - lib/ingram_micro/inbound_elements/serial_numbers.rb
242
+ - lib/ingram_micro/inbound_elements/ship_advice.rb
243
+ - lib/ingram_micro/inbound_transmission_factory.rb
200
244
  - lib/ingram_micro/null_formatter.rb
201
- - lib/ingram_micro/request_processor.rb
202
245
  - lib/ingram_micro/transmission.rb
203
246
  - lib/ingram_micro/transmissions/check_shipment_status.rb
247
+ - lib/ingram_micro/transmissions/failure_response.rb
204
248
  - lib/ingram_micro/transmissions/return_authorization.rb
205
249
  - lib/ingram_micro/transmissions/sales_order.rb
206
250
  - lib/ingram_micro/transmissions/standard_response.rb
251
+ - lib/ingram_micro/transmissions/success_response.rb
207
252
  - lib/ingram_micro/version.rb
208
- - xsd/BPXML_InventoryStatus.xsd
209
253
  - xsd/inbound/BPXML-LoadReject.xsd
210
254
  - xsd/inbound/BPXML-LoadSuccess.xsd
211
255
  - xsd/inbound/BPXML-ReturnReceipt.xsd
212
256
  - xsd/inbound/BPXML-ShipAdvice.xsd
213
- - xsd/inbound/BPXML-StandardResponse.xsd
257
+ - xsd/inbound/BPXML_InventoryStatus.xsd
214
258
  - xsd/outbound/BPXML-ReturnAuthorization.xsd
215
259
  - xsd/outbound/BPXML-SalesOrder.xsd
216
260
  - xsd/outbound/BPXML-ShipmentStatus.xsd
217
- - xsd/xml_samples/Sales_order_sample.xml
261
+ - xsd/outbound/BPXML-StandardResponse.xsd
218
262
  homepage: https://github.com/WalkerAndCoBrandsInc/ingram_micro
219
263
  licenses:
220
264
  - MIT
@@ -236,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
280
  version: '0'
237
281
  requirements: []
238
282
  rubyforge_project:
239
- rubygems_version: 2.2.3
283
+ rubygems_version: 2.4.8
240
284
  signing_key:
241
285
  specification_version: 4
242
286
  summary: Rubygem wrapper for Ingram Micro API
@@ -1,15 +0,0 @@
1
- class IngramMicro::PurchaseOrderInformation < IngramMicro::BaseElement
2
-
3
- DEFAULTS = {
4
- purchase_order_number: nil,
5
- account_description: nil,
6
- purchase_order_amount: 0.0,
7
- purchase_order_event: nil,
8
- currency_code: nil,
9
- comments: nil
10
- }
11
-
12
- def defaults
13
- DEFAULTS
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- class IngramMicro::RequestProcessor
2
- attr_accessor :body_xml
3
-
4
- def initialize(request)
5
- @body_xml = Nokogiri::XML(request.body.read).to_xml
6
- end
7
-
8
- def hashify
9
- Hash.from_xml(@body_xml)
10
- end
11
- end
@@ -1,143 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE message SYSTEM "http://www.brightpoint.com:7800/best/dtd/SaleOrder.dtd">
3
- <message>
4
- <message-header>
5
- <message-id>178329</message-id>
6
- <transaction-name>sales-order-submission</transaction-name>
7
- <partner-name>usfi</partner-name>
8
- <partner-password/>
9
- <source-url>http://www.customer.com</source-url>
10
- <create-timestamp>20100415145015</create-timestamp>
11
- <response-request>1</response-request>
12
- </message-header>
13
- <sales-order-submission>
14
- <header>
15
- <customer-id>286104</customer-id>
16
- <business-name>customer</business-name>
17
- <carrier-name>FEDEX</carrier-name>
18
- <customer-information>
19
- <customer-first-name/>
20
- <customer-last-name/>
21
- <customer-middle-initial/>
22
- <customer-address1/>
23
- <customer-address2/>
24
- <customer-address3/>
25
- <customer-city/>
26
- <customer-state/>
27
- <customer-post-code/>
28
- <customer-country-code/>
29
- <customer-phone1/>
30
- <customer-phone2/>
31
- <customer-fax/>
32
- <customer-email/>
33
- </customer-information>
34
- <shipment-information>
35
- <ship-first-name>Name 1</ship-first-name>
36
- <ship-last-name>Name 2</ship-last-name>
37
- <ship-middle-initial/>
38
- <ship-address1>6229 WEST 16 AVE </ship-address1>
39
- <ship-address2/>
40
- <ship-address3/>
41
- <ship-city>Somewhere</ship-city>
42
- <ship-state>IN</ship-state>
43
- <ship-post-code>12345</ship-post-code>
44
- <ship-country-code>US</ship-country-code>
45
- <ship-phone1>(317)555-8202</ship-phone1>
46
- <ship-phone2/>
47
- <ship-fax/>
48
- <ship-email>customer@yahoo.com</ship-email>
49
- <ship-via>SFXSVP</ship-via>
50
- <ship-request-date>20100415</ship-request-date>
51
- <ship-request-from>Indianapolis</ship-request-from>
52
- <ship-request-warehouse>whse1</ship-request-warehouse>
53
- </shipment-information>
54
- <purchase-order-information>
55
- <purchase-order-number>178329</purchase-order-number>
56
- <account-description/>
57
- <purchase-order-amount/>
58
- <currency-code>USD</currency-code>
59
- <comments/>
60
- </purchase-order-information>
61
- <credit-card-information>
62
- <credit-card-number/>
63
- <credit-card-expiration-date/>
64
- <credit-card-identification/>
65
- <global-card-classification-code/>
66
- <card-holder-name/>
67
- <card-holder-address1/>
68
- <card-holder-address2/>
69
- <card-holder-city/>
70
- <card-holder-state/>
71
- <card-holder-post-code/>
72
- <card-holder-country-code/>
73
- <authorized-amount/>
74
- <billing-sequence-number/>
75
- <billing-authorization-response/>
76
- <billing-address-match/>
77
- <billing-zip-match/>
78
- <avs-hold/>
79
- <merchant-name/>
80
- </credit-card-information>
81
- <order-header>
82
- <customer-order-number>178329</customer-order-number>
83
- <customer-order-date>20100415</customer-order-date>
84
- <order-sub-total/>
85
- <order-discount/>
86
- <order-tax1/>
87
- <order-tax2/>
88
- <order-tax3/>
89
- <order-shipment-charge/>
90
- <order-total-net/>
91
- <order-status>SUBMITTED</order-status>
92
- <order-type>WEB SALES</order-type>
93
- <gift-flag/>
94
- </order-header>
95
- </header>
96
- <detail>
97
- <line-item>
98
- <line-no>1</line-no>
99
- <item-code>HW-M750</item-code>
100
- <universal-product-code/>
101
- <product-name>Huawei M750</product-name>
102
- <comments/>
103
- <quantity>1</quantity>
104
- <unit-of-measure>EA</unit-of-measure>
105
- <sid/>
106
- <esn/>
107
- <min/>
108
- <mdn/>
109
- <irdb/>
110
- <imei/>
111
- <market-id/>
112
- <line-status>IN STOCK</line-status>
113
- <base-price/>
114
- <line-discount/>
115
- <line-tax1/>
116
- <line-tax2/>
117
- <line-tax3/>
118
- </line-item>
119
- <line-item>
120
- <line-no>2</line-no>
121
- <item-code>HW-M750</item-code>
122
- <universal-product-code/>
123
- <product-name>Huawei M750</product-name>
124
- <comments/>
125
- <quantity>1</quantity>
126
- <unit-of-measure>EA</unit-of-measure>
127
- <sid/>
128
- <esn/>
129
- <min/>
130
- <mdn/>
131
- <irdb/>
132
- <imei/>
133
- <market-id/>
134
- <line-status>IN STOCK</line-status>
135
- <base-price/>
136
- <line-discount/>
137
- <line-tax1/>
138
- <line-tax2/>
139
- <line-tax3/>
140
- </line-item>
141
- </detail>
142
- </sales-order-submission>
143
- </message>