Class: Ittybit::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/ittybit/types/task.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, object:, kind:, status:, created:, updated:, input: OMIT, options: OMIT, output: OMIT, progress: OMIT, error: OMIT, created_by: OMIT, parent_id: OMIT, workflow: OMIT, results: OMIT, additional_properties: nil) ⇒ Ittybit::Task



67
68
69
70
71
72
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
104
# File 'lib/ittybit/types/task.rb', line 67

def initialize(id:, object:, kind:, status:, created:, updated:, input: OMIT, options: OMIT, output: OMIT, progress: OMIT, error: OMIT,
               created_by: OMIT, parent_id: OMIT, workflow: OMIT, results: OMIT, additional_properties: nil)
  @id = id
  @object = object
  @kind = kind
  @input = input if input != OMIT
  @options = options if options != OMIT
  @output = output if output != OMIT
  @status = status
  @progress = progress if progress != OMIT
  @error = error if error != OMIT
  @created_by = created_by if created_by != OMIT
  @created = created
  @updated = updated
  @parent_id = parent_id if parent_id != OMIT
  @workflow = workflow if workflow != OMIT
  @results = results if results != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "object": object,
    "kind": kind,
    "input": input,
    "options": options,
    "output": output,
    "status": status,
    "progress": progress,
    "error": error,
    "created_by": created_by,
    "created": created,
    "updated": updated,
    "parent_id": parent_id,
    "workflow": workflow,
    "results": results
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



43
44
45
# File 'lib/ittybit/types/task.rb', line 43

def additional_properties
  @additional_properties
end

#createdDateTime (readonly)



33
34
35
# File 'lib/ittybit/types/task.rb', line 33

def created
  @created
end

#created_byString (readonly)



31
32
33
# File 'lib/ittybit/types/task.rb', line 31

def created_by
  @created_by
end

#errorString (readonly)



29
30
31
# File 'lib/ittybit/types/task.rb', line 29

def error
  @error
end

#idString (readonly)



13
14
15
# File 'lib/ittybit/types/task.rb', line 13

def id
  @id
end

#inputHash{String => Object} (readonly)



19
20
21
# File 'lib/ittybit/types/task.rb', line 19

def input
  @input
end

#kindIttybit::TASK_KIND (readonly)



17
18
19
# File 'lib/ittybit/types/task.rb', line 17

def kind
  @kind
end

#objectString (readonly)



15
16
17
# File 'lib/ittybit/types/task.rb', line 15

def object
  @object
end

#optionsHash{String => Object} (readonly)



21
22
23
# File 'lib/ittybit/types/task.rb', line 21

def options
  @options
end

#outputHash{String => Object} (readonly)



23
24
25
# File 'lib/ittybit/types/task.rb', line 23

def output
  @output
end

#parent_idString (readonly)



37
38
39
# File 'lib/ittybit/types/task.rb', line 37

def parent_id
  @parent_id
end

#progressInteger (readonly)



27
28
29
# File 'lib/ittybit/types/task.rb', line 27

def progress
  @progress
end

#resultsIttybit::TaskResults (readonly)



41
42
43
# File 'lib/ittybit/types/task.rb', line 41

def results
  @results
end

#statusIttybit::TaskStatus (readonly)



25
26
27
# File 'lib/ittybit/types/task.rb', line 25

def status
  @status
end

#updatedDateTime (readonly)



35
36
37
# File 'lib/ittybit/types/task.rb', line 35

def updated
  @updated
end

#workflowArray<Object> (readonly)



39
40
41
# File 'lib/ittybit/types/task.rb', line 39

def workflow
  @workflow
end

Class Method Details

.from_json(json_object:) ⇒ Ittybit::Task

Deserialize a JSON object to an instance of Task



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
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/ittybit/types/task.rb', line 110

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  object = parsed_json["object"]
  kind = parsed_json["kind"]
  input = parsed_json["input"]
  options = parsed_json["options"]
  output = parsed_json["output"]
  status = parsed_json["status"]
  progress = parsed_json["progress"]
  error = parsed_json["error"]
  created_by = parsed_json["created_by"]
  created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
  updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
  parent_id = parsed_json["parent_id"]
  workflow = parsed_json["workflow"]
  if parsed_json["results"].nil?
    results = nil
  else
    results = parsed_json["results"].to_json
    results = Ittybit::TaskResults.from_json(json_object: results)
  end
  new(
    id: id,
    object: object,
    kind: kind,
    input: input,
    options: options,
    output: output,
    status: status,
    progress: progress,
    error: error,
    created_by: created_by,
    created: created,
    updated: updated,
    parent_id: parent_id,
    workflow: workflow,
    results: results,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/ittybit/types/task.rb', line 166

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.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.")
  obj.kind.is_a?(Object) != false || raise("Passed value for field obj.kind is not the expected type, validation failed.")
  obj.input&.is_a?(Hash) != false || raise("Passed value for field obj.input is not the expected type, validation failed.")
  obj.options&.is_a?(Hash) != false || raise("Passed value for field obj.options is not the expected type, validation failed.")
  obj.output&.is_a?(Hash) != false || raise("Passed value for field obj.output is not the expected type, validation failed.")
  obj.status.is_a?(Ittybit::TaskStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.progress&.is_a?(Integer) != false || raise("Passed value for field obj.progress is not the expected type, validation failed.")
  obj.error&.is_a?(String) != false || raise("Passed value for field obj.error is not the expected type, validation failed.")
  obj.created_by&.is_a?(String) != false || raise("Passed value for field obj.created_by is not the expected type, validation failed.")
  obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
  obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
  obj.parent_id&.is_a?(String) != false || raise("Passed value for field obj.parent_id is not the expected type, validation failed.")
  obj.workflow&.is_a?(Array) != false || raise("Passed value for field obj.workflow is not the expected type, validation failed.")
  obj.results.nil? || Ittybit::TaskResults.validate_raw(obj: obj.results)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Task to a JSON object



156
157
158
# File 'lib/ittybit/types/task.rb', line 156

def to_json(*_args)
  @_field_set&.to_json
end