Class: Pinnacle::Sms
- Inherits:
-
Object
- Object
- Pinnacle::Sms
- Defined in:
- lib/rcs/types/sms.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::SmsMessage
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.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::Sms
Deserialize a JSON object to an instance of Sms.
-
.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(message_type:, message:, phone_number: OMIT, additional_properties: nil) ⇒ Pinnacle::Sms constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Sms to a JSON object.
Constructor Details
#initialize(message_type:, message:, phone_number: OMIT, additional_properties: nil) ⇒ Pinnacle::Sms
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rcs/types/sms.rb', line 28 def initialize(message_type:, message:, phone_number: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT @message_type = @message = @additional_properties = additional_properties @_field_set = { "phone_number": phone_number, "message_type": , "message": }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
16 17 18 |
# File 'lib/rcs/types/sms.rb', line 16 def additional_properties @additional_properties end |
#message ⇒ Pinnacle::SmsMessage (readonly)
Returns The content of the message.
14 15 16 |
# File 'lib/rcs/types/sms.rb', line 14 def @message end |
#message_type ⇒ String (readonly)
Returns The type of message being sent.
12 13 14 |
# File 'lib/rcs/types/sms.rb', line 12 def @message_type end |
#phone_number ⇒ String (readonly)
Returns Phone number to send the SMS message to.
10 11 12 |
# File 'lib/rcs/types/sms.rb', line 10 def phone_number @phone_number end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::Sms
Deserialize a JSON object to an instance of Sms
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rcs/types/sms.rb', line 46 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::SmsMessage.from_json(json_object: ) end new( phone_number: phone_number, message_type: , message: , 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.
78 79 80 81 82 |
# File 'lib/rcs/types/sms.rb', line 78 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::SmsMessage.validate_raw(obj: obj.) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Sms to a JSON object
68 69 70 |
# File 'lib/rcs/types/sms.rb', line 68 def to_json(*_args) @_field_set&.to_json end |