Class: IngramMicro::SalesOrder

Inherits:
Transmission show all
Defined in:
lib/ingram_micro/transmissions/sales_order.rb

Constant Summary

Constants inherited from Transmission

Transmission::XSD

Instance Attribute Summary collapse

Attributes inherited from Transmission

#errors, #transaction_name

Instance Method Summary collapse

Methods inherited from Transmission

#add_transaction_info, #schema_valid?, #send_request, #submit_request

Constructor Details

#initialize(options = {}) ⇒ SalesOrder

Returns a new instance of SalesOrder.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 6

def initialize(options={})
  super(options)
  @transaction_name = 'sales-order-submission'
  @customer = options[:customer]
  @sales_order_shipment_information = options[:sales_order_shipment_information]
  @credit_card_information = options[:credit_card_information]
  @order_header = options[:order_header]
  @detail = options[:detail]
  @business_name = options[:business_name]
  @customer_id = options[:customer_id]
  @carrier_name = options[:carrier_name]
end

Instance Attribute Details

#business_nameObject

Returns the value of attribute business_name.



2
3
4
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 2

def business_name
  @business_name
end

#carrier_nameObject

Returns the value of attribute carrier_name.



2
3
4
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 2

def carrier_name
  @carrier_name
end

#credit_card_informationObject

Returns the value of attribute credit_card_information.



2
3
4
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 2

def credit_card_information
  @credit_card_information
end

#customerObject

Returns the value of attribute customer.



2
3
4
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 2

def customer
  @customer
end

#customer_idObject

Returns the value of attribute customer_id.



2
3
4
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 2

def customer_id
  @customer_id
end

#detailObject

Returns the value of attribute detail.



2
3
4
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 2

def detail
  @detail
end

#order_headerObject

Returns the value of attribute order_header.



2
3
4
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 2

def order_header
  @order_header
end

#sales_order_shipment_informationObject

Returns the value of attribute sales_order_shipment_information.



2
3
4
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 2

def sales_order_shipment_information
  @sales_order_shipment_information
end

Instance Method Details

#add_message_header(builder) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 29

def add_message_header(builder)
  message_header = IngramMicro::MessageHeaderPW.new({
    partner_name: IngramMicro.configuration.partner_name,
    transaction_name: transaction_name})
  builder.send('message-header') do
    message_header.build(builder)
  end
  message_header.valid?
end

#add_sales_order_submission(builder) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 39

def add_sales_order_submission(builder)
  sos_options = {
    detail: detail,
    business_name: @business_name,
    customer_id: @customer_id,
    carrier_name: @carrier_name,
    customer: customer,
    sales_order_shipment_information: sales_order_shipment_information,
    order_header: order_header,
    credit_card_information: credit_card_information
  }
  sos = IngramMicro::SalesOrderSubmission.new(sos_options)
  builder.send('sales-order-submission') do
    sos.build(builder)
  end
  sos.valid?
end

#order_builderObject



19
20
21
22
23
24
25
26
27
# File 'lib/ingram_micro/transmissions/sales_order.rb', line 19

def order_builder
  @builder ||= Nokogiri::XML::Builder.new do |builder|
    builder.message do
      add_message_header(builder)
      add_sales_order_submission(builder)
      add_transaction_info(builder)
    end
  end
end