Class: RBEDI::TransactionEnvelope

Inherits:
Object
  • Object
show all
Defined in:
lib/rbedi/transaction_envelope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interchange_sender_id_qualifier: :mutually_defined, interchange_sender_id:, interchange_receiver_id_qualifier: :mutually_defined, interchange_receiver_id:, functional_groups: [], interchange_control_number:, date_time: DateTime.now, repetition_separator: ?^, component_element_separator: ?:, interchange_usage_indicator: :production, authorization_information_qualifier: :no_authorization_information_present, authorization_information: " " * 10, security_information_qualifier: :no_security_information_present, security_information: " " * 10, acknowledgement_requested: false) ⇒ TransactionEnvelope

Returns a new instance of TransactionEnvelope.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rbedi/transaction_envelope.rb', line 3

def initialize(
  interchange_sender_id_qualifier: :mutually_defined,
  interchange_sender_id:,
  interchange_receiver_id_qualifier: :mutually_defined,
  interchange_receiver_id:,
  functional_groups: [],
  interchange_control_number:,
  date_time: DateTime.now,
  repetition_separator: ?^,
  component_element_separator: ?:,
  interchange_usage_indicator: :production,
  authorization_information_qualifier: :no_authorization_information_present,
  authorization_information: " " * 10,
  security_information_qualifier: :no_security_information_present,
  security_information: " " * 10,
  acknowledgement_requested: false
)
  @interchange_sender_id = interchange_sender_id
  @interchange_receiver_id = interchange_receiver_id
  @interchange_sender_id_qualifier = interchange_sender_id_qualifier
  @interchange_receiver_id_qualifier = interchange_receiver_id_qualifier
  @authorization_information_qualifier = authorization_information_qualifier
  @authorization_information = authorization_information
  @security_information_qualifier = security_information_qualifier
  @security_information = security_information
  @repetition_separator = repetition_separator
  @component_element_separator = component_element_separator
  @interchange_control_number = "%09d" % interchange_control_number
  @acknowledgement_requested = acknowledgement_requested
  @date_time = EDIDateTime.new(date_time)
  @functional_groups = functional_groups
  @interchange_usage_indicator = interchange_usage_indicator
end

Instance Attribute Details

#acknowledgement_requestedObject

Returns the value of attribute acknowledgement_requested.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def acknowledgement_requested
  @acknowledgement_requested
end

#authorization_informationObject

Returns the value of attribute authorization_information.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def authorization_information
  @authorization_information
end

#authorization_information_qualifierObject

Returns the value of attribute authorization_information_qualifier.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def authorization_information_qualifier
  @authorization_information_qualifier
end

#component_element_separatorObject

Returns the value of attribute component_element_separator.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def component_element_separator
  @component_element_separator
end

#date_timeObject

Returns the value of attribute date_time.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def date_time
  @date_time
end

#functional_groupsObject

Returns the value of attribute functional_groups.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def functional_groups
  @functional_groups
end

#interchange_control_numberObject

Returns the value of attribute interchange_control_number.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def interchange_control_number
  @interchange_control_number
end

#interchange_receiver_idObject

Returns the value of attribute interchange_receiver_id.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def interchange_receiver_id
  @interchange_receiver_id
end

#interchange_receiver_id_qualifierObject

Returns the value of attribute interchange_receiver_id_qualifier.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def interchange_receiver_id_qualifier
  @interchange_receiver_id_qualifier
end

#interchange_sender_idObject

Returns the value of attribute interchange_sender_id.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def interchange_sender_id
  @interchange_sender_id
end

#interchange_sender_id_qualifierObject

Returns the value of attribute interchange_sender_id_qualifier.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def interchange_sender_id_qualifier
  @interchange_sender_id_qualifier
end

#interchange_usage_indicatorObject

Returns the value of attribute interchange_usage_indicator.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def interchange_usage_indicator
  @interchange_usage_indicator
end

#repetition_separatorObject

Returns the value of attribute repetition_separator.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def repetition_separator
  @repetition_separator
end

#security_informationObject

Returns the value of attribute security_information.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def security_information
  @security_information
end

#security_information_qualifierObject

Returns the value of attribute security_information_qualifier.



73
74
75
# File 'lib/rbedi/transaction_envelope.rb', line 73

def security_information_qualifier
  @security_information_qualifier
end

Instance Method Details

#headerObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rbedi/transaction_envelope.rb', line 43

def header
  Segment.new(
    :interchange_control_header,
    authorization_information_qualifier: @authorization_information_qualifier,
    authorization_information: @authorization_information,
    security_information_qualifier: @security_information_qualifier,
    security_information: @security_information,
    interchange_sender_id_qualifier: @interchange_sender_id_qualifier,
    interchange_receiver_id_qualifier: @interchange_receiver_id_qualifier,
    interchange_sender_id: @interchange_sender_id.ljust(15),
    interchange_receiver_id: @interchange_receiver_id.ljust(15),
    interchange_date: @date_time.yymmdd,
    interchange_time: @date_time.hhmm,
    repetition_separator: @repetition_separator,
    interchange_control_version_number: Codes::INTERCHANGE_CONTROL_VERSION_NUMBER,
    interchange_control_number: @interchange_control_number,
    acknowledgement_requested: @acknowledgement_requested,
    interchange_usage_indicator: @interchange_usage_indicator,
    component_element_separator: @component_element_separator
  )
end

#to_sObject



37
38
39
40
41
# File 'lib/rbedi/transaction_envelope.rb', line 37

def to_s
  header.to_s +
    @functional_groups.map(&:to_s).join +
    trailer.to_s
end

#trailerObject



65
66
67
68
69
70
71
# File 'lib/rbedi/transaction_envelope.rb', line 65

def trailer
  Segment.new(
    :interchange_control_trailer,
    functional_group_count: @functional_groups.length,
    interchange_control_number: @interchange_control_number
  )
end