Class: Courier::Bulk::InboundBulkMessageUser
- Inherits:
-
Object
- Object
- Courier::Bulk::InboundBulkMessageUser
- Defined in:
- lib/trycourier/bulk/types/inbound_bulk_message_user.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#preferences ⇒ Object
readonly
Returns the value of attribute preferences.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#recipient ⇒ Object
readonly
Returns the value of attribute recipient.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Bulk::InboundBulkMessageUser
Deserialize a JSON object to an instance of InboundBulkMessageUser.
-
.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(preferences: nil, profile: nil, recipient: nil, data: nil, to: nil, additional_properties: nil) ⇒ Bulk::InboundBulkMessageUser constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of InboundBulkMessageUser to a JSON object.
Constructor Details
#initialize(preferences: nil, profile: nil, recipient: nil, data: nil, to: nil, additional_properties: nil) ⇒ Bulk::InboundBulkMessageUser
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 19 def initialize(preferences: nil, profile: nil, recipient: nil, data: nil, to: nil, additional_properties: nil) # @type [Commons::RecipientPreferences] @preferences = preferences # @type [Object] @profile = profile # @type [String] @recipient = recipient # @type [Object] @data = data # @type [Send::UserRecipient] @to = to # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
10 11 12 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10 def additional_properties @additional_properties end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10 def data @data end |
#preferences ⇒ Object (readonly)
Returns the value of attribute preferences.
10 11 12 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10 def preferences @preferences end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
10 11 12 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10 def profile @profile end |
#recipient ⇒ Object (readonly)
Returns the value of attribute recipient.
10 11 12 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10 def recipient @recipient end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
10 11 12 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 10 def to @to end |
Class Method Details
.from_json(json_object:) ⇒ Bulk::InboundBulkMessageUser
Deserialize a JSON object to an instance of InboundBulkMessageUser
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 38 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["preferences"].nil? preferences = nil else preferences = parsed_json["preferences"].to_json preferences = Commons::RecipientPreferences.from_json(json_object: preferences) end profile = struct.profile recipient = struct.recipient data = struct.data if parsed_json["to"].nil? to = nil else to = parsed_json["to"].to_json to = Send::UserRecipient.from_json(json_object: to) end new(preferences: preferences, profile: profile, recipient: recipient, data: data, to: to, 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.
71 72 73 74 75 76 77 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 71 def self.validate_raw(obj:) obj.preferences.nil? || Commons::RecipientPreferences.validate_raw(obj: obj.preferences) obj.profile&.is_a?(Object) != false || raise("Passed value for field obj.profile is not the expected type, validation failed.") obj.recipient&.is_a?(String) != false || raise("Passed value for field obj.recipient is not the expected type, validation failed.") obj.data&.is_a?(Object) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") obj.to.nil? || Send::UserRecipient.validate_raw(obj: obj.to) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of InboundBulkMessageUser to a JSON object
63 64 65 |
# File 'lib/trycourier/bulk/types/inbound_bulk_message_user.rb', line 63 def to_json(*_args) { "preferences": @preferences, "profile": @profile, "recipient": @recipient, "data": @data, "to": @to }.to_json end |