Class: IngramMicro::StandardResponse

Inherits:
Transmission show all
Defined in:
lib/ingram_micro/transmissions/standard_response.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 = {}) ⇒ StandardResponse



5
6
7
8
9
10
11
12
13
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 5

def initialize(options={})
  super(options)
  @transaction_name = 'standard-response'
  @status_code = options[:status_code]
  @status_description = options[:status_description]
  @comments = options[:comments]
  @response_timestamp = options[:response_timestamp]
  @filename = options[:filename]
end

Instance Attribute Details

#commentsObject

Returns the value of attribute comments.



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

def comments
  @comments
end

#filenameObject

Returns the value of attribute filename.



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

def filename
  @filename
end

#response_timestampObject

Returns the value of attribute response_timestamp.



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

def response_timestamp
  @response_timestamp
end

#status_codeObject

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

#status_descriptionObject

Returns the value of attribute status_description.



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

def status_description
  @status_description
end

Instance Method Details

#add_message_header(builder) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 25

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_message_status(builder) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 35

def add_message_status(builder)
  message_status = IngramMicro::MessageStatus.new({
    status_code: @status_code,
    status_description: @status_description,
    comments: @comments,
    response_timestamp: @response_timestamp,
    filename: @filename
  })
  builder.send('message-status') do
    message_status.build(builder)
  end
end

#order_builderObject



15
16
17
18
19
20
21
22
23
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 15

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