Class: Samsara::Types::AlertEventDvirDefectsItem

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: OMIT, created_at: OMIT, defect_type: OMIT, comment: OMIT, additional_properties: nil) ⇒ Samsara::Types::AlertEventDvirDefectsItem

Parameters:

  • id (String) (defaults to: OMIT) —

    ID of the defect

  • created_at (DateTime) (defaults to: OMIT) —

    Creation timestamp

  • defect_type (String) (defaults to: OMIT) —

    Type of defect

  • comment (String) (defaults to: OMIT) —

    Defect comment

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

    Additional properties unmapped to the current class definition



31
32
33
34
35
36
37
38
39
40
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 31

def initialize(id: OMIT, created_at: OMIT, defect_type: OMIT, comment: OMIT, additional_properties: nil)
  @id = id if id != OMIT
  @created_at = created_at if created_at != OMIT
  @defect_type = defect_type if defect_type != OMIT
  @comment = comment if comment != OMIT
  @additional_properties = additional_properties
  @_field_set = { "id": id, "createdAt": created_at, "defectType": defect_type, "comment": comment }.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



18
19
20
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 18

def additional_properties
  @additional_properties
end

#comment ⇒ String (readonly)

Returns Defect comment.

Returns:

  • (String) —

    Defect comment



16
17
18
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 16

def comment
  @comment
end

#created_at ⇒ DateTime (readonly)

Returns Creation timestamp.

Returns:

  • (DateTime) —

    Creation timestamp



12
13
14
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 12

def created_at
  @created_at
end

#defect_type ⇒ String (readonly)

Returns Type of defect.

Returns:

  • (String) —

    Type of defect



14
15
16
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 14

def defect_type
  @defect_type
end

#id ⇒ String (readonly)

Returns ID of the defect.

Returns:

  • (String) —

    ID of the defect



10
11
12
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 10

def id
  @id
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 45

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  created_at = unless parsed_json["createdAt"].nil?
  DateTime.parse(parsed_json["createdAt"])
else
  nil
end
  defect_type = parsed_json["defectType"]
  comment = parsed_json["comment"]
  new(
    id: id,
    created_at: created_at,
    defect_type: defect_type,
    comment: comment,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


76
77
78
79
80
81
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 76

def self.validate_raw(obj:)
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.defect_type&.is_a?(String) != false || raise("Passed value for field obj.defect_type is not the expected type, validation failed.")
  obj.comment&.is_a?(String) != false || raise("Passed value for field obj.comment is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


67
68
69
# File 'lib/samsara_api/types/alert_event_dvir_defects_item.rb', line 67

def to_json
  @_field_set&.to_json
end