Class: PapierkramApi::V1::Endpoints::Tracker::Tasks

Inherits:
Base
  • Object
show all
Defined in:
lib/papierkram_api/v1/endpoints/tracker/tasks.rb

Overview

This class is responsible for all the API calls related to tracker tasks connections.

Instance Attribute Summary

Attributes inherited from Base

#client, #url_api_path

Instance Method Summary collapse

Methods inherited from Base

#http_delete, #http_get, #http_patch, #http_post, #http_put, #initialize, #remaining_quota

Constructor Details

This class inherits a constructor from PapierkramApi::V1::Endpoints::Base

Instance Method Details

#all(page: 1, page_size: 100, order_by: nil, order_direction: nil, project_id: nil, proposition_id: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/papierkram_api/v1/endpoints/tracker/tasks.rb', line 13

def all(page: 1,
        page_size: 100,
        order_by: nil,
        order_direction: nil,
        project_id: nil,
        proposition_id: nil)
  query = {
    page: page,
    page_size: page_size
  }
  query[:order_by] = order_by if order_by
  query[:order_direction] = order_direction if order_direction
  query[:project_id] = project_id if project_id
  query[:proposition_id] = proposition_id if proposition_id
  http_get("#{@url_api_path}/tracker/tasks", query)
end

#archive_by(id:) ⇒ Object

Raises:

  • (ArgumentError)


81
82
83
84
85
# File 'lib/papierkram_api/v1/endpoints/tracker/tasks.rb', line 81

def archive_by(id:)
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)

  http_post("#{@url_api_path}/tracker/tasks/#{id}/archive")
end

#create(name:, project_id:, proposition_id: nil, deadline: nil, relative_costs: nil, complete: nil, flagged: nil, user_id: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/papierkram_api/v1/endpoints/tracker/tasks.rb', line 30

def create(
  name:,
  project_id:,
  proposition_id: nil,
  deadline: nil,
  relative_costs: nil,
  complete: nil,
  flagged: nil,
  user_id: nil
)
  body = {}
  body[:name] = name
  body[:project] = { id: project_id }
  body[:proposition] = { id: proposition_id } if proposition_id
  body[:deadline] = deadline if deadline
  body[:relative_costs] = relative_costs if relative_costs
  body[:complete] = complete if complete
  body[:flagged] = flagged if flagged
  body[:user] = { id: user_id } if user_id

  http_post("#{@url_api_path}/tracker/tasks", body)
end

#delete_by(id:) ⇒ Object



77
78
79
# File 'lib/papierkram_api/v1/endpoints/tracker/tasks.rb', line 77

def delete_by(id:)
  http_delete("#{@url_api_path}/tracker/tasks/#{id}")
end

#find_by(id:) ⇒ Object



9
10
11
# File 'lib/papierkram_api/v1/endpoints/tracker/tasks.rb', line 9

def find_by(id:)
  http_get("#{@url_api_path}/tracker/tasks/#{id}")
end

#unarchive_by(id:) ⇒ Object

Raises:

  • (ArgumentError)


87
88
89
90
91
# File 'lib/papierkram_api/v1/endpoints/tracker/tasks.rb', line 87

def unarchive_by(id:)
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)

  http_post("#{@url_api_path}/tracker/tasks/#{id}/unarchive")
end

#update_by(id:, name:, project_id:, proposition_id: nil, deadline: nil, relative_costs: nil, complete: nil, flagged: nil, user_id: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/papierkram_api/v1/endpoints/tracker/tasks.rb', line 53

def update_by( # rubocop:disable Metrics/ParameterLists
  id:,
  name:,
  project_id:,
  proposition_id: nil,
  deadline: nil,
  relative_costs: nil,
  complete: nil,
  flagged: nil,
  user_id: nil
)
  body = {}
  body[:name] = name
  body[:project] = { id: project_id }
  body[:proposition] = { id: proposition_id } if proposition_id
  body[:deadline] = deadline if deadline
  body[:relative_costs] = relative_costs if relative_costs
  body[:complete] = complete if complete
  body[:flagged] = flagged if flagged
  body[:user] = { id: user_id } if user_id

  http_put("#{@url_api_path}/tracker/tasks/#{id}", body)
end