Class: Pinnacle::InboundMediaMessage
- Inherits:
-
Object
- Object
- Pinnacle::InboundMediaMessage
- Defined in:
- lib/rcs/types/inbound_media_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
- #media_urls ⇒ Array<Pinnacle::MediaPayload> readonly
- #message_type ⇒ String readonly
- #metadata ⇒ Pinnacle::InboundMessageMetadata readonly
- #text ⇒ String readonly
- #to ⇒ String readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::InboundMediaMessage
Deserialize a JSON object to an instance of InboundMediaMessage.
-
.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(media_urls:, from:, to:, message_type: OMIT, text: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundMediaMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of InboundMediaMessage to a JSON object.
Constructor Details
#initialize(media_urls:, from:, to:, message_type: OMIT, text: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundMediaMessage
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rcs/types/inbound_media_message.rb', line 38 def initialize(media_urls:, from:, to:, message_type: OMIT, text: OMIT, metadata: OMIT, additional_properties: nil) @message_type = if != OMIT @text = text if text != OMIT @media_urls = media_urls @from = from @to = to @metadata = if != OMIT @additional_properties = additional_properties @_field_set = { "messageType": , "text": text, "mediaUrls": media_urls, "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.
23 24 25 |
# File 'lib/rcs/types/inbound_media_message.rb', line 23 def additional_properties @additional_properties end |
#from ⇒ String (readonly)
17 18 19 |
# File 'lib/rcs/types/inbound_media_message.rb', line 17 def from @from end |
#media_urls ⇒ Array<Pinnacle::MediaPayload> (readonly)
15 16 17 |
# File 'lib/rcs/types/inbound_media_message.rb', line 15 def media_urls @media_urls end |
#message_type ⇒ String (readonly)
11 12 13 |
# File 'lib/rcs/types/inbound_media_message.rb', line 11 def @message_type end |
#metadata ⇒ Pinnacle::InboundMessageMetadata (readonly)
21 22 23 |
# File 'lib/rcs/types/inbound_media_message.rb', line 21 def @metadata end |
#text ⇒ String (readonly)
13 14 15 |
# File 'lib/rcs/types/inbound_media_message.rb', line 13 def text @text end |
#to ⇒ String (readonly)
19 20 21 |
# File 'lib/rcs/types/inbound_media_message.rb', line 19 def to @to end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::InboundMediaMessage
Deserialize a JSON object to an instance of InboundMediaMessage
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rcs/types/inbound_media_message.rb', line 62 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"] media_urls = parsed_json["mediaUrls"]&.map do |item| item = item.to_json Pinnacle::MediaPayload.from_json(json_object: item) end 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, media_urls: media_urls, 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.
103 104 105 106 107 108 109 110 |
# File 'lib/rcs/types/inbound_media_message.rb', line 103 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.media_urls.is_a?(Array) != false || raise("Passed value for field obj.media_urls 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 InboundMediaMessage to a JSON object
93 94 95 |
# File 'lib/rcs/types/inbound_media_message.rb', line 93 def to_json(*_args) @_field_set&.to_json end |