Class: SyncteraRubySdk::DeviceDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/synctera_ruby_sdk/models/device_details.rb

Overview

Optionally provided browser device details, used as a fallback in case there is an issue with Device Data Collection. Note that minimal field validation is performed.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ DeviceDetails

Initializes the object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 94

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `SyncteraRubySdk::DeviceDetails` 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 `SyncteraRubySdk::DeviceDetails`. 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?(:'color_depth')
    self.color_depth = attributes[:'color_depth']
  end

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#color_depthObject

The device’s color palette bit depth, in bits per pixel



20
21
22
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 20

def color_depth
  @color_depth
end

#headerObject

The exact contents of the browser’s HTTP accept headers



23
24
25
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 23

def header
  @header
end

#ip_addressObject

The device’s IP address (either IPv4 or IPv6 formats are acceptable)



26
27
28
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 26

def ip_address
  @ip_address
end

#java_enabledObject

If the browser has the ability to execute Java (value returned from ‘navigator.javaEnabled` property)



29
30
31
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 29

def java_enabled
  @java_enabled
end

#javascript_enabledObject

If the browser has the ability to execute JavaScript (value returned from ‘navigator.javaScriptEnabled` property)



32
33
34
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 32

def javascript_enabled
  @javascript_enabled
end

#languageObject

The browser’s language as defined in IETF BCP47



35
36
37
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 35

def language
  @language
end

#screen_heightObject

The total height of the device’s screen, in pixels



38
39
40
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 38

def screen_height
  @screen_height
end

#screen_widthObject

The total width of the device’s screen, in pixels



41
42
43
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 41

def screen_width
  @screen_width
end

#timezoneObject

The offset from UTC of the device’s local timezone, in minutes



44
45
46
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 44

def timezone
  @timezone
end

#user_agentObject

The exact contents of the HTTP user agent header



47
48
49
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 47

def user_agent
  @user_agent
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



66
67
68
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 66

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 50

def self.attribute_map
  {
    :'color_depth' => :'color_depth',
    :'header' => :'header',
    :'ip_address' => :'ip_address',
    :'java_enabled' => :'java_enabled',
    :'javascript_enabled' => :'javascript_enabled',
    :'language' => :'language',
    :'screen_height' => :'screen_height',
    :'screen_width' => :'screen_width',
    :'timezone' => :'timezone',
    :'user_agent' => :'user_agent'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash



355
356
357
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 355

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

.openapi_nullableObject

List of attributes with nullable: true



87
88
89
90
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 87

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

.openapi_typesObject

Attribute type mapping.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 71

def self.openapi_types
  {
    :'color_depth' => :'Integer',
    :'header' => :'String',
    :'ip_address' => :'String',
    :'java_enabled' => :'Boolean',
    :'javascript_enabled' => :'Boolean',
    :'language' => :'String',
    :'screen_height' => :'Integer',
    :'screen_width' => :'Integer',
    :'timezone' => :'Integer',
    :'user_agent' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 325

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      color_depth == o.color_depth &&
      header == o.header &&
      ip_address == o.ip_address &&
      java_enabled == o.java_enabled &&
      javascript_enabled == o.javascript_enabled &&
      language == o.language &&
      screen_height == o.screen_height &&
      screen_width == o.screen_width &&
      timezone == o.timezone &&
      user_agent == o.user_agent
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type



386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 386

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 = SyncteraRubySdk.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



457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 457

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



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 362

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

See Also:

  • `==` method


342
343
344
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 342

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.



348
349
350
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 348

def hash
  [color_depth, header, ip_address, java_enabled, javascript_enabled, language, screen_height, screen_width, timezone, user_agent].hash
end

#list_invalid_propertiesObject

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



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
221
222
223
224
225
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 150

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

  if @color_depth > 99
    invalid_properties.push('invalid value for "color_depth", must be smaller than or equal to 99.')
  end

  if @color_depth < 1
    invalid_properties.push('invalid value for "color_depth", must be greater than or equal to 1.')
  end

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

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

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

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

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

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

  if @screen_height > 999999
    invalid_properties.push('invalid value for "screen_height", must be smaller than or equal to 999999.')
  end

  if @screen_height < 1
    invalid_properties.push('invalid value for "screen_height", must be greater than or equal to 1.')
  end

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

  if @screen_width > 999999
    invalid_properties.push('invalid value for "screen_width", must be smaller than or equal to 999999.')
  end

  if @screen_width < 1
    invalid_properties.push('invalid value for "screen_width", must be greater than or equal to 1.')
  end

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

  if @timezone > 840
    invalid_properties.push('invalid value for "timezone", must be smaller than or equal to 840.')
  end

  if @timezone < -840
    invalid_properties.push('invalid value for "timezone", must be greater than or equal to -840.')
  end

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

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



433
434
435
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 433

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 439

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



427
428
429
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 427

def to_s
  to_hash.to_s
end

#valid?Boolean

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



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/synctera_ruby_sdk/models/device_details.rb', line 229

def valid?
  return false if @color_depth.nil?
  return false if @color_depth > 99
  return false if @color_depth < 1
  return false if @header.nil?
  return false if @ip_address.nil?
  return false if @java_enabled.nil?
  return false if @javascript_enabled.nil?
  return false if @language.nil?
  return false if @screen_height.nil?
  return false if @screen_height > 999999
  return false if @screen_height < 1
  return false if @screen_width.nil?
  return false if @screen_width > 999999
  return false if @screen_width < 1
  return false if @timezone.nil?
  return false if @timezone > 840
  return false if @timezone < -840
  return false if @user_agent.nil?
  true
end