Class: Sumac::Message::Exchange::CompatibilityNotification

Inherits:
Notification show all
Defined in:
lib/sumac/message/exchange/compatibility_notification.rb

Instance Method Summary collapse

Methods inherited from Base

from_json_structure

Methods inherited from Sumac::Message::Exchange

from_json_structure

Methods inherited from Sumac::Message

from_json, #to_json

Constructor Details

#initialize(connection) ⇒ CompatibilityNotification

Returns a new instance of CompatibilityNotification.



6
7
8
9
# File 'lib/sumac/message/exchange/compatibility_notification.rb', line 6

def initialize(connection)
  super
  @protocol_version = nil
end

Instance Method Details

#invert_orginObject

Raises:



39
40
41
42
# File 'lib/sumac/message/exchange/compatibility_notification.rb', line 39

def invert_orgin
  raise MessageError unless setup?
  nil
end

#parse_json_structure(json_structure) ⇒ Object

Raises:



11
12
13
14
15
16
17
18
# File 'lib/sumac/message/exchange/compatibility_notification.rb', line 11

def parse_json_structure(json_structure)
  raise MessageError unless json_structure.is_a?(Hash) &&
    json_structure['message_type'] == 'exchange' &&
    json_structure['exchange_type'] == 'compatibility_notification'
  raise MessageError unless json_structure['protocol_version'].is_a?(Integer)
  @protocol_version = json_structure['protocol_version']
  nil
end

#protocol_versionObject

Raises:



29
30
31
32
# File 'lib/sumac/message/exchange/compatibility_notification.rb', line 29

def protocol_version
  raise MessageError unless setup?
  @protocol_version
end

#protocol_version=(new_protocol_version) ⇒ Object

Raises:



34
35
36
37
# File 'lib/sumac/message/exchange/compatibility_notification.rb', line 34

def protocol_version=(new_protocol_version)
  raise MessageError unless new_protocol_version.is_a?(Integer)
  @protocol_version = new_protocol_version
end

#to_json_structureObject

Raises:



20
21
22
23
24
25
26
27
# File 'lib/sumac/message/exchange/compatibility_notification.rb', line 20

def to_json_structure
  raise MessageError unless setup?
  {
    'message_type' => 'exchange',
    'exchange_type' => 'compatibility_notification',
    'protocol_version' => @protocol_version
  }
end