Class: CropwisePlatformSdk::IdentifiedAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/cropwise-platform-sdk/models/identified_account.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ IdentifiedAccount

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 140

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `CropwisePlatformSdk::IdentifiedAccount` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `CropwisePlatformSdk::IdentifiedAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.key?(:'type')
    self.type = attributes[:'type']
  end

  if attributes.key?(:'role')
    self.role = attributes[:'role']
  end

  if attributes.key?(:'ssn')
    self.ssn = attributes[:'ssn']
  end

  if attributes.key?(:'tutorial_complete')
    self.tutorial_complete = attributes[:'tutorial_complete']
  end

  if attributes.key?(:'phone')
    self.phone = attributes[:'phone']
  end

  if attributes.key?(:'authorities')
    if (value = attributes[:'authorities']).is_a?(Array)
      self.authorities = value
    end
  end

  if attributes.key?(:'locale')
    self.locale = attributes[:'locale']
  end

  if attributes.key?(:'clock_format')
    self.clock_format = attributes[:'clock_format']
  end

  if attributes.key?(:'pending_change_password')
    self.pending_change_password = attributes[:'pending_change_password']
  end

  if attributes.key?(:'default_workspace_id')
    self.default_workspace_id = attributes[:'default_workspace_id']
  end

  if attributes.key?(:'workspaces')
    if (value = attributes[:'workspaces']).is_a?(Array)
      self.workspaces = value
    end
  end

  if attributes.key?(:'login')
    self. = attributes[:'login']
  end

  if attributes.key?(:'country_code')
    self.country_code = attributes[:'country_code']
  end

  if attributes.key?(:'photo_uri')
    self.photo_uri = attributes[:'photo_uri']
  end
end

Instance Attribute Details

#authoritiesObject

Returns the value of attribute authorities.



34
35
36
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 34

def authorities
  @authorities
end

#clock_formatObject

Returns the value of attribute clock_format.



38
39
40
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 38

def clock_format
  @clock_format
end

#country_codeObject

Returns the value of attribute country_code.



49
50
51
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 49

def country_code
  @country_code
end

#default_workspace_idObject

A v4 UUID, represented in its canonical textual form (hexadecimal, lowercase, 8-4-4-4-12 groups separated by a dash (-)).



43
44
45
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 43

def default_workspace_id
  @default_workspace_id
end

#idObject

A v4 UUID, represented in its canonical textual form (hexadecimal, lowercase, 8-4-4-4-12 groups separated by a dash (-)).



19
20
21
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 19

def id
  @id
end

#localeObject

Returns the value of attribute locale.



36
37
38
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 36

def locale
  @locale
end

#loginObject

Returns the value of attribute login.



47
48
49
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 47

def 
  @login
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 21

def name
  @name
end

#pending_change_passwordObject

Returns the value of attribute pending_change_password.



40
41
42
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 40

def pending_change_password
  @pending_change_password
end

#phoneObject

E.164 international phone number formatting



32
33
34
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 32

def phone
  @phone
end

#photo_uriObject

Returns the value of attribute photo_uri.



51
52
53
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 51

def photo_uri
  @photo_uri
end

#roleObject

Returns the value of attribute role.



25
26
27
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 25

def role
  @role
end

#ssnObject

Returns the value of attribute ssn.



27
28
29
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 27

def ssn
  @ssn
end

#tutorial_completeObject

Returns the value of attribute tutorial_complete.



29
30
31
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 29

def tutorial_complete
  @tutorial_complete
end

#typeObject

Returns the value of attribute type.



23
24
25
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 23

def type
  @type
end

#workspacesObject

Returns the value of attribute workspaces.



45
46
47
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 45

def workspaces
  @workspaces
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



98
99
100
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 98

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 76

def self.attribute_map
  {
    :'id' => :'id',
    :'name' => :'name',
    :'type' => :'type',
    :'role' => :'role',
    :'ssn' => :'ssn',
    :'tutorial_complete' => :'tutorial_complete',
    :'phone' => :'phone',
    :'authorities' => :'authorities',
    :'locale' => :'locale',
    :'clock_format' => :'clock_format',
    :'pending_change_password' => :'pending_change_password',
    :'default_workspace_id' => :'default_workspace_id',
    :'workspaces' => :'workspaces',
    :'login' => :'login',
    :'country_code' => :'country_code',
    :'photo_uri' => :'photo_uri'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



329
330
331
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 329

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_all_ofObject

List of class defined in allOf (OpenAPI v3)



131
132
133
134
135
136
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 131

def self.openapi_all_of
  [
  :'BasicAccount',
  :'IdentifiedModel'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



125
126
127
128
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 125

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 103

def self.openapi_types
  {
    :'id' => :'String',
    :'name' => :'String',
    :'type' => :'String',
    :'role' => :'AccountRole',
    :'ssn' => :'String',
    :'tutorial_complete' => :'Boolean',
    :'phone' => :'String',
    :'authorities' => :'Array<Authority>',
    :'locale' => :'String',
    :'clock_format' => :'String',
    :'pending_change_password' => :'Boolean',
    :'default_workspace_id' => :'String',
    :'workspaces' => :'Array<Workspace>',
    :'login' => :'String',
    :'country_code' => :'String',
    :'photo_uri' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 293

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      name == o.name &&
      type == o.type &&
      role == o.role &&
      ssn == o.ssn &&
      tutorial_complete == o.tutorial_complete &&
      phone == o.phone &&
      authorities == o.authorities &&
      locale == o.locale &&
      clock_format == o.clock_format &&
      pending_change_password == o.pending_change_password &&
      default_workspace_id == o.default_workspace_id &&
      workspaces == o.workspaces &&
       == o. &&
      country_code == o.country_code &&
      photo_uri == o.photo_uri
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 360

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = CropwisePlatformSdk.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 431

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 336

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


316
317
318
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 316

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



322
323
324
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 322

def hash
  [id, name, type, role, ssn, tutorial_complete, phone, authorities, locale, clock_format, pending_change_password, default_workspace_id, workspaces, , country_code, photo_uri].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 224

def list_invalid_properties
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @name.nil?
    invalid_properties.push('invalid value for "name", name cannot be nil.')
  end

  if @type.nil?
    invalid_properties.push('invalid value for "type", type cannot be nil.')
  end

  if @authorities.nil?
    invalid_properties.push('invalid value for "authorities", authorities cannot be nil.')
  end

  if !@country_code.nil? && @country_code.to_s.length > 2
    invalid_properties.push('invalid value for "country_code", the character length must be smaller than or equal to 2.')
  end

  if !@country_code.nil? && @country_code.to_s.length < 2
    invalid_properties.push('invalid value for "country_code", the character length must be great than or equal to 2.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



407
408
409
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 407

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 413

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



401
402
403
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 401

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



255
256
257
258
259
260
261
262
263
264
265
# File 'lib/cropwise-platform-sdk/models/identified_account.rb', line 255

def valid?
  return false if @id.nil?
  return false if @name.nil?
  return false if @type.nil?
  return false if @authorities.nil?
  clock_format_validator = EnumAttributeValidator.new('String', ["ALWAYS_12", "ALWAYS_24", "LET_LOCALE_DECIDE"])
  return false unless clock_format_validator.valid?(@clock_format)
  return false if !@country_code.nil? && @country_code.to_s.length > 2
  return false if !@country_code.nil? && @country_code.to_s.length < 2
  true
end