Class: Samsara::Types::DefectsResponse
- Inherits:
-
Object
- Object
- Samsara::Types::DefectsResponse
- Defined in:
- lib/samsara_api/types/defects_response.rb
Overview
A list of defects.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #data ⇒ Array<Samsara::Types::Defect> readonly
- #pagination ⇒ Samsara::Types::PaginationResponse readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(data: OMIT, pagination: OMIT, additional_properties: nil) ⇒ Samsara::Types::DefectsResponse constructor
- #to_json ⇒ String
Constructor Details
#initialize(data: OMIT, pagination: OMIT, additional_properties: nil) ⇒ Samsara::Types::DefectsResponse
27 28 29 30 31 32 33 34 |
# File 'lib/samsara_api/types/defects_response.rb', line 27 def initialize(data: OMIT, pagination: OMIT, additional_properties: nil) @data = data if data != OMIT @pagination = pagination if pagination != OMIT @additional_properties = additional_properties @_field_set = { "data": data, "pagination": pagination }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
16 17 18 |
# File 'lib/samsara_api/types/defects_response.rb', line 16 def additional_properties @additional_properties end |
#data ⇒ Array<Samsara::Types::Defect> (readonly)
12 13 14 |
# File 'lib/samsara_api/types/defects_response.rb', line 12 def data @data end |
#pagination ⇒ Samsara::Types::PaginationResponse (readonly)
14 15 16 |
# File 'lib/samsara_api/types/defects_response.rb', line 14 def pagination @pagination end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::DefectsResponse
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/samsara_api/types/defects_response.rb', line 39 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) data = parsed_json["data"]&.map do | item | item = item.to_json Samsara::Types::Defect.from_json(json_object: item) end unless parsed_json["pagination"].nil? pagination = parsed_json["pagination"].to_json pagination = Samsara::Types::PaginationResponse.from_json(json_object: pagination) else pagination = nil end new( data: data, pagination: pagination, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
70 71 72 73 |
# File 'lib/samsara_api/types/defects_response.rb', line 70 def self.validate_raw(obj:) obj.data&.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") obj.pagination.nil? || Samsara::Types::PaginationResponse.validate_raw(obj: obj.pagination) end |
Instance Method Details
#to_json ⇒ String
61 62 63 |
# File 'lib/samsara_api/types/defects_response.rb', line 61 def to_json @_field_set&.to_json end |