Class: Pinnacle::BasicRcs

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_type:, message:, phone_number: OMIT, quick_replies: OMIT, additional_properties: nil) ⇒ Pinnacle::BasicRcs

Parameters:

  • phone_number (String) (defaults to: OMIT)

    Phone number to send the SMS message to

  • message_type (String)

    The type of message being sent

  • message (Pinnacle::BasicRcsMessage)

    The content of the message

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

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rcs/types/basic_rcs.rb', line 32

def initialize(message_type:, message:, phone_number: OMIT, quick_replies: OMIT, additional_properties: nil)
  @phone_number = phone_number if phone_number != OMIT
  @message_type = message_type
  @message = message
  @quick_replies = quick_replies if quick_replies != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "phone_number": phone_number,
    "message_type": message_type,
    "message": message,
    "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



19
20
21
# File 'lib/rcs/types/basic_rcs.rb', line 19

def additional_properties
  @additional_properties
end

#messagePinnacle::BasicRcsMessage (readonly)

Returns The content of the message.

Returns:



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

def message
  @message
end

#message_typeString (readonly)

Returns The type of message being sent.

Returns:

  • (String)

    The type of message being sent



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

def message_type
  @message_type
end

#phone_numberString (readonly)

Returns Phone number to send the SMS message to.

Returns:

  • (String)

    Phone number to send the SMS message to



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

def phone_number
  @phone_number
end

#quick_repliesArray<Pinnacle::Action> (readonly)

Returns:



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

def quick_replies
  @quick_replies
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::BasicRcs

Deserialize a JSON object to an instance of BasicRcs

Parameters:

  • json_object (String)

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rcs/types/basic_rcs.rb', line 52

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  phone_number = parsed_json["phone_number"]
  message_type = parsed_json["message_type"]
  if parsed_json["message"].nil?
    message = nil
  else
    message = parsed_json["message"].to_json
    message = Pinnacle::BasicRcsMessage.from_json(json_object: message)
  end
  quick_replies = parsed_json["quick_replies"]&.map do |item|
    item = item.to_json
    Pinnacle::Action.from_json(json_object: item)
  end
  new(
    phone_number: phone_number,
    message_type: message_type,
    message: message,
    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)


89
90
91
92
93
94
# File 'lib/rcs/types/basic_rcs.rb', line 89

def self.validate_raw(obj:)
  obj.phone_number&.is_a?(String) != false || raise("Passed value for field obj.phone_number is not the expected type, validation failed.")
  obj.message_type.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
  Pinnacle::BasicRcsMessage.validate_raw(obj: obj.message)
  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 BasicRcs to a JSON object

Returns:

  • (String)


79
80
81
# File 'lib/rcs/types/basic_rcs.rb', line 79

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