Class: IngramMicro::StandardResponse

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

Direct Known Subclasses

FailureResponse, SuccessResponse

Constant Summary collapse

TRANSMISSION_FILENAME =
'standard-response'

Constants inherited from Transmission

Transmission::XSD

Instance Attribute Summary collapse

Attributes inherited from Transmission

#errors

Instance Method Summary collapse

Methods inherited from Transmission

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

Constructor Details

#initialize(options = {}) ⇒ StandardResponse

Returns a new instance of StandardResponse.



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

def initialize(options={})
  super(options)
  @transaction_name = options[:transaction_name]
  @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.



4
5
6
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 4

def comments
  @comments
end

#filenameObject

Returns the value of attribute filename.



4
5
6
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 4

def filename
  @filename
end

#response_timestampObject

Returns the value of attribute response_timestamp.



4
5
6
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 4

def response_timestamp
  @response_timestamp
end

#status_codeObject

Returns the value of attribute status_code.



4
5
6
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 4

def status_code
  @status_code
end

#status_descriptionObject

Returns the value of attribute status_description.



4
5
6
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 4

def status_description
  @status_description
end

#transaction_nameObject

Returns the value of attribute transaction_name.



4
5
6
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 4

def transaction_name
  @transaction_name
end

Instance Method Details

#add_message_header(builder) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 31

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



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 41

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

#to_xml(opts = {}) ⇒ Object



17
18
19
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 17

def to_xml(opts={})
  xml_builder.to_xml
end

#xml_builderObject



21
22
23
24
25
26
27
28
29
# File 'lib/ingram_micro/transmissions/standard_response.rb', line 21

def xml_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