ingram_micro 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +4 -0
  6. data/CODE_OF_CONDUCT.md +13 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +123 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +7 -0
  13. data/example.rb +18 -0
  14. data/ingram_micro.gemspec +38 -0
  15. data/lib/.DS_Store +0 -0
  16. data/lib/ingram_micro.rb +42 -0
  17. data/lib/ingram_micro/.DS_Store +0 -0
  18. data/lib/ingram_micro/base_element.rb +32 -0
  19. data/lib/ingram_micro/client.rb +49 -0
  20. data/lib/ingram_micro/configuration.rb +46 -0
  21. data/lib/ingram_micro/elements/credit_card_information.rb +26 -0
  22. data/lib/ingram_micro/elements/customer.rb +23 -0
  23. data/lib/ingram_micro/elements/detail.rb +19 -0
  24. data/lib/ingram_micro/elements/message_header_no_pw.rb +21 -0
  25. data/lib/ingram_micro/elements/message_header_pw.rb +22 -0
  26. data/lib/ingram_micro/elements/purchase_order_information.rb +15 -0
  27. data/lib/ingram_micro/elements/return_authorization_line_item.rb +39 -0
  28. data/lib/ingram_micro/elements/return_authorization_submission.rb +67 -0
  29. data/lib/ingram_micro/elements/return_order_header.rb +29 -0
  30. data/lib/ingram_micro/elements/sales_order_header.rb +27 -0
  31. data/lib/ingram_micro/elements/sales_order_line_item.rb +37 -0
  32. data/lib/ingram_micro/elements/sales_order_submission.rb +62 -0
  33. data/lib/ingram_micro/elements/shipment_information.rb +69 -0
  34. data/lib/ingram_micro/elements/shipment_status.rb +44 -0
  35. data/lib/ingram_micro/elements/shipment_status_line_item.rb +28 -0
  36. data/lib/ingram_micro/errors/invalid_type.rb +2 -0
  37. data/lib/ingram_micro/errors/missing_field.rb +2 -0
  38. data/lib/ingram_micro/request_processor.rb +11 -0
  39. data/lib/ingram_micro/transmission.rb +50 -0
  40. data/lib/ingram_micro/transmissions/check_shipment_status.rb +45 -0
  41. data/lib/ingram_micro/transmissions/return_authorization.rb +50 -0
  42. data/lib/ingram_micro/transmissions/sales_order.rb +55 -0
  43. data/lib/ingram_micro/version.rb +3 -0
  44. data/xsd/.DS_Store +0 -0
  45. data/xsd/BPXML_InventoryStatus.xsd +49 -0
  46. data/xsd/inbound/BPXML-LoadReject.xsd +686 -0
  47. data/xsd/inbound/BPXML-LoadSuccess.xsd +696 -0
  48. data/xsd/inbound/BPXML-ReturnReceipt.xsd +664 -0
  49. data/xsd/inbound/BPXML-ShipAdvice.xsd +758 -0
  50. data/xsd/inbound/BPXML-StandardResponse.xsd +122 -0
  51. data/xsd/outbound/BPXML-ReturnAuthorization.xsd +641 -0
  52. data/xsd/outbound/BPXML-SalesOrder.xsd +753 -0
  53. data/xsd/outbound/BPXML-ShipmentStatus.xsd +232 -0
  54. data/xsd/xml_samples/.DS_Store +0 -0
  55. data/xsd/xml_samples/Sales_order_sample.xml +143 -0
  56. metadata +227 -0
