Class: Samsara::Types::TrainingCourseResponseObjectResponseBody

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

Overview

Training Course response object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category:, description: OMIT, estimated_time_to_complete_minutes:, id:, labels: OMIT, revision_id:, status:, title:, additional_properties: nil) ⇒ Samsara::Types::TrainingCourseResponseObjectResponseBody

Parameters:

  • title (String)

    Title of the course.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/samsara_api/types/training_course_response_object_response_body.rb', line 54

def initialize(category:, description: OMIT, estimated_time_to_complete_minutes:, id:, labels: OMIT, revision_id:, status:, title:, additional_properties: nil)
  @category = category
  @description = description if description != OMIT
  @estimated_time_to_complete_minutes = estimated_time_to_complete_minutes
  @id = id
  @labels = labels if labels != OMIT
  @revision_id = revision_id
  @status = status
  @title = title
  @additional_properties = additional_properties
  @_field_set = { "category": category, "description": description, "estimatedTimeToCompleteMinutes": estimated_time_to_complete_minutes, "id": id, "labels": labels, "revisionId": revision_id, "status": status, "title": title }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#categorySamsara::Types::TrainingCategoryObjectResponseBody (readonly)



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

def category
  @category
end

#descriptionString (readonly)

Returns Description of the course.

Returns:

  • (String)

    Description of the course.



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

def description
  @description
end

#estimated_time_to_complete_minutesLong (readonly)

Returns Estimated time it takes to complete the course.

Returns:

  • (Long)

    Estimated time it takes to complete the course.



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

def estimated_time_to_complete_minutes
  @estimated_time_to_complete_minutes
end

#idString (readonly)

Returns ID of the training course.

Returns:

  • (String)

    ID of the training course.



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

def id
  @id
end

#labelsArray<Samsara::Types::TrainingCourseLabelObjectResponseBody> (readonly)

Returns List of course labels.

Returns:



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

def labels
  @labels
end

#revision_idString (readonly)

Returns ID of the course’s specific version.

Returns:

  • (String)

    ID of the course’s specific version.



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

def revision_id
  @revision_id
end

#statusObject (readonly)

values: ‘published`, `deleted`, `archived`, `unknown`



29
30
31
# File 'lib/samsara_api/types/training_course_response_object_response_body.rb', line 29

def status
  @status
end

#titleString (readonly)

Returns Title of the course.

Returns:

  • (String)

    Title of the course.



31
32
33
# File 'lib/samsara_api/types/training_course_response_object_response_body.rb', line 31

def title
  @title
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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/training_course_response_object_response_body.rb', line 73

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["category"].nil?
    category = parsed_json["category"].to_json
    category = Samsara::Types::TrainingCategoryObjectResponseBody.from_json(json_object: category)
  else
    category = nil
  end
  description = parsed_json["description"]
  estimated_time_to_complete_minutes = parsed_json["estimatedTimeToCompleteMinutes"]
  id = parsed_json["id"]
  labels = parsed_json["labels"]&.map do | item |
  item = item.to_json
  Samsara::Types::TrainingCourseLabelObjectResponseBody.from_json(json_object: item)
end
  revision_id = parsed_json["revisionId"]
  status = parsed_json["status"]
  title = parsed_json["title"]
  new(
    category: category,
    description: description,
    estimated_time_to_complete_minutes: estimated_time_to_complete_minutes,
    id: id,
    labels: labels,
    revision_id: revision_id,
    status: status,
    title: title,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

def self.validate_raw(obj:)
  Samsara::Types::TrainingCategoryObjectResponseBody.validate_raw(obj: obj.category)
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.estimated_time_to_complete_minutes.is_a?(Long) != false || raise("Passed value for field obj.estimated_time_to_complete_minutes is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.labels&.is_a?(Array) != false || raise("Passed value for field obj.labels is not the expected type, validation failed.")
  obj.revision_id.is_a?(String) != false || raise("Passed value for field obj.revision_id is not the expected type, validation failed.")
  obj.status.is_a?(Samsara::Types::TrainingCourseResponseObjectResponseBodyStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.title.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


108
109
110
# File 'lib/samsara_api/types/training_course_response_object_response_body.rb', line 108

def to_json
  @_field_set&.to_json
end