Class: Pinnacle::InboundMediaMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs/types/inbound_media_message.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(media_urls:, from:, to:, message_type: OMIT, text: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Pinnacle::InboundMediaMessage

Parameters:

  • message_type (String) (defaults to: OMIT)
  • text (String) (defaults to: OMIT)
  • media_urls (Array<Pinnacle::MediaPayload>)
  • from (String)
  • to (String)
  • metadata (Pinnacle::InboundMessageMetadata) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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 = message_type if message_type != OMIT
  @text = text if text != OMIT
  @media_urls = media_urls
  @from = from
  @to = to
  @metadata =  if  != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "messageType": message_type,
    "text": text,
    "mediaUrls": media_urls,
    "from": from,
    "to": to,
    "metadata": 
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#fromString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/rcs/types/inbound_media_message.rb', line 17

def from
  @from
end

#media_urlsArray<Pinnacle::MediaPayload> (readonly)

Returns:



15
16
17
# File 'lib/rcs/types/inbound_media_message.rb', line 15

def media_urls
  @media_urls
end

#message_typeString (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/rcs/types/inbound_media_message.rb', line 11

def message_type
  @message_type
end

#metadataPinnacle::InboundMessageMetadata (readonly)



21
22
23
# File 'lib/rcs/types/inbound_media_message.rb', line 21

def 
  @metadata
end

#textString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/rcs/types/inbound_media_message.rb', line 13

def text
  @text
end

#toString (readonly)

Returns:

  • (String)


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

Parameters:

  • json_object (String)

Returns:



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)
  message_type = 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: 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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


103
104
105
106
107
108
109
110
# File 'lib/rcs/types/inbound_media_message.rb', line 103

def self.validate_raw(obj:)
  obj.message_type&.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

Returns:

  • (String)


93
94
95
# File 'lib/rcs/types/inbound_media_message.rb', line 93

def to_json(*_args)
  @_field_set&.to_json
end