Class: Samsara::Types::RouteFeedObjectResponseBody

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

Overview

Route feed object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(changes:, operation: OMIT, route:, source:, time:, type:, additional_properties: nil) ⇒ Samsara::Types::RouteFeedObjectResponseBody

Parameters:

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

    Additional properties unmapped to the current class definition



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 58

def initialize(changes:, operation: OMIT, route:, source:, time:, type:, additional_properties: nil)
  @changes = changes
  @operation = operation if operation != OMIT
  @route = route
  @source = source
  @time = time
  @type = type
  @additional_properties = additional_properties
  @_field_set = { "changes": changes, "operation": operation, "route": route, "source": source, "time": time, "type": type }.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



35
36
37
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 35

def additional_properties
  @additional_properties
end

#changes ⇒ Samsara::Types::RouteChangesResponseBody (readonly)



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

def changes
  @changes
end

#operation ⇒ Object (readonly)

time updated, stop order changed, stop arrival prevented`



20
21
22
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 20

def operation
  @operation
end

#route ⇒ Samsara::Types::BaseRouteResponseObjectResponseBody (readonly)



22
23
24
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 22

def route
  @route
end

#source ⇒ Object (readonly)

admin



26
27
28
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 26

def source
  @source
end

#time ⇒ DateTime (readonly)

Returns The timestamp of the route in RFC 3339 format.

Returns:

  • (DateTime) —

    The timestamp of the route in RFC 3339 format.



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

def time
  @time
end

#type ⇒ Object (readonly)

additional types are added. Valid values: route tracking



33
34
35
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 33

def type
  @type
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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
104
105
106
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 74

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["changes"].nil?
    changes = parsed_json["changes"].to_json
    changes = Samsara::Types::RouteChangesResponseBody.from_json(json_object: changes)
  else
    changes = nil
  end
  operation = parsed_json["operation"]
  unless parsed_json["route"].nil?
    route = parsed_json["route"].to_json
    route = Samsara::Types::BaseRouteResponseObjectResponseBody.from_json(json_object: route)
  else
    route = nil
  end
  source = parsed_json["source"]
  time = unless parsed_json["time"].nil?
  DateTime.parse(parsed_json["time"])
else
  nil
end
  type = parsed_json["type"]
  new(
    changes: changes,
    operation: operation,
    route: route,
    source: source,
    time: time,
    type: type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


119
120
121
122
123
124
125
126
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 119

def self.validate_raw(obj:)
  Samsara::Types::RouteChangesResponseBody.validate_raw(obj: obj.changes)
  obj.operation&.is_a?(Samsara::Types::RouteFeedObjectResponseBodyOperation) != false || raise("Passed value for field obj.operation is not the expected type, validation failed.")
  Samsara::Types::BaseRouteResponseObjectResponseBody.validate_raw(obj: obj.route)
  obj.source.is_a?(Samsara::Types::RouteFeedObjectResponseBodySource) != false || raise("Passed value for field obj.source is not the expected type, validation failed.")
  obj.time.is_a?(DateTime) != false || raise("Passed value for field obj.time is not the expected type, validation failed.")
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


110
111
112
# File 'lib/samsara_api/types/route_feed_object_response_body.rb', line 110

def to_json
  @_field_set&.to_json
end