Class: TrophyApiClient::UpdatedUser

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/updated_user.rb

Overview

An object with editable user fields.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email: OMIT, name: OMIT, tz: OMIT, device_tokens: OMIT, subscribe_to_emails: OMIT, attributes: OMIT, additional_properties: nil) ⇒ TrophyApiClient::UpdatedUser



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/trophy_api_client/types/updated_user.rb', line 41

def initialize(email: OMIT, name: OMIT, tz: OMIT, device_tokens: OMIT, subscribe_to_emails: OMIT, attributes: OMIT,
               additional_properties: nil)
  @email = email if email != OMIT
  @name = name if name != OMIT
  @tz = tz if tz != OMIT
  @device_tokens = device_tokens if device_tokens != OMIT
  @subscribe_to_emails = subscribe_to_emails if subscribe_to_emails != OMIT
  @attributes = attributes if attributes != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "email": email,
    "name": name,
    "tz": tz,
    "deviceTokens": device_tokens,
    "subscribeToEmails": subscribe_to_emails,
    "attributes": attributes
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



24
25
26
# File 'lib/trophy_api_client/types/updated_user.rb', line 24

def additional_properties
  @additional_properties
end

#attributesHash{String => String} (readonly)



22
23
24
# File 'lib/trophy_api_client/types/updated_user.rb', line 22

def attributes
  @attributes
end

#device_tokensArray<String> (readonly)



16
17
18
# File 'lib/trophy_api_client/types/updated_user.rb', line 16

def device_tokens
  @device_tokens
end

#emailString (readonly)



10
11
12
# File 'lib/trophy_api_client/types/updated_user.rb', line 10

def email
  @email
end

#nameString (readonly)



12
13
14
# File 'lib/trophy_api_client/types/updated_user.rb', line 12

def name
  @name
end

#subscribe_to_emailsBoolean (readonly)



19
20
21
# File 'lib/trophy_api_client/types/updated_user.rb', line 19

def subscribe_to_emails
  @subscribe_to_emails
end

#tzString (readonly)



14
15
16
# File 'lib/trophy_api_client/types/updated_user.rb', line 14

def tz
  @tz
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::UpdatedUser

Deserialize a JSON object to an instance of UpdatedUser



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/trophy_api_client/types/updated_user.rb', line 66

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  email = parsed_json["email"]
  name = parsed_json["name"]
  tz = parsed_json["tz"]
  device_tokens = parsed_json["deviceTokens"]
  subscribe_to_emails = parsed_json["subscribeToEmails"]
  attributes = parsed_json["attributes"]
  new(
    email: email,
    name: name,
    tz: tz,
    device_tokens: device_tokens,
    subscribe_to_emails: subscribe_to_emails,
    attributes: attributes,
    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.


99
100
101
102
103
104
105
106
# File 'lib/trophy_api_client/types/updated_user.rb', line 99

def self.validate_raw(obj:)
  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.device_tokens&.is_a?(Array) != false || raise("Passed value for field obj.device_tokens 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.")
  obj.attributes&.is_a?(Hash) != false || raise("Passed value for field obj.attributes is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of UpdatedUser to a JSON object



89
90
91
# File 'lib/trophy_api_client/types/updated_user.rb', line 89

def to_json(*_args)
  @_field_set&.to_json
end