Class: Pinnacle::InboundMessage
- Inherits:
-
Object
- Object
- Pinnacle::InboundMessage
- Defined in:
- lib/rcs/types/inbound_message.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #from ⇒ String readonly
- #message_type ⇒ Pinnacle::InboundMessageMessageType readonly
- #metadata ⇒ Pinnacle::InboundMessageMetadata readonly
- #to ⇒ String readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::InboundMessage
Deserialize a JSON object to an instance of InboundMessage.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(from:, to:, message_type:, metadata: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of InboundMessage to a JSON object.
Constructor Details
#initialize(from:, to:, message_type:, metadata: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundMessage
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rcs/types/inbound_message.rb', line 32 def initialize(from:, to:, message_type:, metadata: OMIT, additional_properties: nil) @from = from @to = to @message_type = @metadata = if != OMIT @additional_properties = additional_properties @_field_set = { "from": from, "to": to, "messageType": , "metadata": }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
19 20 21 |
# File 'lib/rcs/types/inbound_message.rb', line 19 def additional_properties @additional_properties end |
#from ⇒ String (readonly)
11 12 13 |
# File 'lib/rcs/types/inbound_message.rb', line 11 def from @from end |
#message_type ⇒ Pinnacle::InboundMessageMessageType (readonly)
15 16 17 |
# File 'lib/rcs/types/inbound_message.rb', line 15 def @message_type end |
#metadata ⇒ Pinnacle::InboundMessageMetadata (readonly)
17 18 19 |
# File 'lib/rcs/types/inbound_message.rb', line 17 def @metadata end |
#to ⇒ String (readonly)
13 14 15 |
# File 'lib/rcs/types/inbound_message.rb', line 13 def to @to end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::InboundMessage
Deserialize a JSON object to an instance of InboundMessage
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rcs/types/inbound_message.rb', line 47 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) from = parsed_json["from"] to = parsed_json["to"] = parsed_json["messageType"] if parsed_json["metadata"].nil? = nil else = parsed_json["metadata"].to_json = Pinnacle::InboundMessageMetadata.from_json(json_object: ) end new( from: from, to: to, message_type: , metadata: , additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
81 82 83 84 85 86 |
# File 'lib/rcs/types/inbound_message.rb', line 81 def self.validate_raw(obj:) obj.from.is_a?(String) != false || raise("Passed value for field obj.from is not the expected type, validation failed.") obj.to.is_a?(String) != false || raise("Passed value for field obj.to is not the expected type, validation failed.") obj..is_a?(Pinnacle::InboundMessageMessageType) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.") obj..nil? || Pinnacle::InboundMessageMetadata.validate_raw(obj: obj.) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of InboundMessage to a JSON object
71 72 73 |
# File 'lib/rcs/types/inbound_message.rb', line 71 def to_json(*_args) @_field_set&.to_json end |