Class: Courier::Users::Tokens::Tracking

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/users/tokens/types/tracking.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(os_version: nil, ip: nil, lat: nil, long: nil, additional_properties: nil) ⇒ Users::Tokens::Tracking

Parameters:

  • os_version (String) (defaults to: nil)

    The operating system version

  • ip (String) (defaults to: nil)

    The IP address of the device

  • lat (String) (defaults to: nil)

    The latitude of the device

  • long (String) (defaults to: nil)

    The longitude of the device

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 17

def initialize(os_version: nil, ip: nil, lat: nil, long: nil, additional_properties: nil)
  # @type [String] The operating system version
  @os_version = os_version
  # @type [String] The IP address of the device
  @ip = ip
  # @type [String] The latitude of the device
  @lat = lat
  # @type [String] The longitude of the device
  @long = long
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



9
10
11
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 9

def additional_properties
  @additional_properties
end

#ipObject (readonly)

Returns the value of attribute ip.



9
10
11
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 9

def ip
  @ip
end

#latObject (readonly)

Returns the value of attribute lat.



9
10
11
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 9

def lat
  @lat
end

#longObject (readonly)

Returns the value of attribute long.



9
10
11
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 9

def long
  @long
end

#os_versionObject (readonly)

Returns the value of attribute os_version.



9
10
11
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 9

def os_version
  @os_version
end

Class Method Details

.from_json(json_object:) ⇒ Users::Tokens::Tracking

Deserialize a JSON object to an instance of Tracking

Parameters:

  • json_object (JSON)

Returns:



34
35
36
37
38
39
40
41
42
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 34

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  os_version = struct.os_version
  ip = struct.ip
  lat = struct.lat
  long = struct.long
  new(os_version: os_version, ip: ip, lat: lat, long: long, 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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


55
56
57
58
59
60
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 55

def self.validate_raw(obj:)
  obj.os_version&.is_a?(String) != false || raise("Passed value for field obj.os_version is not the expected type, validation failed.")
  obj.ip&.is_a?(String) != false || raise("Passed value for field obj.ip is not the expected type, validation failed.")
  obj.lat&.is_a?(String) != false || raise("Passed value for field obj.lat is not the expected type, validation failed.")
  obj.long&.is_a?(String) != false || raise("Passed value for field obj.long is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of Tracking to a JSON object

Returns:

  • (JSON)


47
48
49
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 47

def to_json(*_args)
  { "os_version": @os_version, "ip": @ip, "lat": @lat, "long": @long }.to_json
end