papierkram_api_client 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -134,11 +134,62 @@ module PapierkramApi
134
134
  http_post("#{@url_api_path}/contact/companies", body)
135
135
  end
136
136
 
137
- def update_by(id:, attributes: {})
137
+ def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/ParameterLists
138
+ id:,
139
+ name: nil,
140
+ contact_type: nil,
141
+ phone: nil,
142
+ fax: nil,
143
+ email: nil,
144
+ website: nil,
145
+ twitter: nil,
146
+ ust_idnr: nil,
147
+ delivery_method: nil,
148
+ postal_street: nil,
149
+ postal_zip: nil,
150
+ postal_city: nil,
151
+ postal_country: nil,
152
+ physical_street: nil,
153
+ physical_zip: nil,
154
+ physical_city: nil,
155
+ physical_country: nil,
156
+ bank_account_no: nil,
157
+ bank_blz: nil,
158
+ bank_institute: nil,
159
+ bank_bic: nil,
160
+ bank_iban: nil,
161
+ notes: nil,
162
+ color: nil
163
+ )
138
164
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
139
- raise ArgumentError, 'attributes must be a Hash' unless attributes.is_a?(Hash)
140
165
 
141
- http_put("#{@url_api_path}/contact/companies/#{id}", attributes)
166
+ body = {}
167
+ body[:name] = name if name
168
+ body[:contact_type] = contact_type if contact_type
169
+ body[:phone] = phone if phone
170
+ body[:fax] = fax if fax
171
+ body[:email] = email if email
172
+ body[:website] = website if website
173
+ body[:twitter] = twitter if twitter
174
+ body[:ust_idnr] = ust_idnr if ust_idnr
175
+ body[:delivery_method] = delivery_method if delivery_method
176
+ body[:postal_street] = postal_street if postal_street
177
+ body[:postal_zip] = postal_zip if postal_zip
178
+ body[:postal_city] = postal_city if postal_city
179
+ body[:postal_country] = postal_country if postal_country
180
+ body[:physical_street] = physical_street if physical_street
181
+ body[:physical_zip] = physical_zip if physical_zip
182
+ body[:physical_city] = physical_city if physical_city
183
+ body[:physical_country] = physical_country if physical_country
184
+ body[:bank_account_no] = bank_account_no if bank_account_no
185
+ body[:bank_blz] = bank_blz if bank_blz
186
+ body[:bank_institute] = bank_institute if bank_institute
187
+ body[:bank_bic] = bank_bic if bank_bic
188
+ body[:bank_iban] = bank_iban if bank_iban
189
+ body[:notes] = notes if notes
190
+ body[:color] = color if color
191
+
192
+ http_put("#{@url_api_path}/contact/companies/#{id}", body)
142
193
  end
143
194
 
144
195
  def delete_by(id:)
@@ -54,12 +54,44 @@ module PapierkramApi
54
54
  http_post("#{@url_api_path}/contact/companies/#{company_id}/persons", body)
55
55
  end
56
56
 
57
- def update_by(company_id:, id:, attributes: {})
58
- raise ArgumentError, 'attributes must be a Hash' unless attributes.is_a?(Hash)
57
+ def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists, Metrics/MethodLength
58
+ id:,
59
+ company_id:,
60
+ title: nil,
61
+ salutation: nil,
62
+ first_name: nil,
63
+ last_name: nil,
64
+ position: nil,
65
+ department: nil,
66
+ phone: nil,
67
+ skype: nil,
68
+ fax: nil,
69
+ email: nil,
70
+ flagged: nil,
71
+ mobile: nil,
72
+ comment: nil,
73
+ default: nil
74
+ )
59
75
  raise ArgumentError, 'company_id must be an Integer' unless company_id.is_a?(Integer)
60
76
  raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
61
77
 
62
- http_put("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}", attributes)
78
+ body = {}
79
+ body[:title] = title if title
80
+ body[:salutation] = salutation if salutation
81
+ body[:first_name] = first_name if first_name
82
+ body[:last_name] = last_name if last_name
83
+ body[:position] = position if position
84
+ body[:department] = department if department
85
+ body[:phone] = phone if phone
86
+ body[:skype] = skype if skype
87
+ body[:fax] = fax if fax
88
+ body[:email] = email if email
89
+ body[:flagged] = flagged if flagged
90
+ body[:mobile] = mobile if mobile
91
+ body[:comment] = comment if comment
92
+ body[:default] = default if default
93
+
94
+ http_put("#{@url_api_path}/contact/companies/#{company_id}/persons/#{id}", body)
63
95
  end
