Class: Courier::Users::Tokens::Tracking
- Inherits:
-
Object
- Object
- Courier::Users::Tokens::Tracking
- Defined in:
- lib/trycourier/users/tokens/types/tracking.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#long ⇒ Object
readonly
Returns the value of attribute long.
-
#os_version ⇒ Object
readonly
Returns the value of attribute os_version.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Users::Tokens::Tracking
Deserialize a JSON object to an instance of Tracking.
-
.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(os_version: nil, ip: nil, lat: nil, long: nil, additional_properties: nil) ⇒ Users::Tokens::Tracking constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of Tracking to a JSON object.
Constructor Details
#initialize(os_version: nil, ip: nil, lat: nil, long: nil, additional_properties: nil) ⇒ Users::Tokens::Tracking
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_properties ⇒ Object (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 |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
9 10 11 |
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 9 def ip @ip end |
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
9 10 11 |
# File 'lib/trycourier/users/tokens/types/tracking.rb', line 9 def lat @lat end |
#long ⇒ Object (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_version ⇒ Object (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
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.
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
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 |