Class: Pinnacle::BasicRcs
- Inherits:
-
Object
- Object
- Pinnacle::BasicRcs
- Defined in:
- lib/rcs/types/basic_rcs.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#message ⇒ Pinnacle::BasicRcsMessage
readonly
The content of the message.
-
#message_type ⇒ String
readonly
The type of message being sent.
-
#phone_number ⇒ String
readonly
Phone number to send the SMS message to.
- #quick_replies ⇒ Array<Pinnacle::Action> readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::BasicRcs
Deserialize a JSON object to an instance of BasicRcs.
-
.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(phone_number:, message_type:, message:, quick_replies: OMIT, additional_properties: nil) ⇒ Pinnacle::BasicRcs constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of BasicRcs to a JSON object.
Constructor Details
#initialize(phone_number:, message_type:, message:, quick_replies: OMIT, additional_properties: nil) ⇒ Pinnacle::BasicRcs
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(phone_number:, message_type:, message:, quick_replies: OMIT, additional_properties: nil) @phone_number = phone_number @message_type = @message = @quick_replies = quick_replies if quick_replies != OMIT @additional_properties = additional_properties @_field_set = { "phone_number": phone_number, "message_type": , "message": , "quick_replies": quick_replies }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns 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 |
#message ⇒ Pinnacle::BasicRcsMessage (readonly)
Returns The content of the message.
15 16 17 |
# File 'lib/rcs/types/basic_rcs.rb', line 15 def @message end |
#message_type ⇒ String (readonly)
Returns The type of message being sent.
13 14 15 |
# File 'lib/rcs/types/basic_rcs.rb', line 13 def @message_type end |
#phone_number ⇒ String (readonly)
Returns 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_replies ⇒ Array<Pinnacle::Action> (readonly)
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
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"] = parsed_json["message_type"] if parsed_json["message"].nil? = nil else = parsed_json["message"].to_json = Pinnacle::BasicRcsMessage.from_json(json_object: ) 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: , 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.
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..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.) 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
79 80 81 |
# File 'lib/rcs/types/basic_rcs.rb', line 79 def to_json(*_args) @_field_set&.to_json end |