Class: Courier::Lists::ListSubscriptionRecipient
- Inherits:
-
Object
- Object
- Courier::Lists::ListSubscriptionRecipient
- Defined in:
- lib/trycourier/lists/types/list_subscription_recipient.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#preferences ⇒ Object
readonly
Returns the value of attribute preferences.
-
#recipient_id ⇒ Object
readonly
Returns the value of attribute recipient_id.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Lists::ListSubscriptionRecipient
Deserialize a JSON object to an instance of ListSubscriptionRecipient.
-
.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(recipient_id:, created: nil, preferences: nil, additional_properties: nil) ⇒ Lists::ListSubscriptionRecipient constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ListSubscriptionRecipient to a JSON object.
Constructor Details
#initialize(recipient_id:, created: nil, preferences: nil, additional_properties: nil) ⇒ Lists::ListSubscriptionRecipient
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trycourier/lists/types/list_subscription_recipient.rb', line 16 def initialize(recipient_id:, created: nil, preferences: nil, additional_properties: nil) # @type [String] @recipient_id = recipient_id # @type [String] @created = created # @type [Commons::RecipientPreferences] @preferences = preferences # @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.
9 10 11 |
# File 'lib/trycourier/lists/types/list_subscription_recipient.rb', line 9 def additional_properties @additional_properties end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
9 10 11 |
# File 'lib/trycourier/lists/types/list_subscription_recipient.rb', line 9 def created @created end |
#preferences ⇒ Object (readonly)
Returns the value of attribute preferences.
9 10 11 |
# File 'lib/trycourier/lists/types/list_subscription_recipient.rb', line 9 def preferences @preferences end |
#recipient_id ⇒ Object (readonly)
Returns the value of attribute recipient_id.
9 10 11 |
# File 'lib/trycourier/lists/types/list_subscription_recipient.rb', line 9 def recipient_id @recipient_id end |
Class Method Details
.from_json(json_object:) ⇒ Lists::ListSubscriptionRecipient
Deserialize a JSON object to an instance of ListSubscriptionRecipient
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/trycourier/lists/types/list_subscription_recipient.rb', line 31 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) recipient_id = struct.recipientId created = struct.created if parsed_json["preferences"].nil? preferences = nil else preferences = parsed_json["preferences"].to_json preferences = Commons::RecipientPreferences.from_json(json_object: preferences) end new(recipient_id: recipient_id, created: created, preferences: preferences, 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.
56 57 58 59 60 |
# File 'lib/trycourier/lists/types/list_subscription_recipient.rb', line 56 def self.validate_raw(obj:) obj.recipient_id.is_a?(String) != false || raise("Passed value for field obj.recipient_id is not the expected type, validation failed.") obj.created&.is_a?(String) != false || raise("Passed value for field obj.created is not the expected type, validation failed.") obj.preferences.nil? || Commons::RecipientPreferences.validate_raw(obj: obj.preferences) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of ListSubscriptionRecipient to a JSON object
48 49 50 |
# File 'lib/trycourier/lists/types/list_subscription_recipient.rb', line 48 def to_json(*_args) { "recipientId": @recipient_id, "created": @created, "preferences": @preferences }.to_json end |