Class: Samsara::Types::FormTemplateResponseObjectResponseBody

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

Overview

Form Template response object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(approval_config: OMIT, created_at_time:, created_by:, description: OMIT, fields:, id:, revision_id:, sections:, title:, updated_at_time:, updated_by:, additional_properties: nil) ⇒ Samsara::Types::FormTemplateResponseObjectResponseBody

Parameters:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/samsara_api/types/form_template_response_object_response_body.rb', line 60

def initialize(approval_config: OMIT, created_at_time:, created_by:, description: OMIT, fields:, id:, revision_id:, sections:, title:, updated_at_time:, updated_by:, additional_properties: nil)
  @approval_config = approval_config if approval_config != OMIT
  @created_at_time = created_at_time
  @created_by = created_by
  @description = description if description != OMIT
  @fields = fields
  @id = id
  @revision_id = revision_id
  @sections = sections
  @title = title
  @updated_at_time = updated_at_time
  @updated_by = updated_by
  @additional_properties = additional_properties
  @_field_set = { "approvalConfig": approval_config, "createdAtTime": created_at_time, "createdBy": created_by, "description": description, "fields": fields, "id": id, "revisionId": revision_id, "sections": sections, "title": title, "updatedAtTime": updated_at_time, "updatedBy": updated_by }.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



39
40
41
# File 'lib/samsara_api/types/form_template_response_object_response_body.rb', line 39

def additional_properties
  @additional_properties
end

#approval_configSamsara::Types::FormsApprovalConfigObjectResponseBody (readonly)



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

def approval_config
  @approval_config
end

#created_at_timeDateTime (readonly)

Returns Creation time of the form template. UTC timestamp in RFC 3339 format.

Returns:

  • (DateTime)

    Creation time of the form template. UTC timestamp in RFC 3339 format.



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

def created_at_time
  @created_at_time
end

#created_bySamsara::Types::FormsPolymorphicUserObjectResponseBody (readonly)



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

def created_by
  @created_by
end

#descriptionObject (readonly)

description.



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

def description
  @description
end

#fieldsArray<Samsara::Types::FormsFieldDefinitionObjectResponseBody> (readonly)

Returns List of fields in the form template.

Returns:



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

def fields
  @fields
end

#idString (readonly)

Returns Unique identifier of the form template.

Returns:

  • (String)

    Unique identifier of the form template.



27
28
29
# File 'lib/samsara_api/types/form_template_response_object_response_body.rb', line 27

def id
  @id
end

#revision_idString (readonly)

Returns Unique identifier of the form template revision.

Returns:

  • (String)

    Unique identifier of the form template revision.



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

def revision_id
  @revision_id
end

#sectionsArray<Samsara::Types::FormTemplateSectionObjectResponseBody> (readonly)

Returns List of sections in the form template.

Returns:



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

def sections
  @sections
end

#titleString (readonly)

Returns Title of the form template.

Returns:

  • (String)

    Title of the form template.



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

def title
  @title
end

#updated_at_timeDateTime (readonly)

Returns Update time of the form template. UTC timestamp in RFC 3339 format.

Returns:

  • (DateTime)

    Update time of the form template. UTC timestamp in RFC 3339 format.



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

def updated_at_time
  @updated_at_time
end

#updated_bySamsara::Types::FormsPolymorphicUserObjectResponseBody (readonly)



37
38
39
# File 'lib/samsara_api/types/form_template_response_object_response_body.rb', line 37

def updated_by
  @updated_by
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/samsara_api/types/form_template_response_object_response_body.rb', line 82

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["approvalConfig"].nil?
    approval_config = parsed_json["approvalConfig"].to_json
    approval_config = Samsara::Types::FormsApprovalConfigObjectResponseBody.from_json(json_object: approval_config)
  else
    approval_config = nil
  end
  created_at_time = unless parsed_json["createdAtTime"].nil?
  DateTime.parse(parsed_json["createdAtTime"])
else
  nil
end
  unless parsed_json["createdBy"].nil?
    created_by = parsed_json["createdBy"].to_json
    created_by = Samsara::Types::FormsPolymorphicUserObjectResponseBody.from_json(json_object: created_by)
  else
    created_by = nil
  end
  description = parsed_json["description"]
  fields = parsed_json["fields"]&.map do | item |
  item = item.to_json
  Samsara::Types::FormsFieldDefinitionObjectResponseBody.from_json(json_object: item)
end
  id = parsed_json["id"]
  revision_id = parsed_json["revisionId"]
  sections = parsed_json["sections"]&.map do | item |
  item = item.to_json
  Samsara::Types::FormTemplateSectionObjectResponseBody.from_json(json_object: item)
end
  title = parsed_json["title"]
  updated_at_time = unless parsed_json["updatedAtTime"].nil?
  DateTime.parse(parsed_json["updatedAtTime"])
else
  nil
end
  unless parsed_json["updatedBy"].nil?
    updated_by = parsed_json["updatedBy"].to_json
    updated_by = Samsara::Types::FormsPolymorphicUserObjectResponseBody.from_json(json_object: updated_by)
  else
    updated_by = nil
  end
  new(
    approval_config: approval_config,
    created_at_time: created_at_time,
    created_by: created_by,
    description: description,
    fields: fields,
    id: id,
    revision_id: revision_id,
    sections: sections,
    title: title,
    updated_at_time: updated_at_time,
    updated_by: updated_by,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/samsara_api/types/form_template_response_object_response_body.rb', line 152

def self.validate_raw(obj:)
  obj.approval_config.nil? || Samsara::Types::FormsApprovalConfigObjectResponseBody.validate_raw(obj: obj.approval_config)
  obj.created_at_time.is_a?(DateTime) != false || raise("Passed value for field obj.created_at_time is not the expected type, validation failed.")
  Samsara::Types::FormsPolymorphicUserObjectResponseBody.validate_raw(obj: obj.created_by)
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.fields.is_a?(Array) != false || raise("Passed value for field obj.fields 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.revision_id.is_a?(String) != false || raise("Passed value for field obj.revision_id is not the expected type, validation failed.")
  obj.sections.is_a?(Array) != false || raise("Passed value for field obj.sections 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.")
  obj.updated_at_time.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at_time is not the expected type, validation failed.")
  Samsara::Types::FormsPolymorphicUserObjectResponseBody.validate_raw(obj: obj.updated_by)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


143
144
145
# File 'lib/samsara_api/types/form_template_response_object_response_body.rb', line 143

def to_json
  @_field_set&.to_json
end