64
96
 
65
97
  def delete_by(company_id:, id:)
@@ -6,6 +6,8 @@ module PapierkramApi
6
6
  module Expense
7
7
  # This class is responsible for all the API calls related to expense vouchers.
8
8
  class Vouchers < PapierkramApi::V1::Endpoints::Base
9
+ ALLOWED_DIFFERENCE_REASONS = %w[sonstige mahnung teilzahlung skonto sonstige schmaelerung].freeze
10
+
9
11
  def find_by(id:, pdf: false)
10
12
  if pdf == true
11
13
  return get("#{@url_api_path}/expense/vouchers/#{id}/pdf", nil,
@@ -38,6 +40,154 @@ module PapierkramApi
38
40
 
39
41
  http_get("#{@url_api_path}/expense/vouchers", query)
40
42
  end
43
+
44
+ def create( # rubocop:disable Metrics/ParameterLists,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
45
+ name:,
46
+ provenance:,
47
+ line_items:,
48
+ due_date: nil,
49
+ document_date: nil,
50
+ description: nil,
51
+ entertainment_reason: nil,
52
+ entertainment_persons: nil,
53
+ flagged: nil,
54
+ creditor_id: nil
55
+ )
56
+ body = {}
57
+ body[:name] = name
58
+ body[:line_items] = line_items
59
+ body[:provenance] = provenance
60
+
61
+ body[:due_date] = due_date if due_date
62
+ body[:document_date] = document_date if document_date
63
+ body[:description] = description if description
64
+ body[:entertainment_reason] = entertainment_reason if entertainment_reason
65
+ body[:entertainment_persons] = entertainment_persons if entertainment_persons
66
+ body[:flagged] = flagged if flagged
67
+ body[:creditor] = { id: creditor_id } if creditor_id
68
+
69
+ if entertainment_persons
70
+ raise ArgumentError, 'entertainment_persons must be an array' unless entertainment_persons.is_a?(Array)
71
+
72
+ unless entertainment_persons.all?(String)
73
+ raise ArgumentError,
74
+ 'entertainment_persons must be an array of strings'
75
+ end
76
+ end
77
+
78
+ if line_items
79
+ raise ArgumentError, 'line_items must be an array' unless line_items.is_a?(Array)
80
+ raise ArgumentError, 'line_items must be an array of hashes' unless line_items.all?(Hash)
81
+ end
82
+
83
+ http_post("#{@url_api_path}/expense/vouchers", body)
84
+ end
85
+
86
+ def update_by( # rubocop:disable Metrics/ParameterLists,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
87
+ id:,
88
+ name: nil,
89
+ due_date: nil,
90
+ document_date: nil,
91
+ description: nil,
92
+ entertainment_reason: nil,
93
+ entertainment_persons: nil,
94
+ flagged: nil,
95
+ provenance: nil,
96
+ creditor_id: nil,
97
+ line_items: nil
98
+ )
99
+ body = {}
100
+ body[:name] = name if name
101
+ body[:due_date] = due_date if due_date
102
+ body[:document_date] = document_date if document_date
103
+ body[:description] = description if description
104
+ body[:entertainment_reason] = entertainment_reason if entertainment_reason
105
+ body[:entertainment_persons] = entertainment_persons if entertainment_persons
106
+ body[:flagged] = flagged if flagged
107
+ body[:provenance] = provenance if provenance
108
+ body[:creditor] = { id: creditor_id } if creditor_id
109
+ body[:line_items] = line_items if line_items
110
+
111
+ if line_items
112
+ raise ArgumentError, 'line_items must be an array' unless line_items.is_a?(Array)
113
+ raise ArgumentError, 'line_items must be an array of hashes' unless line_items.all?(Hash)
114
+ end
115
+
116
+ http_put("#{@url_api_path}/expense/vouchers/#{id}", body)
117
+ end
118
+
119
+ def add_document_by(id:, path_to_file:, file_type:)
120
+ doc = Faraday::Multipart::FilePart.new(path_to_file, file_type)
121
+
122
+ http_post("#{@url_api_path}/expense/vouchers/#{id}/documents", { file: doc })
123
+ end
124
+
125
+ def delete_document_by(id:, document_id:)
126
+ http_delete("#{@url_api_path}/expense/vouchers/#{id}/documents/#{document_id}")
127
+ end
128
+
129
+ def delete_by(id:)
130
+ http_delete("#{@url_api_path}/expense/vouchers/#{id}")
131
+ end
132
+
133
+ def archive_by(id:)
134
+ http_post("#{@url_api_path}/expense/vouchers/#{id}/archive")
135
+ end
136
+
137
+ def unarchive_by(id:)
138
+ http_post("#{@url_api_path}/expense/vouchers/#{id}/unarchive")
139
+ end
140
+
141
+ def cancel_by(id:)
142
+ http_post("#{@url_api_path}/expense/vouchers/#{id}/cancel")
143
+ end
144
+
145
+ def cancel_with_reverse_entry_by(id:)
146
+ http_post("#{@url_api_path}/expense/vouchers/#{id}/cancel_with_reverse_entry")
147
+ end
148
+
149
+ def mark_as_paid_by(
150
+ id:,
151
+ value: nil,
152
+ payment_date: nil,
153
+ banking_transaction_id: nil,
154
+ difference_reason: nil
155
+ )
156
+ unless value || banking_transaction_id
157
+ raise ArgumentError, 'either value or banking_transaction_id must be given'
158
+ end
159
+
160
+ body = {}
161
+
162
+ if value
163
+ validate_value!(value)
164
+ body[:value] = value
165
+ end
166
+
167
+ if difference_reason
168
+ validate_difference_reason!(difference_reason)
169
+ body[:difference_reason] = difference_reason
170
+ end
171
+
172
+ body[:payment_date] = payment_date if payment_date
173
+ body[:banking_transaction] = { id: banking_transaction_id } if banking_transaction_id
174
+
175
+ http_post("#{@url_api_path}/expense/vouchers/#{id}/pay", body)
176
+ end
177
+
178
+ private
179
+
180
+ def validate_value!(value)
181
+ raise ArgumentError, 'value must be a float' unless value.is_a?(Numeric)
182
+ end
183
+
184
+ def validate_difference_reason!(difference_reason)
185
+ raise ArgumentError, 'difference_reason must be a string' unless difference_reason.is_a?(String)
186
+
187
+ return if ALLOWED_DIFFERENCE_REASONS.include?(difference_reason)
188
+
189
+ raise ArgumentError, "difference_reason must be one of: #{ALLOWED_DIFFERENCE_REASONS.join(', ')}"
190
+ end
41
191
  end
42
192
  end
43
193
  end
@@ -6,6 +6,8 @@ module PapierkramApi
6
6
  module Income
7
7
  # This class is responsible for all the API calls related to income invoices.
8
8
  class Invoices < PapierkramApi::V1::Endpoints::Base
9
+ ALLOWED_SEND_VIA = %i[email pdf].freeze
10
+
9
11
  def find_by(id:, pdf: false)
10
12
  if pdf == true
11
13
  return http_get(
@@ -18,14 +20,16 @@ module PapierkramApi
18
20
  http_get("#{@url_api_path}/income/invoices/#{id}")
19
21
  end
20
22
 
21
- def all(page: 1, # rubocop:disable Metrics/CyclomaticComplexity
22
- page_size: 100,
23
- order_by: nil,
24
- order_direction: nil,
25
- creditor_id: nil,
26
- project_id: nil,
27
- document_date_range_start: nil,
28
- document_date_range_end: nil)
23
+ def all( # rubocop:disable Metrics/CyclomaticComplexity
24
+ page: 1,
25
+ page_size: 100,
26
+ order_by: nil,
27
+ order_direction: nil,
28
+ creditor_id: nil,
29
+ project_id: nil,
30
+ document_date_range_start: nil,
31
+ document_date_range_end: nil
32
+ )
29
33
  query = {
30
34
  page: page,
31
35
  page_size: page_size
@@ -42,6 +46,148 @@ module PapierkramApi
42
46
 
43
47
  http_get("#{@url_api_path}/income/invoices", query)
44
48
  end
49
+
50
+ def create( # rubocop:disable Metrics/ParameterLists,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
51
+ name:,
52
+ line_items:,
53
+ payment_term_id:,
54
+ description: nil,
55
+ flagged: nil,
56
+ document_date: nil,
57
+ supply_date: nil,
58
+ customer_id: nil,
59
+ contact_person_id: nil,
60
+ project_id: nil,
61
+ custom_template_id: nil,
62
+ billing_company: nil,
63
+ billing_department: nil,
64
+ billing_contact_person: nil,
65
+ billing_street: nil,
66
+ billing_zip: nil,
67
+ billing_city: nil,
68
+ billing_country: nil,
69
+ billing_ust_idnr: nil,
70
+ billing_email: nil
71
+ )
72
+ body = {}
73
+ body[:name] = name
74
+ body[:line_items] = line_items
75
+ body[:payment_term] = { id: payment_term_id }
76
+ body[:description] = description if description
77
+ body[:flagged] = flagged if flagged
78
+ body[:document_date] = document_date if document_date
79
+ body[:supply_date] = supply_date if supply_date
80
+ body[:customer] = { id: customer_id } if customer_id
81
+ body[:customer][:contact_person] = { id: contact_person_id } if contact_person_id
82
+ body[:customer][:project] = { id: project_id } if project_id
83
+ body[:custom_template] = { id: custom_template_id } if custom_template_id
84
+
85
+ body[:billing] = {}
86
+ body[:billing][:company] = billing_company if billing_company
87
+ body[:billing][:department] = billing_department if billing_department
88
+ body[:billing][:contact_person] = billing_contact_person if billing_contact_person
89
+ body[:billing][:street] = billing_street if billing_street
90
+ body[:billing][:zip] = billing_zip if billing_zip
91
+ body[:billing][:city] = billing_city if billing_city
92
+ body[:billing][:country] = billing_country if billing_country
93
+ body[:billing][:ust_idnr] = billing_ust_idnr if billing_ust_idnr
94
+ body[:billing][:email] = billing_email if billing_email
95
+
96
+ http_post("#{@url_api_path}/income/invoices", body)
97
+ end
98
+
99
+ def update_by( # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity,Metrics/ParameterLists
100
+ id:,
101
+ name: nil,
102
+ line_items: nil,
103
+ payment_term_id: nil,
104
+ description: nil,
105
+ flagged: nil,
106
+ document_date: nil,
107
+ supply_date: nil,
108
+ customer_id: nil,
109
+ contact_person_id: nil,
110
+ project_id: nil,
111
+ custom_template_id: nil,
112
+ billing_company: nil,
113
+ billing_department: nil,
114
+ billing_contact_person: nil,
115
+ billing_street: nil,
116
+ billing_zip: nil,
117
+ billing_city: nil,
118
+ billing_country: nil,
119
+ billing_ust_idnr: nil,
120
+ billing_email: nil
121
+ )
122
+ body = {}
123
+ body[:name] = name if name
124
+ body[:line_items] = line_items if line_items
125
+ body[:payment_term] = { id: payment_term_id } if payment_term_id
126
+ body[:description] = description if description
127
+ body[:flagged] = flagged if flagged
128
+ body[:document_date] = document_date if document_date
129
+ body[:supply_date] = supply_date if supply_date
130
+ body[:customer] = { id: customer_id } if customer_id
131
+ body[:customer][:contact_person] = { id: contact_person_id } if contact_person_id
132
+ body[:customer][:project] = { id: project_id } if project_id
133
+ body[:custom_template] = { id: custom_template_id } if custom_template_id
134
+
135
+ body[:billing] = {}
136
+ body[:billing][:company] = billing_company if billing_company
137
+ body[:billing][:department] = billing_department if billing_department
138
+ body[:billing][:contact_person] = billing_contact_person if billing_contact_person
139
+ body[:billing][:street] = billing_street if billing_street
140
+ body[:billing][:zip] = billing_zip if billing_zip
141
+ body[:billing][:city] = billing_city if billing_city
142
+ body[:billing][:country] = billing_country if billing_country
143
+ body[:billing][:ust_idnr] = billing_ust_idnr if billing_ust_idnr
144
+ body[:billing][:email] = billing_email if billing_email
145
+
146
+ http_put("#{@url_api_path}/income/invoices/#{id}", body)
147
+ end
148
+
149
+ def deliver_by( # rubocop:disable Metrics/AbcSize
150
+ id:,
151
+ email_recipient: nil,
152
+ email_subject: nil,
153
+ email_body: nil,
154
+ send_via: :pdf
155
+ )
156
+
157
+ raise ArgumentError, 'send_via must be :email or :pdf' unless ALLOWED_SEND_VIA.include?(send_via)
158
+
159
+ body = {}
160
+ body[:send_via] = send_via
161
+
162
+ if send_via == :email
163
+ if email_recipient.nil? || email_subject.nil? || email_body.nil?
164
+ raise ArgumentError, 'email_recipient, email_subject and email_body must be set'
165
+ end
166
+
167
+ body[:email] = {}
168
+ body[:email][:recipient] = email_recipient
169
+ body[:email][:subject] = email_subject
170
+ body[:email][:body] = email_body
171
+ end
172
+
173
+ http_post("#{@url_api_path}/income/invoices/#{id}/deliver", body)
174
+ end
175
+
176
+ def delete_by(id:)
177
+ http_delete("#{@url_api_path}/income/invoices/#{id}")
178
+ end
179
+
180
+ def archive_by(id:)
181
+ http_post("#{@url_api_path}/income/invoices/#{id}/archive")
182
+ end
183
+
184
+ def unarchive_by(id:)
185
+ http_post("#{@url_api_path}/income/invoices/#{id}/unarchive")
186
+ end
187
+
188
+ def cancel_by(id:)
189
+ http_post("#{@url_api_path}/income/invoices/#{id}/cancel")
190
+ end
45
191
  end
46
192
  end
47
193
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PapierkramApi
4
+ module V1
5
+ module Endpoints
6
+ module Income
7
+ # This class is responsible for all the API calls related to income propositions.
8
+ class PaymentTerms < PapierkramApi::V1::Endpoints::Base
9
+ def find_by(id:)
10
+ http_get("#{@url_api_path}/income/payment_terms/#{id}")
11
+ end
12
+
13
+ def all(page: 1,
14
+ page_size: 100,
15
+ order_by: nil,
16
+ order_direction: nil)
17
+ query = {
18
+ page: page,
19
+ page_size: page_size
20
+ }
21
+ query[:order_by] = order_by if order_by
22
+ query[:order_direction] = order_direction if order_direction
23
+
24
+ http_get("#{@url_api_path}/income/payment_terms", query)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -27,21 +27,37 @@ module PapierkramApi
27
27
  body = {}
28
28
  body[:name] = name
29
29
  body[:article_no] = article_no
30
+
31
+ body[:proposition_type] = proposition_type if proposition_type
30
32
  body[:description] = description if description
31
33
  body[:time_unit] = time_unit if time_unit
32
- body[:proposition_type] = proposition_type if proposition_type
33
- body[:price] = price if price
34
34
  body[:vat_rate] = vat_rate if vat_rate
35
+ body[:price] = price if price
35
36
 
36
37
  http_post("#{@url_api_path}/income/propositions", body)
37
38
  end
38
39
 
39
- def update_by(id:, attributes: {})
40
- if attributes[:vat_rate] && (attributes[:vat_rate].empty? || !attributes[:vat_rate].include?('%'))
41
- raise ArgumentError, 'vat_rate must be a percentage and include a % sign'
42
- end
40
+ def update_by( # rubocop:disable Metrics/CyclomaticComplexity
41
+ id:,
42
+ name: nil,
43
+ description: nil,
44
+ article_no: nil,
45
+ price: nil,
46
+ proposition_type: nil,
47
+ time_unit: nil,
48
+ vat_rate: nil
49
+ )
50
+
51
+ body = {}
52
+ body[:name] = name if name
53
+ body[:description] = description if description
54
+ body[:article_no] = article_no if article_no
55
+ body[:price] = price if price
56
+ body[:proposition_type] = proposition_type if proposition_type
57
+ body[:time_unit] = time_unit if time_unit
58
+ body[:vat_rate] = vat_rate if vat_rate
43
59
 
44
- http_put("#{@url_api_path}/income/propositions/#{id}", attributes)
60
+ http_put("#{@url_api_path}/income/propositions/#{id}", body)
45
61
  end
46
62
 
47
63
  def delete_by(id:)
@@ -55,10 +55,39 @@ module PapierkramApi
55
55
  http_post("#{@url_api_path}/projects", body)
56
56
  end
57
57
 
58
- def update_by(id:, attributes: {})
59
- raise ArgumentError, 'attributes must be a Hash' unless attributes.is_a?(Hash)
58
+ def update_by( # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists
59
+ id:,
60
+ name: nil,
61
+ customer_id: nil,
62
+ description: nil,
63
+ start_date: nil,
64
+ end_date: nil,
65
+ flagged: nil,
66
+ budget_type: nil,
67
+ budget_money: nil,
68
+ budget_time: nil,
69
+ budget_time_unit: nil,
70
+ color: nil,
71
+ default_proposition: nil,
72
+ team_members: nil
73
+ )
74
+
75
+ body = {}
76
+ body[:name] = name if name
77
+ body[:customer] = { id: customer_id } if customer_id
78
+ body[:description] = description if description
79
+ body[:start_date] = start_date if start_date
80
+ body[:end_date] = end_date if end_date
81
+ body[:flagged] = flagged if flagged
82
+ body[:budget_type] = budget_type if budget_type
83
+ body[:budget_money] = budget_money if budget_money
84
+ body[:budget_time] = budget_time if budget_time
85
+ body[:budget_time_unit] = budget_time_unit if budget_time_unit
86
+ body[:color] = color if color
87
+ body[:default_proposition] = default_proposition if default_proposition
88
+ body[:team_members] = team_members if team_members
60
89
 
61
- http_put("#{@url_api_path}/projects/#{id}", attributes)
90
+ http_put("#{@url_api_path}/projects/#{id}", body)
62
91
  end
63
92
 
64
93
  def delete_by(id:)
@@ -26,6 +26,69 @@ module PapierkramApi
26
26
  query[:proposition_id] = proposition_id if proposition_id
27
27
  http_get("#{@url_api_path}/tracker/tasks", query)
28
28
  end
29
+
30
+ def create(
31
+ name:,
32
+ project_id:,
33
+ proposition_id: nil,
34
+ deadline: nil,
35
+ relative_costs: nil,
36
+ complete: nil,
37
+ flagged: nil,
38
+ user_id: nil
39
+ )
40
+ body = {}
41
+ body[:name] = name
42
+ body[:project] = { id: project_id }
43
+ body[:proposition] = { id: proposition_id } if proposition_id
44
+ body[:deadline] = deadline if deadline
45
+ body[:relative_costs] = relative_costs if relative_costs
46
+ body[:complete] = complete if complete
47
+ body[:flagged] = flagged if flagged
48
+ body[:user] = { id: user_id } if user_id
49
+
50
+ http_post("#{@url_api_path}/tracker/tasks", body)
51
+ end
52
+
53
+ def update_by( # rubocop:disable Metrics/ParameterLists
54
+ id:,
55
+ name:,
56
+ project_id:,
57
+ proposition_id: nil,
58
+ deadline: nil,
59
+ relative_costs: nil,
60
+ complete: nil,
61
+ flagged: nil,
62
+ user_id: nil
63
+ )
64
+ body = {}
65
+ body[:name] = name
66
+ body[:project] = { id: project_id }
67
+ body[:proposition] = { id: proposition_id } if proposition_id
68
+ body[:deadline] = deadline if deadline
69
+ body[:relative_costs] = relative_costs if relative_costs
70
+ body[:complete] = complete if complete
71
+ body[:flagged] = flagged if flagged
72
+ body[:user] = { id: user_id } if user_id
73
+
74
+ http_put("#{@url_api_path}/tracker/tasks/#{id}", body)
75
+ end
76
+
77
+ def delete_by(id:)
78
+ http_delete("#{@url_api_path}/tracker/tasks/#{id}")
79
+ end
80
+
81
+ def archive_by(id:)
82
+ raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
83
+
84
+ http_post("#{@url_api_path}/tracker/tasks/#{id}/archive")
85
+ end
86
+
87
+ def unarchive_by(id:)
88
+ raise ArgumentError, 'id must be an Integer' unless id.is_a?(Integer)
89
+
90
+ http_post("#{@url_api_path}/tracker/tasks/#{id}/unarchive")
91
+ end
29
92
  end
30
93
  end
31
94
  end