Class: Courier::Send::UserRecipient
- Inherits:
-
Object
- Object
- Courier::Send::UserRecipient
- Defined in:
- lib/trycourier/send/types/user_recipient.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#phone_number ⇒ Object
readonly
Returns the value of attribute phone_number.
-
#preferences ⇒ Object
readonly
Returns the value of attribute preferences.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::UserRecipient
Deserialize a JSON object to an instance of UserRecipient.
-
.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(account_id: nil, context: nil, data: nil, email: nil, locale: nil, user_id: nil, phone_number: nil, preferences: nil, tenant_id: nil, additional_properties: nil) ⇒ Send::UserRecipient constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of UserRecipient to a JSON object.
Constructor Details
#initialize(account_id: nil, context: nil, data: nil, email: nil, locale: nil, user_id: nil, phone_number: nil, preferences: nil, tenant_id: nil, additional_properties: nil) ⇒ Send::UserRecipient
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 26 def initialize(account_id: nil, context: nil, data: nil, email: nil, locale: nil, user_id: nil, phone_number: nil, preferences: nil, tenant_id: nil, additional_properties: nil) # @type [String] Use `tenant_id` instad. @account_id = account_id # @type [Send::MessageContext] Context information such as tenant_id to send the notification with. @context = context # @type [Send::MESSAGE_DATA] @data = data # @type [String] @email = email # @type [String] The user's preferred ISO 639-1 language code. @locale = locale # @type [String] @user_id = user_id # @type [String] @phone_number = phone_number # @type [Send::IProfilePreferences] @preferences = preferences # @type [String] An id of a tenant, [see tenants api docs](https://www.courier.com/docs/reference/tenants). # Will load brand, default preferences and any other base context data associated with this tenant. @tenant_id = tenant_id # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def account_id @account_id end |
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def additional_properties @additional_properties end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def context @context end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def data @data end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def email @email end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def locale @locale end |
#phone_number ⇒ Object (readonly)
Returns the value of attribute phone_number.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def phone_number @phone_number end |
#preferences ⇒ Object (readonly)
Returns the value of attribute preferences.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def preferences @preferences end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def tenant_id @tenant_id end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
11 12 13 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 11 def user_id @user_id end |
Class Method Details
.from_json(json_object:) ⇒ Send::UserRecipient
Deserialize a JSON object to an instance of UserRecipient
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 55 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) account_id = struct.account_id if parsed_json["context"].nil? context = nil else context = parsed_json["context"].to_json context = Send::MessageContext.from_json(json_object: context) end data = struct.data email = struct.email locale = struct.locale user_id = struct.user_id phone_number = struct.phone_number if parsed_json["preferences"].nil? preferences = nil else preferences = parsed_json["preferences"].to_json preferences = Send::IProfilePreferences.from_json(json_object: preferences) end tenant_id = struct.tenant_id new(account_id: account_id, context: context, data: data, email: email, locale: locale, user_id: user_id, phone_number: phone_number, preferences: preferences, tenant_id: tenant_id, 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.
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 102 def self.validate_raw(obj:) obj.account_id&.is_a?(String) != false || raise("Passed value for field obj.account_id is not the expected type, validation failed.") obj.context.nil? || Send::MessageContext.validate_raw(obj: obj.context) obj.data&.is_a?(Hash) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") obj.locale&.is_a?(String) != false || raise("Passed value for field obj.locale is not the expected type, validation failed.") obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.") obj.phone_number&.is_a?(String) != false || raise("Passed value for field obj.phone_number is not the expected type, validation failed.") obj.preferences.nil? || Send::IProfilePreferences.validate_raw(obj: obj.preferences) obj.tenant_id&.is_a?(String) != false || raise("Passed value for field obj.tenant_id is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of UserRecipient to a JSON object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/trycourier/send/types/user_recipient.rb', line 84 def to_json(*_args) { "account_id": @account_id, "context": @context, "data": @data, "email": @email, "locale": @locale, "user_id": @user_id, "phone_number": @phone_number, "preferences": @preferences, "tenant_id": @tenant_id }.to_json end |