Class: Samsara::Types::TripResponseBody

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/trip_response_body.rb

Overview

Trip

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset:, completion_status:, created_at_time:, end_location: OMIT, start_location:, trip_end_time: OMIT, trip_start_time:, updated_at_time:, additional_properties: nil) ⇒ Samsara::Types::TripResponseBody

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/samsara_api/types/trip_response_body.rb', line 48

def initialize(asset:, completion_status:, created_at_time:, end_location: OMIT, start_location:, trip_end_time: OMIT, trip_start_time:, updated_at_time:, additional_properties: nil)
  @asset = asset
  @completion_status = completion_status
  @created_at_time = created_at_time
  @end_location = end_location if end_location != OMIT
  @start_location = start_location
  @trip_end_time = trip_end_time if trip_end_time != OMIT
  @trip_start_time = trip_start_time
  @updated_at_time = updated_at_time
  @additional_properties = additional_properties
  @_field_set = { "asset": asset, "completionStatus": completion_status, "createdAtTime": created_at_time, "endLocation": end_location, "startLocation": start_location, "tripEndTime": trip_end_time, "tripStartTime": trip_start_time, "updatedAtTime": updated_at_time }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



30
31
32
# File 'lib/samsara_api/types/trip_response_body.rb', line 30

def additional_properties
  @additional_properties
end

#asset ⇒ Samsara::Types::TripAssetResponseBody (readonly)



13
14
15
# File 'lib/samsara_api/types/trip_response_body.rb', line 13

def asset
  @asset
end

#completion_status ⇒ Samsara::Types::TripResponseBodyCompletionStatus (readonly)

Returns Trip completion status Valid values: inProgress, completed.

Returns:



15
16
17
# File 'lib/samsara_api/types/trip_response_body.rb', line 15

def completion_status
  @completion_status
end

#created_at_time ⇒ String (readonly)

Returns [RFC 3339] Time the trip was created in Samsara in UTC.

Returns:

  • (String) —

    [RFC 3339] Time the trip was created in Samsara in UTC.



17
18
19
# File 'lib/samsara_api/types/trip_response_body.rb', line 17

def created_at_time
  @created_at_time
end

#end_location ⇒ Samsara::Types::LocationResponseResponseBody (readonly)



19
20
21
# File 'lib/samsara_api/types/trip_response_body.rb', line 19

def end_location
  @end_location
end

#start_location ⇒ Samsara::Types::LocationResponseResponseBody (readonly)



21
22
23
# File 'lib/samsara_api/types/trip_response_body.rb', line 21

def start_location
  @start_location
end

#trip_end_time ⇒ String (readonly)

Returns [RFC 3339] Time the trip ended in UTC.

Returns:

  • (String) —

    [RFC 3339] Time the trip ended in UTC.



23
24
25
# File 'lib/samsara_api/types/trip_response_body.rb', line 23

def trip_end_time
  @trip_end_time
end

#trip_start_time ⇒ String (readonly)

Returns [RFC 3339] Time the trip started in UTC.

Returns:

  • (String) —

    [RFC 3339] Time the trip started in UTC.



25
26
27
# File 'lib/samsara_api/types/trip_response_body.rb', line 25

def trip_start_time
  @trip_start_time
end

#updated_at_time ⇒ Object (readonly)

endTime populates or completionStatus changes values.



28
29
30
# File 'lib/samsara_api/types/trip_response_body.rb', line 28

def updated_at_time
  @updated_at_time
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Types::TripResponseBody

Parameters:

  • json_object (String)

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/samsara_api/types/trip_response_body.rb', line 66

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["asset"].nil?
    asset = parsed_json["asset"].to_json
    asset = Samsara::Types::TripAssetResponseBody.from_json(json_object: asset)
  else
    asset = nil
  end
  completion_status = parsed_json["completionStatus"]
  created_at_time = parsed_json["createdAtTime"]
  unless parsed_json["endLocation"].nil?
    end_location = parsed_json["endLocation"].to_json
    end_location = Samsara::Types::LocationResponseResponseBody.from_json(json_object: end_location)
  else
    end_location = nil
  end
  unless parsed_json["startLocation"].nil?
    start_location = parsed_json["startLocation"].to_json
    start_location = Samsara::Types::LocationResponseResponseBody.from_json(json_object: start_location)
  else
    start_location = nil
  end
  trip_end_time = parsed_json["tripEndTime"]
  trip_start_time = parsed_json["tripStartTime"]
  updated_at_time = parsed_json["updatedAtTime"]
  new(
    asset: asset,
    completion_status: completion_status,
    created_at_time: created_at_time,
    end_location: end_location,
    start_location: start_location,
    trip_end_time: trip_end_time,
    trip_start_time: trip_start_time,
    updated_at_time: updated_at_time,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


116
117
118
119
120
121
122
123
124
125
# File 'lib/samsara_api/types/trip_response_body.rb', line 116

def self.validate_raw(obj:)
  Samsara::Types::TripAssetResponseBody.validate_raw(obj: obj.asset)
  obj.completion_status.is_a?(Samsara::Types::TripResponseBodyCompletionStatus) != false || raise("Passed value for field obj.completion_status is not the expected type, validation failed.")
  obj.created_at_time.is_a?(String) != false || raise("Passed value for field obj.created_at_time is not the expected type, validation failed.")
  obj.end_location.nil? || Samsara::Types::LocationResponseResponseBody.validate_raw(obj: obj.end_location)
  Samsara::Types::LocationResponseResponseBody.validate_raw(obj: obj.start_location)
  obj.trip_end_time&.is_a?(String) != false || raise("Passed value for field obj.trip_end_time is not the expected type, validation failed.")
  obj.trip_start_time.is_a?(String) != false || raise("Passed value for field obj.trip_start_time is not the expected type, validation failed.")
  obj.updated_at_time.is_a?(String) != false || raise("Passed value for field obj.updated_at_time is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


107
108
109
# File 'lib/samsara_api/types/trip_response_body.rb', line 107

def to_json
  @_field_set&.to_json
end