@@ -0,0 +1,26 @@
1
+ class IngramMicro::CreditCardInformation < IngramMicro::BaseElement
2
+ DEFAULTS = {
3
+ credit_card_number: nil,
4
+ credit_card_expiration_date: nil,
5
+ credit_card_identification: nil,
6
+ global_card_classification_code: nil,
7
+ card_holder_name: nil,
8
+ card_holder_address1: nil,
9
+ card_holder_address2: nil,
10
+ card_holder_city: nil,
11
+ card_holder_state: nil,
12
+ card_holder_post_code: nil,
13
+ card_holder_country_code: nil,
14
+ authorized_amount: 0.0,
15
+ billing_sequence_number: nil,
16
+ billing_authorization_response: nil,
17
+ billing_address_match: nil,
18
+ billing_zip_match: nil,
19
+ avs_hold: nil,
20
+ merchant_name: nil
21
+ }
22
+
23
+ def defaults
24
+ DEFAULTS
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ class IngramMicro::Customer < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ customer_first_name: nil,
5
+ customer_last_name: nil,
6
+ customer_middle_initial: nil,
7
+ customer_address1: nil,
8
+ customer_address2: nil,
9
+ customer_address3: nil,
10
+ customer_city: nil,
11
+ customer_state: nil,
12
+ customer_post_code: nil,
13
+ customer_country_code: nil,
14
+ customer_phone1: nil,
15
+ customer_phone2: nil,
16
+ customer_fax: nil,
17
+ customer_email: nil
18
+ }
19
+
20
+ def defaults
21
+ DEFAULTS
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ class IngramMicro::Detail < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ line_items: []
5
+ }
6
+
7
+ def defaults
8
+ DEFAULTS
9
+ end
10
+
11
+ def build(builder)
12
+ @element[:line_items].each_with_index do |line_item, idx|
13
+ line_item.line_no = idx + 1 if line_item.line_no.nil?
14
+ builder.send('line-item') do
15
+ line_item.build(builder)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ class IngramMicro::MessageHeaderNoPW < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ message_id: 0,
5
+ transaction_name: nil,
6
+ partner_name: nil,
7
+ source_url: nil,
8
+ create_timestamp: nil,
9
+ response_request: 1
10
+ }
11
+
12
+ def defaults
13
+ DEFAULTS
14
+ end
15
+
16
+ def valid?
17
+ raise IngramMicro::InvalidType.new('message_id must be a number') unless integer?(@element[:message_id])
18
+ raise IngramMicro::MissingField.new('partner_name must be present') unless @element[:partner_name]
19
+ true
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ class IngramMicro::MessageHeaderPW < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ message_id: 0,
5
+ transaction_name: nil,
6
+ partner_name: nil,
7
+ partner_password: nil,
8
+ source_url: nil,
9
+ create_timestamp: nil,
10
+ response_request: 1
11
+ }
12
+
13
+ def defaults
14
+ DEFAULTS
15
+ end
16
+
17
+ def valid?
18
+ raise IngramMicro::InvalidType.new('message_id must be a number') unless integer?(@element[:message_id])
19
+ raise IngramMicro::MissingField.new('partner_name must be present') unless @element[:partner_name]
20
+ true
21
+ end
22
+ end
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,39 @@
1
+ class IngramMicro::ReturnAuthorizationLineItem < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ line_no: nil,
5
+ line_reference: nil,
6
+ item_code: nil,
7
+ universal_product_code: nil,
8
+ product_name: nil,
9
+ comments: nil,
10
+ quantity: 0.0,
11
+ unit_of_measure: nil,
12
+ min: nil,
13
+ sid: nil,
14
+ esn: nil,
15
+ imei: nil,
16
+ market_id: nil,
17
+ line_status: nil,
18
+ base_price: 0.0,
19
+ line_discount: 0.0,
20
+ line_tax1: 0.0,
21
+ line_tax2: 0.0,
22
+ line_tax3: 0.0,
23
+ ship_date: nil,
24
+ failure_date: nil,
25
+ failure_description: nil
26
+ }
27
+
28
+ def line_no
29
+ @element[:line_no]
30
+ end
31
+
32
+ def line_no=(num)
33
+ @element[:line_no] = num
34
+ end
35
+
36
+ def defaults
37
+ DEFAULTS
38
+ end
39
+ end
@@ -0,0 +1,67 @@
1
+ class IngramMicro::ReturnAuthorizationSubmission < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ customer: nil,
5
+ shipment_information: nil,
6
+ credit_card_information: nil,
7
+ order_header: nil,
8
+ detail: nil,
9
+ purchase_order_information: nil,
10
+ customer_id: nil,
11
+ business_name: nil,
12
+ carrier_name: nil
13
+ }
14
+
15
+ def defaults
16
+ DEFAULTS
17
+ end
18
+
19
+ def initialize(options={})
20
+ super
21
+ @element[:customer] ||= IngramMicro::Customer.new
22
+ @element[:shipment_information] ||= IngramMicro::ShipmentInformation.new
23
+ @element[:credit_card_information] ||= IngramMicro::CreditCardInformation.new
24
+ @element[:order_header] ||= IngramMicro::ReturnOrderHeader.new
25
+ @element[:purchase_order_information] ||= IngramMicro::PurchaseOrderInformation.new
26
+ @element[:detail] ||= IngramMicro::Detail.new
27
+ end
28
+
29
+ def build(builder)
30
+ builder.send('header') do
31
+ builder.send 'customer-id', @element[:customer_id]
32
+ builder.send 'business-name', @element[:business_name]
33
+ builder.send 'carrier-name', @element[:carrier_name]
34
+ builder.send('customer-information') do
35
+ @element[:customer].build(builder)
36
+ end
37
+ builder.send('shipment-information') do
38
+ @element[:shipment_information].build(builder)
39
+ end
40
+ builder.send('purchase-order-information') do
41
+ @element[:purchase_order_information].build(builder)
42
+ end
43
+ builder.send('credit-card-information') do
44
+ @element[:credit_card_information].build(builder)
45
+ end
46
+ builder.send('order-header') do
47
+ @element[:order_header].build(builder)
48
+ end
49
+ end
50
+ check_line_items
51
+ builder.send('detail') do
52
+ @element[:detail].build(builder)
53
+ end
54
+ end
55
+
56
+ def check_line_items
57
+ if @element[:detail].element[:line_items].empty?
58
+ line_item = IngramMicro::ReturnAuthorizationLineItem.new
59
+ @element[:detail].element[:line_items] << line_item
60
+ end
61
+ end
62
+
63
+ def valid?
64
+ raise IngramMicro::InvalidType.new('customer_id must be a number') unless integer?(@element[:customer_id])
65
+ true
66
+ end
67
+ end
@@ -0,0 +1,29 @@
1
+ class IngramMicro::ReturnOrderHeader < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ customer_order_number: nil,
5
+ brightpoint_order_number: nil,
6
+ order_reference: nil,
7
+ customer_order_date: nil,
8
+ order_sub_total: 0.0 ,
9
+ order_discount: 0.0,
10
+ order_tax1: 0.0,
11
+ order_tax2: 0.0,
12
+ order_tax3: 0.0,
13
+ order_shipment_charge: 0.0 ,
14
+ order_total_net: 0.0 ,
15
+ order_status: nil,
16
+ order_type: nil,
17
+ return_request_expiration_date: nil
18
+ }
19
+
20
+ def defaults
21
+ DEFAULTS
22
+ end
23
+
24
+ def use_current_date?
25
+ if @element[:customer_order_date].nil?
26
+ @element[:customer_order_date] = DateTime.now.strftime("%Y%m%d")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ class IngramMicro::SalesOrderHeader < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ customer_order_number: 0,
5
+ customer_order_date: nil,
6
+ order_sub_total: 0.0,
7
+ order_discount: 0.0,
8
+ order_tax1: 0.0,
9
+ order_tax2: 0.0,
10
+ order_tax3: 0.0,
11
+ order_shipment_charge: 0.0,
12
+ order_total_net: 0.0,
13
+ order_status: nil,
14
+ order_type: nil,
15
+ gift_flag: nil
16
+ }
17
+
18
+ def defaults
19
+ DEFAULTS
20
+ end
21
+
22
+ def use_current_date?
23
+ if @element[:customer_order_date].nil?
24
+ @element[:customer_order_date] = DateTime.now.strftime('%Y%m%d')
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ class IngramMicro::SalesOrderLineItem < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ :line_no => nil,
5
+ :item_code => nil,
6
+ :universal_product_code => nil,
7
+ :product_name => nil,
8
+ :comments => nil,
9
+ :quantity => 1.0,
10
+ :unit_of_measure => nil,
11
+ :sid => nil,
12
+ :esn => nil,
13
+ :min => nil,
14
+ :mdn => nil,
15
+ :irdb => nil,
16
+ :imei => nil,
17
+ :market_id => nil,
18
+ :line_status => nil,
19
+ :base_price => 0.0,
20
+ :line_discount => 0.0,
21
+ :line_tax1 => 0.0,
22
+ :line_tax2 => 0.0,
23
+ :line_tax3 => 0.0
24
+ }
25
+
26
+ def line_no
27
+ @element[:line_no]
28
+ end
29
+
30
+ def line_no=(num)
31
+ @element[:line_no] = num
32
+ end
33
+
34
+ def defaults
35
+ DEFAULTS
36
+ end
37
+ end
@@ -0,0 +1,62 @@
1
+ class IngramMicro::SalesOrderSubmission < IngramMicro::BaseElement
2
+
3
+ DEFAULTS = {
4
+ customer: nil,
5
+ shipment_information: nil,
6
+ credit_card_information: nil,
7
+ order_header: nil,
8
+ detail: nil,
9
+ line_items: [],
10
+ customer_id: nil,
11
+ business_name: nil,
12
+ carrier_name: nil
13
+ }
14
+
15
+ def defaults
16
+ DEFAULTS
17
+ end
18
+
19
+ def initialize(options={})
20
+ super
21
+ @element[:customer] ||= IngramMicro::Customer.new
22
+ @element[:shipment_information] ||= IngramMicro::ShipmentInformation.new
23
+ @element[:credit_card_information] ||= IngramMicro::CreditCardInformation.new
24
+ @element[:order_header] ||= IngramMicro::SalesOrderHeader.new
25
+ check_line_items
26
+ @element[:detail] ||= IngramMicro::Detail.new({line_items: @element[:line_items]})
27
+ end
28
+
29
+ def build(builder)
30
+ builder.send('header') do
31
+ builder.send 'customer-id', @element[:customer_id]
32
+ builder.send 'business-name', @element[:business_name]
33
+ builder.send 'carrier-name', @element[:carrier_name]
34
+ builder.send('customer-information') do
35
+ @element[:customer].build(builder)
36
+ end
37
+ builder.send('shipment-information') do
38
+ @element[:shipment_information].build(builder)
39
+ end
40
+ builder.send('credit-card-information') do
41
+ @element[:credit_card_information].build(builder)
42
+ end
43
+ builder.send('order-header') do
44
+ @element[:order_header].build(builder)
45
+ end
46
+ end
47
+ builder.send('detail') do
48
+ @element[:detail].build(builder)
49
+ end
50
+ end
51
+
52
+ def check_line_items
53
+ if @element[:line_items].empty?
54
+ line_item = IngramMicro::SalesOrderLineItem.new
55
+ @element[:line_items] << line_item
56
+ end
57
+ end
58
+
59
+ def valid?
60
+ true
61
+ end
62
+ end
@@ -0,0 +1,69 @@
1
+ class IngramMicro::ShipmentInformation < IngramMicro::BaseElement
2
+
3
+ SHIPPING_METHODS = {
4
+ 'FX01' => 'FedEx Standard Overnight',
5
+ 'FXAM' => 'FedEx Priority Overnight',
6
+ 'FX2D' => 'FedEx Second Day',
7
+ 'FXSP' => 'FedEx Smart Post',
8
+ 'FXIE' => 'FedEx International Economy',
9
+ 'FXIP' => 'FedEx International Priority',
10
+ 'FXSV' => 'FedEx Express saver (3 day)',
11
+ 'USPP' => 'Postal Priority',
12
+ 'GGRNDP' => 'Ground shipping',
13
+ 'FXL1' => 'FedEx Freight Overnight (Air)',
14
+ 'FXL2' => 'FedEx Freight 2-day (Air)',
15
+ 'FXL3' => 'FedEx Freight 3-day (Air)',
16
+ 'FXLE' => 'FedEx Freight Ground',
17
+ }
18
+
19
+ DEFAULTS = {
20
+ ship_first_name: nil,
21
+ ship_last_name: nil,
22
+ ship_middle_initial: nil,
23
+ ship_address1: nil,
24
+ ship_address2: nil,
25
+ ship_address3: nil,
26
+ ship_city: nil,
27
+ ship_state: nil,
28
+ ship_post_code: nil,
29
+ ship_country_code: nil,
30
+ ship_phone1: nil,
31
+ ship_phone2: nil,
32
+ ship_fax: nil,
33
+ ship_email: nil,
34
+ ship_via: nil,
35
+ ship_request_date: nil,
36
+ ship_request_from: nil,
37
+ ship_request_warehouse: nil
38
+ }
39
+
40
+ def defaults
41
+ DEFAULTS
42
+ end
43
+
44
+ def valid_shipping_methods?
45
+ shipping_method = element[:ship_via]
46
+ !!SHIPPING_METHODS[shipping_method]
47
+ end
48
+
49
+ def shipping_method_name
50
+ if valid_shipping_methods?
51
+ SHIPPING_METHODS[element[:ship_via]]
52
+ else
53
+ 'Invalid shipping code'
54
+ end
55
+ end
56
+
57
+ def build(builder)
58
+ add_ship_address2
59
+ super(builder)
60
+ end
61
+
62
+ def add_ship_address2
63
+ element[:ship_address2] = ' ' unless element[:ship_address2]
64
+ end
65
+
66
+ def valid?
67
+ true
68
+ end
69
+ end