Class: Pinnacle::SenderMetadata
- Inherits:
-
Object
- Object
- Pinnacle::SenderMetadata
- Defined in:
- lib/rcs/types/sender_metadata.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #city ⇒ String readonly
- #country ⇒ String readonly
- #state ⇒ String readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::SenderMetadata
Deserialize a JSON object to an instance of SenderMetadata.
-
.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(city: OMIT, state: OMIT, country: OMIT, additional_properties: nil) ⇒ Pinnacle::SenderMetadata constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of SenderMetadata to a JSON object.
Constructor Details
#initialize(city: OMIT, state: OMIT, country: OMIT, additional_properties: nil) ⇒ Pinnacle::SenderMetadata
27 28 29 30 31 32 33 34 35 |
# File 'lib/rcs/types/sender_metadata.rb', line 27 def initialize(city: OMIT, state: OMIT, country: OMIT, additional_properties: nil) @city = city if city != OMIT @state = state if state != OMIT @country = country if country != OMIT @additional_properties = additional_properties @_field_set = { "city": city, "state": state, "country": country }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
15 16 17 |
# File 'lib/rcs/types/sender_metadata.rb', line 15 def additional_properties @additional_properties end |
#city ⇒ String (readonly)
9 10 11 |
# File 'lib/rcs/types/sender_metadata.rb', line 9 def city @city end |
#country ⇒ String (readonly)
13 14 15 |
# File 'lib/rcs/types/sender_metadata.rb', line 13 def country @country end |
#state ⇒ String (readonly)
11 12 13 |
# File 'lib/rcs/types/sender_metadata.rb', line 11 def state @state end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::SenderMetadata
Deserialize a JSON object to an instance of SenderMetadata
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rcs/types/sender_metadata.rb', line 41 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) city = parsed_json["city"] state = parsed_json["state"] country = parsed_json["country"] new( city: city, state: state, country: country, 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.
68 69 70 71 72 |
# File 'lib/rcs/types/sender_metadata.rb', line 68 def self.validate_raw(obj:) obj.city&.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") obj.country&.is_a?(String) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of SenderMetadata to a JSON object
58 59 60 |
# File 'lib/rcs/types/sender_metadata.rb', line 58 def to_json(*_args) @_field_set&.to_json end |