Class: PapierkramApi::V1::Endpoints::Income::Propositions

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

Overview

This class is responsible for all the API calls related to income propositions.

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

#allObject



13
14
15
# File 'lib/papierkram_api/v1/endpoints/income/propositions.rb', line 13

def all
  http_get("#{@url_api_path}/income/propositions")
end

#archive_by(id:) ⇒ Object



67
68
69
# File 'lib/papierkram_api/v1/endpoints/income/propositions.rb', line 67

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

#create(name:, article_no:, description: nil, time_unit: nil, proposition_type: nil, price: nil, vat_rate: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/papierkram_api/v1/endpoints/income/propositions.rb', line 17

def create(
  name:,
  article_no:,
  description: nil,
  time_unit: nil,
  proposition_type: nil,
  price: nil,
  vat_rate: nil
)

  body = {}
  body[:name] = name
  body[:article_no] = article_no

  body[:proposition_type] = proposition_type if proposition_type
  body[:description] = description if description
  body[:time_unit] = time_unit if time_unit
  body[:vat_rate] = vat_rate if vat_rate
  body[:price] = price if price

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

#delete_by(id:) ⇒ Object



63
64
65
# File 'lib/papierkram_api/v1/endpoints/income/propositions.rb', line 63

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

#find_by(id:) ⇒ Object



9
10
11
# File 'lib/papierkram_api/v1/endpoints/income/propositions.rb', line 9

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

#unarchive_by(id:) ⇒ Object



71
72
73
# File 'lib/papierkram_api/v1/endpoints/income/propositions.rb', line 71

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

#update_by(id:, name: nil, description: nil, article_no: nil, price: nil, proposition_type: nil, time_unit: nil, vat_rate: nil) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/papierkram_api/v1/endpoints/income/propositions.rb', line 40

def update_by( # rubocop:disable Metrics/CyclomaticComplexity
  id:,
  name: nil,
  description: nil,
  article_no: nil,
  price: nil,
  proposition_type: nil,
  time_unit: nil,
  vat_rate: nil
)

  body = {}
  body[:name] = name if name
  body[:description] = description if description
  body[:article_no] = article_no if article_no
  body[:price] = price if price
  body[:proposition_type] = proposition_type if proposition_type
  body[:time_unit] = time_unit if time_unit
  body[:vat_rate] = vat_rate if vat_rate

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