Class: EgonGate::Kobra::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/egon_gate/kobra/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(egsb_message, mode = 'sync') ⇒ Message

Returns a new instance of Message.



8
9
10
11
# File 'lib/egon_gate/kobra/message.rb', line 8

def initialize(egsb_message, mode='sync')
  @egsb_message = egsb_message
  @mode = mode
end

Instance Method Details

#bodyObject



19
20
21
# File 'lib/egon_gate/kobra/message.rb', line 19

def body
  Base64.encode64 @egsb_message.to_s
end

#configObject



13
14
15
16
17
# File 'lib/egon_gate/kobra/message.rb', line 13

def config
  {
    is_id: 124
  }
end

#message_detailsObject



23
24
25
# File 'lib/egon_gate/kobra/message.rb', line 23

def message_details
  {class: @egsb_message.message_code, attributes!: {class: {mode: @mode}}}
end

#message_hashObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/egon_gate/kobra/message.rb', line 27

def message_hash
  { gate_message: {
      version: '2.0',
      header: {
        message_details: message_details,
        sender_details: {authentication: {'ISId' => config[:is_id]}, attributes!: { authentication: {type: 'clear'} }},
        attributes!: {message_details: {type: 'request'}}
      },
      body: body
    }
  }
end

#to_sObject



40
41
42
# File 'lib/egon_gate/kobra/message.rb', line 40

def to_s
  Gyoku.xml(message_hash, key_converter: :camelcase)
end