Class: TrophyApiClient::UpsertedUser
- Inherits:
-
Object
- Object
- TrophyApiClient::UpsertedUser
- Defined in:
- lib/trophy_api_client/types/upserted_user.rb
Overview
An object with editable user fields.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#email ⇒ String
readonly
The user’s email address.
-
#id ⇒ String
readonly
The ID of the user in your database.
-
#name ⇒ String
readonly
The name to refer to the user by in emails.
-
#subscribe_to_emails ⇒ Boolean
readonly
Whether the user should receive Trophy-powered emails.
-
#tz ⇒ String
readonly
The user’s timezone (used for email scheduling).
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::UpsertedUser
Deserialize a JSON object to an instance of UpsertedUser.
-
.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(id:, email: OMIT, name: OMIT, tz: OMIT, subscribe_to_emails: OMIT, additional_properties: nil) ⇒ TrophyApiClient::UpsertedUser constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of UpsertedUser to a JSON object.
Constructor Details
#initialize(id:, email: OMIT, name: OMIT, tz: OMIT, subscribe_to_emails: OMIT, additional_properties: nil) ⇒ TrophyApiClient::UpsertedUser
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 36 def initialize(id:, email: OMIT, name: OMIT, tz: OMIT, subscribe_to_emails: OMIT, additional_properties: nil) @id = id @email = email if email != OMIT @name = name if name != OMIT @tz = tz if tz != OMIT @subscribe_to_emails = subscribe_to_emails if subscribe_to_emails != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "email": email, "name": name, "tz": tz, "subscribeToEmails": subscribe_to_emails }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
21 22 23 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 21 def additional_properties @additional_properties end |
#email ⇒ String (readonly)
Returns The user’s email address. Required if subscribeToEmails is true.
12 13 14 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 12 def email @email end |
#id ⇒ String (readonly)
Returns The ID of the user in your database. Must be a string.
10 11 12 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 10 def id @id end |
#name ⇒ String (readonly)
Returns The name to refer to the user by in emails.
14 15 16 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 14 def name @name end |
#subscribe_to_emails ⇒ Boolean (readonly)
Returns Whether the user should receive Trophy-powered emails. Cannot be false if an email is provided.
19 20 21 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 19 def subscribe_to_emails @subscribe_to_emails end |
#tz ⇒ String (readonly)
Returns The user’s timezone (used for email scheduling).
16 17 18 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 16 def tz @tz end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::UpsertedUser
Deserialize a JSON object to an instance of UpsertedUser
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 58 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] email = parsed_json["email"] name = parsed_json["name"] tz = parsed_json["tz"] subscribe_to_emails = parsed_json["subscribeToEmails"] new( id: id, email: email, name: name, tz: tz, subscribe_to_emails: subscribe_to_emails, 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.
89 90 91 92 93 94 95 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 89 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id 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.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.tz&.is_a?(String) != false || raise("Passed value for field obj.tz is not the expected type, validation failed.") obj.subscribe_to_emails&.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of UpsertedUser to a JSON object
79 80 81 |
# File 'lib/trophy_api_client/types/upserted_user.rb', line 79 def to_json(*_args) @_field_set&.to_json end |