Class: Pinnacle::InboundTextMessage
- Inherits:
-
Object
- Object
- Pinnacle::InboundTextMessage
- Defined in:
- lib/rcs/types/inbound_text_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 ⇒ String readonly
- #metadata ⇒ Pinnacle::InboundMessageMetadata readonly
- #text ⇒ String readonly
- #to ⇒ String readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::InboundTextMessage
Deserialize a JSON object to an instance of InboundTextMessage.
-
.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(text:, from:, to:, message_type: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundTextMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of InboundTextMessage to a JSON object.
Constructor Details
#initialize(text:, from:, to:, message_type: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundTextMessage
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rcs/types/inbound_text_message.rb', line 34 def initialize(text:, from:, to:, message_type: OMIT, metadata: OMIT, additional_properties: nil) @message_type = if != OMIT @text = text @from = from @to = to @metadata = if != OMIT @additional_properties = additional_properties @_field_set = { "messageType": , "text": text, "from": from, "to": to, "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.
20 21 22 |
# File 'lib/rcs/types/inbound_text_message.rb', line 20 def additional_properties @additional_properties end |
#from ⇒ String (readonly)
14 15 16 |
# File 'lib/rcs/types/inbound_text_message.rb', line 14 def from @from end |
#message_type ⇒ String (readonly)
10 11 12 |
# File 'lib/rcs/types/inbound_text_message.rb', line 10 def @message_type end |
#metadata ⇒ Pinnacle::InboundMessageMetadata (readonly)
18 19 20 |
# File 'lib/rcs/types/inbound_text_message.rb', line 18 def @metadata end |
#text ⇒ String (readonly)
12 13 14 |
# File 'lib/rcs/types/inbound_text_message.rb', line 12 def text @text end |
#to ⇒ String (readonly)
16 17 18 |
# File 'lib/rcs/types/inbound_text_message.rb', line 16 def to @to end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::InboundTextMessage
Deserialize a JSON object to an instance of InboundTextMessage
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rcs/types/inbound_text_message.rb', line 56 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) = parsed_json["messageType"] text = parsed_json["text"] from = parsed_json["from"] to = parsed_json["to"] if parsed_json["metadata"].nil? = nil else = parsed_json["metadata"].to_json = Pinnacle::InboundMessageMetadata.from_json(json_object: ) end new( message_type: , text: text, from: from, to: to, 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.
92 93 94 95 96 97 98 |
# File 'lib/rcs/types/inbound_text_message.rb', line 92 def self.validate_raw(obj:) obj.&.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.") obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") 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..nil? || Pinnacle::InboundMessageMetadata.validate_raw(obj: obj.) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of InboundTextMessage to a JSON object
82 83 84 |
# File 'lib/rcs/types/inbound_text_message.rb', line 82 def to_json(*_args) @_field_set&.to_json end |