Class: Spatio::Task

Inherits:
ApiModelBase show all
Defined in:
lib/spatio-sdk/models/task.rb

Overview

A to-do / reminder / issue. Tasks belong to one connected account (‘accountId` + `provider`). Native tasks store in Spatio’s DB; external providers (Linear, GitHub Issues, Todoist, etc.) round-trip through Spatio.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Task

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/spatio-sdk/models/task.rb', line 166

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Spatio::Task` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Spatio::Task`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'provider')
    self.provider = attributes[:'provider']
  end

  if attributes.key?(:'account_id')
    self. = attributes[:'account_id']
  end

  if attributes.key?(:'owner_user_id')
    self.owner_user_id = attributes[:'owner_user_id']
  end

  if attributes.key?(:'title')
    self.title = attributes[:'title']
  else
    self.title = nil
  end

  if attributes.key?(:'description')
    self.description = attributes[:'description']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  end

  if attributes.key?(:'completed')
    self.completed = attributes[:'completed']
  else
    self.completed = nil
  end

  if attributes.key?(:'due_date')
    self.due_date = attributes[:'due_date']
  end

  if attributes.key?(:'priority')
    self.priority = attributes[:'priority']
  else
    self.priority = nil
  end

  if attributes.key?(:'labels')
    if (value = attributes[:'labels']).is_a?(Array)
      self.labels = value
    end
  end

  if attributes.key?(:'tags')
    if (value = attributes[:'tags']).is_a?(Array)
      self.tags = value
    end
  end

  if attributes.key?(:'assignee_id')
    self.assignee_id = attributes[:'assignee_id']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  else
    self.created_at = nil
  end

  if attributes.key?(:'updated_at')
    self.updated_at = attributes[:'updated_at']
  else
    self.updated_at = nil
  end

  if attributes.key?(:'completed_at')
    self.completed_at = attributes[:'completed_at']
  end

  if attributes.key?(:'parent_task_id')
    self.parent_task_id = attributes[:'parent_task_id']
  end

  if attributes.key?(:'metadata')
    if (value = attributes[:'metadata']).is_a?(Hash)
      self. = value
    end
  end

  if attributes.key?(:'type')
    self.type = attributes[:'type']
  end

  if attributes.key?(:'source_platform')
    self.source_platform = attributes[:'source_platform']
  end

  if attributes.key?(:'source_id')
    self.source_id = attributes[:'source_id']
  end
end

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.



24
25
26
# File 'lib/spatio-sdk/models/task.rb', line 24

def 
  @account_id
end

#assignee_idObject

Returns the value of attribute assignee_id.



46
47
48
# File 'lib/spatio-sdk/models/task.rb', line 46

def assignee_id
  @assignee_id
end

#completedObject

Returns the value of attribute completed.



35
36
37
# File 'lib/spatio-sdk/models/task.rb', line 35

def completed
  @completed
end

#completed_atObject

Returns the value of attribute completed_at.



52
53
54
# File 'lib/spatio-sdk/models/task.rb', line 52

def completed_at
  @completed_at
end

#created_atObject

Returns the value of attribute created_at.



48
49
50
# File 'lib/spatio-sdk/models/task.rb', line 48

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



30
31
32
# File 'lib/spatio-sdk/models/task.rb', line 30

def description
  @description
end

#due_dateObject

Returns the value of attribute due_date.



37
38
39
# File 'lib/spatio-sdk/models/task.rb', line 37

def due_date
  @due_date
end

#idObject

Returns the value of attribute id.



19
20
21
# File 'lib/spatio-sdk/models/task.rb', line 19

def id
  @id
end

#labelsObject

Returns the value of attribute labels.



42
43
44
# File 'lib/spatio-sdk/models/task.rb', line 42

def labels
  @labels
end

#metadataObject

Provider-specific extras.



58
59
60
# File 'lib/spatio-sdk/models/task.rb', line 58

def 
  @metadata
end

#owner_user_idObject

Returns the value of attribute owner_user_id.



26
27
28
# File 'lib/spatio-sdk/models/task.rb', line 26

def owner_user_id
  @owner_user_id
end

#parent_task_idObject

Parent task id when this is a subtask.



55
56
57
# File 'lib/spatio-sdk/models/task.rb', line 55

def parent_task_id
  @parent_task_id
end

#priorityObject

Priority bucket. Canonical values (mapped from a 0–4 integer): ‘none`, `low`, `medium`, `high`, `urgent`.



40
41
42
# File 'lib/spatio-sdk/models/task.rb', line 40

def priority
  @priority
end

#providerObject

Registered provider id (e.g. ‘native-tasks`, `linear`).



22
23
24
# File 'lib/spatio-sdk/models/task.rb', line 22

def provider
  @provider
end

#source_idObject

Source artifact id paired with ‘sourcePlatform`.



67
68
69
# File 'lib/spatio-sdk/models/task.rb', line 67

def source_id
  @source_id
end

#source_platformObject

When this task was auto-generated from another artifact (e.g. a calendar event reminder), the platform id of that artifact.



64
65
66
# File 'lib/spatio-sdk/models/task.rb', line 64

def source_platform
  @source_platform
end

#statusObject

Free-form status string. Canonical values across most providers: ‘todo`, `in_progress`, `in_review`, `backlog`, `done`. The platform falls back to `done` when `completed` is true and `status` is empty, else `todo`.



33
34
35
# File 'lib/spatio-sdk/models/task.rb', line 33

def status
  @status
end

#tagsObject

Returns the value of attribute tags.



44
45
46
# File 'lib/spatio-sdk/models/task.rb', line 44

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



28
29
30
# File 'lib/spatio-sdk/models/task.rb', line 28

def title
  @title
end

#typeObject

Discriminator. Canonical values: ‘todo`, `reminder`, `issue`. Empty defaults to `todo`.



61
62
63
# File 'lib/spatio-sdk/models/task.rb', line 61

def type
  @type
end

#updated_atObject

Returns the value of attribute updated_at.



50
51
52
# File 'lib/spatio-sdk/models/task.rb', line 50

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



119
120
121
# File 'lib/spatio-sdk/models/task.rb', line 119

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



124
125
126
# File 'lib/spatio-sdk/models/task.rb', line 124

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



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
# File 'lib/spatio-sdk/models/task.rb', line 92

def self.attribute_map
  {
    :'id' => :'id',
    :'provider' => :'provider',
    :'account_id' => :'accountId',
    :'owner_user_id' => :'ownerUserId',
    :'title' => :'title',
    :'description' => :'description',
    :'status' => :'status',
    :'completed' => :'completed',
    :'due_date' => :'dueDate',
    :'priority' => :'priority',
    :'labels' => :'labels',
    :'tags' => :'tags',
    :'assignee_id' => :'assigneeId',
    :'created_at' => :'createdAt',
    :'updated_at' => :'updatedAt',
    :'completed_at' => :'completedAt',
    :'parent_task_id' => :'parentTaskId',
    :'metadata' => :'metadata',
    :'type' => :'type',
    :'source_platform' => :'sourcePlatform',
    :'source_id' => :'sourceId'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/spatio-sdk/models/task.rb', line 433

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



156
157
158
159
160
161
162
# File 'lib/spatio-sdk/models/task.rb', line 156

def self.openapi_nullable
  Set.new([
    :'due_date',
    :'completed_at',
    :'parent_task_id',
  ])
end

.openapi_typesObject

Attribute type mapping.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/spatio-sdk/models/task.rb', line 129

def self.openapi_types
  {
    :'id' => :'String',
    :'provider' => :'String',
    :'account_id' => :'String',
    :'owner_user_id' => :'String',
    :'title' => :'String',
    :'description' => :'String',
    :'status' => :'String',
    :'completed' => :'Boolean',
    :'due_date' => :'Time',
    :'priority' => :'String',
    :'labels' => :'Array<String>',
    :'tags' => :'Array<String>',
    :'assignee_id' => :'String',
    :'created_at' => :'Time',
    :'updated_at' => :'Time',
    :'completed_at' => :'Time',
    :'parent_task_id' => :'String',
    :'metadata' => :'Hash<String, Object>',
    :'type' => :'String',
    :'source_platform' => :'String',
    :'source_id' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/spatio-sdk/models/task.rb', line 392

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      provider == o.provider &&
       == o. &&
      owner_user_id == o.owner_user_id &&
      title == o.title &&
      description == o.description &&
      status == o.status &&
      completed == o.completed &&
      due_date == o.due_date &&
      priority == o.priority &&
      labels == o.labels &&
      tags == o.tags &&
      assignee_id == o.assignee_id &&
      created_at == o.created_at &&
      updated_at == o.updated_at &&
      completed_at == o.completed_at &&
      parent_task_id == o.parent_task_id &&
       == o. &&
      type == o.type &&
      source_platform == o.source_platform &&
      source_id == o.source_id
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


420
421
422
# File 'lib/spatio-sdk/models/task.rb', line 420

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



426
427
428
# File 'lib/spatio-sdk/models/task.rb', line 426

def hash
  [id, provider, , owner_user_id, title, description, status, completed, due_date, priority, labels, tags, assignee_id, created_at, updated_at, completed_at, parent_task_id, , type, source_platform, source_id].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/spatio-sdk/models/task.rb', line 285

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @title.nil?
    invalid_properties.push('invalid value for "title", title cannot be nil.')
  end

  if @completed.nil?
    invalid_properties.push('invalid value for "completed", completed cannot be nil.')
  end

  if @priority.nil?
    invalid_properties.push('invalid value for "priority", priority cannot be nil.')
  end

  if @created_at.nil?
    invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
  end

  if @updated_at.nil?
    invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/spatio-sdk/models/task.rb', line 455

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/spatio-sdk/models/task.rb', line 317

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @title.nil?
  return false if @completed.nil?
  return false if @priority.nil?
  priority_validator = EnumAttributeValidator.new('String', ["none", "low", "medium", "high", "urgent"])
  return false unless priority_validator.valid?(@priority)
  return false if @created_at.nil?
  return false if @updated_at.nil?
  true
end