Class: Pinnacle::MediaRcsMessage

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

Overview

The content of the message

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(media_type:, media_url:, quick_replies: OMIT, additional_properties: nil) ⇒ Pinnacle::MediaRcsMessage

Parameters:

  • media_type (Pinnacle::MediaType)
  • media_url (String)

    The URL of the media being sent

  • quick_replies (Array<Pinnacle::Action>) (defaults to: OMIT)

    Array of quick replies attached to the media. Maximum of 11 quick replies.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rcs/types/media_rcs_message.rb', line 30

def initialize(media_type:, media_url:, quick_replies: OMIT, additional_properties: nil)
  @media_type = media_type
  @media_url = media_url
  @quick_replies = quick_replies if quick_replies != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "mediaType": media_type,
    "mediaUrl": media_url,
    "quick_replies": quick_replies
  }.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



18
19
20
# File 'lib/rcs/types/media_rcs_message.rb', line 18

def additional_properties
  @additional_properties
end

#media_typePinnacle::MediaType (readonly)

Returns:



12
13
14
# File 'lib/rcs/types/media_rcs_message.rb', line 12

def media_type
  @media_type
end

#media_urlString (readonly)

Returns The URL of the media being sent.

Returns:

  • (String)

    The URL of the media being sent



14
15
16
# File 'lib/rcs/types/media_rcs_message.rb', line 14

def media_url
  @media_url
end

#quick_repliesArray<Pinnacle::Action> (readonly)

Returns Array of quick replies attached to the media. Maximum of 11 quick replies.

Returns:

  • (Array<Pinnacle::Action>)

    Array of quick replies attached to the media. Maximum of 11 quick replies.



16
17
18
# File 'lib/rcs/types/media_rcs_message.rb', line 16

def quick_replies
  @quick_replies
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::MediaRcsMessage

Deserialize a JSON object to an instance of MediaRcsMessage

Parameters:

  • json_object (String)

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rcs/types/media_rcs_message.rb', line 48

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  media_type = parsed_json["mediaType"]
  media_url = parsed_json["mediaUrl"]
  quick_replies = parsed_json["quick_replies"]&.map do |item|
    item = item.to_json
    Pinnacle::Action.from_json(json_object: item)
  end
  new(
    media_type: media_type,
    media_url: media_url,
    quick_replies: quick_replies,
    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)


78
79
80
81
82
# File 'lib/rcs/types/media_rcs_message.rb', line 78

def self.validate_raw(obj:)
  obj.media_type.is_a?(Pinnacle::MediaType) != false || raise("Passed value for field obj.media_type is not the expected type, validation failed.")
  obj.media_url.is_a?(String) != false || raise("Passed value for field obj.media_url is not the expected type, validation failed.")
  obj.quick_replies&.is_a?(Array) != false || raise("Passed value for field obj.quick_replies is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of MediaRcsMessage to a JSON object

Returns:

  • (String)


68
69
70
# File 'lib/rcs/types/media_rcs_message.rb', line 68

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