Class: PapierkramApi::V1::Endpoints::Projects

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

Overview

This class is responsible for all the API calls related to projects 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, per_page: 100, order_by: nil, order_direction: nil, company_id: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/papierkram_api/v1/endpoints/projects.rb', line 12

def all(page: 1, per_page: 100, order_by: nil, order_direction: nil, company_id: nil)
  query = {
    page: page,
    per_page: per_page
  }
  query[:order_by] = order_by if order_by
  query[:order_direction] = order_direction if order_direction
  query[:company_id] = company_id if company_id

  http_get("#{@url_api_path}/projects", query)
end

#archive_by(id:) ⇒ Object



97
98
99
# File 'lib/papierkram_api/v1/endpoints/projects.rb', line 97

def archive_by(id:)
  http_post("#{@url_api_path}/projects/#{id}/archive")
end

#create(name:, customer_id:, description: nil, start_date: nil, end_date: nil, flagged: nil, budget_type: nil, budget_money: nil, budget_time: nil, budget_time_unit: nil, color: nil, default_proposition: nil, team_members: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/papierkram_api/v1/endpoints/projects.rb', line 24

def create( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  name:,
  customer_id:,
  description: nil,
  start_date: nil,
  end_date: nil,
  flagged: nil,
  budget_type: nil,
  budget_money: nil,
  budget_time: nil,
  budget_time_unit: nil,
  color: nil,
  default_proposition: nil,
  team_members: nil
)

  body = {}
  body[:name] = name
  body[:customer] = { id: customer_id }
  body[:description] = description if description
  body[:start_date] = start_date if start_date
  body[:end_date] = end_date if end_date
  body[:flagged] = flagged if flagged
  body[:budget_type] = budget_type if budget_type
  body[:budget_money] = budget_money if budget_money
  body[:budget_time] = budget_time if budget_time
  body[:budget_time_unit] = budget_time_unit if budget_time_unit
  body[:color] = color if color
  body[:default_proposition] = default_proposition if default_proposition
  body[:team_members] = team_members if team_members

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

#delete_by(id:) ⇒ Object



93
94
95
# File 'lib/papierkram_api/v1/endpoints/projects.rb', line 93

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

#find_by(id:) ⇒ Object



8
9
10
# File 'lib/papierkram_api/v1/endpoints/projects.rb', line 8

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

#unarchive_by(id:) ⇒ Object



101
102
103
# File 'lib/papierkram_api/v1/endpoints/projects.rb', line 101

def unarchive_by(id:)
  http_post("#{@url_api_path}/projects/#{id}/unarchive")
end

#update_by(id:, name: nil, customer_id: nil, description: nil, start_date: nil, end_date: nil, flagged: nil, budget_type: nil, budget_money: nil, budget_time: nil, budget_time_unit: nil, color: nil, default_proposition: nil, team_members: nil) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists



58
59
60
61
62
63
64
65
66
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
# File 'lib/papierkram_api/v1/endpoints/projects.rb', line 58

def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists
  id:,
  name: nil,
  customer_id: nil,
  description: nil,
  start_date: nil,
  end_date: nil,
  flagged: nil,
  budget_type: nil,
  budget_money: nil,
  budget_time: nil,
  budget_time_unit: nil,
  color: nil,
  default_proposition: nil,
  team_members: nil
)

  body = {}
  body[:name] = name if name
  body[:customer] = { id: customer_id } if customer_id
  body[:description] = description if description
  body[:start_date] = start_date if start_date
  body[:end_date] = end_date if end_date
  body[:flagged] = flagged if flagged
  body[:budget_type] = budget_type if budget_type
  body[:budget_money] = budget_money if budget_money
  body[:budget_time] = budget_time if budget_time
  body[:budget_time_unit] = budget_time_unit if budget_time_unit
  body[:color] = color if color
  body[:default_proposition] = default_proposition if default_proposition
  body[:team_members] = team_members if team_members

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