papierkram_api_client 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/CHANGELOG.md +24 -1
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +5 -5
  6. data/README.md +164 -56
  7. data/lib/papierkram_api/client.rb +92 -0
  8. data/lib/papierkram_api/v1/business_intelligence/base.rb +23 -0
  9. data/lib/papierkram_api/v1/business_intelligence/expenses_by_category.rb +98 -0
  10. data/lib/papierkram_api/v1/business_intelligence/smart_queries/expense_vouchers_for_month_in_year.rb +58 -0
  11. data/lib/papierkram_api/v1/endpoints/banking/bank_connections.rb +30 -0
  12. data/lib/papierkram_api/v1/endpoints/banking/transactions.rb +20 -0
  13. data/lib/papierkram_api/v1/endpoints/base.rb +77 -0
  14. data/lib/papierkram_api/v1/endpoints/contact/companies.rb +30 -0
  15. data/lib/papierkram_api/v1/endpoints/contact/companies_persons.rb +28 -0
  16. data/lib/papierkram_api/v1/endpoints/expense/vouchers.rb +45 -0
  17. data/lib/papierkram_api/v1/endpoints/income/estimates.rb +46 -0
  18. data/lib/papierkram_api/v1/endpoints/income/invoices.rb +46 -0
  19. data/lib/papierkram_api/v1/endpoints/income/propositions.rb +20 -0
  20. data/lib/papierkram_api/v1/endpoints/info.rb +14 -0
  21. data/lib/papierkram_api/v1/endpoints/projects.rb +26 -0
  22. data/lib/papierkram_api/v1/endpoints/tracker/tasks.rb +33 -0
  23. data/lib/papierkram_api/v1/endpoints/tracker/time_entries.rb +62 -0
  24. data/lib/papierkram_api/v1/helper/date_helper.rb +14 -0
  25. data/lib/{api → papierkram_api}/v1/helper/pdf_from_response.rb +1 -1
  26. data/lib/papierkram_api/v1/validators/expense_voucher.rb +105 -0
  27. data/lib/papierkram_api_client/version.rb +1 -1
  28. data/lib/papierkram_api_client.rb +21 -102
  29. metadata +22 -16
  30. data/lib/api/v1/banking/bank_connections.rb +0 -28
  31. data/lib/api/v1/banking/transactions.rb +0 -18
  32. data/lib/api/v1/base.rb +0 -75
  33. data/lib/api/v1/contact/companies.rb +0 -28
  34. data/lib/api/v1/contact/companies_persons.rb +0 -26
  35. data/lib/api/v1/expense/vouchers.rb +0 -44
  36. data/lib/api/v1/income/estimates.rb +0 -44
  37. data/lib/api/v1/income/invoices.rb +0 -44
  38. data/lib/api/v1/income/propositions.rb +0 -18
  39. data/lib/api/v1/info.rb +0 -12
  40. data/lib/api/v1/projects.rb +0 -24
  41. data/lib/api/v1/tracker/tasks.rb +0 -31
  42. data/lib/api/v1/tracker/time_entries.rb +0 -59
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Api
4
- module V1
5
- module Income
6
- # This class is responsible for all the API calls related to income estimates.
7
- class Estimates < Api::V1::Base
8
- def by(id:, pdf: false)
9
- if pdf == true
10
- return get("#{@url_api_path}/income/estimates/#{id}/pdf", nil,
11
- { headers: { 'Content-Type' => 'application/pdf' } })
12
- end
13
-
14
- get("#{@url_api_path}/income/estimates/#{id}")
15
- end
16
-
17
- def all(page: 1, # rubocop:disable Metrics/CyclomaticComplexity
18
- page_size: 100,
19
- order_by: nil,
20
- order_direction: nil,
21
- creditor_id: nil,
22
- project_id: nil,
23
- document_date_range_start: nil,
24
- document_date_range_end: nil)
25
- query = {
26
- page: page,
27
- page_size: page_size
28
- }
29
- query[:order_by] = order_by if order_by
30
- query[:order_direction] = order_direction if order_direction
31
- query[:creditor_id] = creditor_id if creditor_id
32
- query[:project_id] = project_id if project_id
33
- query[:document_date_range_start] = document_date_range_start if document_date_range_start
34
- if document_date_range_end && document_date_range_start
35
- query[:document_date_range_end] =
36
- document_date_range_end
37
- end
38
-
39
- get("#{@url_api_path}/income/estimates", query)
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Api
4
- module V1
5
- module Income
6
- # This class is responsible for all the API calls related to income invoices.
7
- class Invoices < Api::V1::Base
8
- def by(id:, pdf: false)
9
- if pdf == true
10
- return get("#{@url_api_path}/income/invoices/#{id}/pdf", nil,
11
- { headers: { 'Content-Type' => 'application/pdf' } })
12
- end
13
-
14
- get("#{@url_api_path}/income/invoices/#{id}")
15
- end
16
-
17
- def all(page: 1, # rubocop:disable Metrics/CyclomaticComplexity
18
- page_size: 100,
19
- order_by: nil,
20
- order_direction: nil,
21
- creditor_id: nil,
22
- project_id: nil,
23
- document_date_range_start: nil,
24
- document_date_range_end: nil)
25
- query = {
26
- page: page,
27
- page_size: page_size
28
- }
29
- query[:order_by] = order_by if order_by
30
- query[:order_direction] = order_direction if order_direction
31
- query[:creditor_id] = creditor_id if creditor_id
32
- query[:project_id] = project_id if project_id
33
- query[:document_date_range_start] = document_date_range_start if document_date_range_start
34
- if document_date_range_end && document_date_range_start
35
- query[:document_date_range_end] =
36
- document_date_range_end
37
- end
38
-
39
- get("#{@url_api_path}/income/invoices", query)
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Api
4
- module V1
5
- module Income
6
- # This class is responsible for all the API calls related to income propositions.
7
- class Propositions < Api::V1::Base
8
- def by(id:)
9
- get("#{@url_api_path}/income/propositions/#{id}")
10
- end
11
-
12
- def all
13
- get("#{@url_api_path}/income/propositions")
14
- end
15
- end
16
- end
17
- end
18
- end
data/lib/api/v1/info.rb DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Api
4
- module V1
5
- # This class is responsible for all the API calls related to info connections.
6
- class Info < Api::V1::Base
7
- def details
8
- get("#{@url_api_path}/info")
9
- end
10
- end
11
- end
12
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Api
4
- module V1
5
- # This class is responsible for all the API calls related to projects connections.
6
- class Projects < Api::V1::Base
7
- def by(id:)
8
- get("#{@url_api_path}/projects/#{id}")
9
- end
10
-
11
- def all(page: 1, per_page: 100, order_by: nil, order_direction: nil, company_id: nil)
12
- query = {
13
- page: page,
14
- per_page: per_page
15
- }
16
- query[:order_by] = order_by if order_by
17
- query[:order_direction] = order_direction if order_direction
18
- query[:company_id] = company_id if company_id
19
-
20
- get("#{@url_api_path}/projects", query)
21
- end
22
- end
23
- end
24
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Api
4
- module V1
5
- module Tracker
6
- # This class is responsible for all the API calls related to tracker tasks connections.
7
- class Tasks < Api::V1::Base
8
- def by(id:)
9
- get("#{@url_api_path}/tracker/tasks/#{id}")
10
- end
11
-
12
- def all(page: 1,
13
- page_size: 100,
14
- order_by: nil,
15
- order_direction: nil,
16
- project_id: nil,
17
- proposition_id: nil)
18
- query = {
19
- page: page,
20
- page_size: page_size
21
- }
22
- query[:order_by] = order_by if order_by
23
- query[:order_direction] = order_direction if order_direction
24
- query[:project_id] = project_id if project_id
25
- query[:proposition_id] = proposition_id if proposition_id
26
- get("#{@url_api_path}/tracker/tasks", query)
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Api
4
- module V1
5
- module Tracker
6
- # This class is responsible for all the API calls related to tracker time entries connections.
7
- class TimeEntries < Api::V1::Base
8
- def by(id:)
9
- get("#{@url_api_path}/tracker/time_entries/#{id}")
10
- end
11
-
12
- def all(page: 1, # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
13
- page_size: 100,
14
- order_by: nil,
15
- order_direction: nil,
16
- project_id: nil,
17
- task_id: nil,
18
- invoice_id: nil,
19
- user_id: nil,
20
- billing_state: nil,
21
- start_time_range_start: nil,
22
- start_time_range_end: nil)
23
- validate!(billing_state: billing_state,
24
- start_time_range_start: start_time_range_start,
25
- start_time_range_end: start_time_range_end)
26
-
27
- query = {
28
- page: page,
29
- page_size: page_size
30
- }
31
- query[:order_by] = order_by if order_by
32
- query[:order_direction] = order_direction if order_direction
33
- query[:project_id] = project_id if project_id
34
- query[:task_id] = task_id if task_id
35
- query[:invoice_id] = invoice_id if invoice_id
36
- query[:user_id] = user_id if user_id
37
- query[:billing_state] = billing_state if billing_state
38
- query[:start_time_range_start] = start_time_range_start if start_time_range_start
39
- query[:start_time_range_end] = start_time_range_end if start_time_range_end
40
- get("#{@url_api_path}/tracker/time_entries", query)
41
- end
42
-
43
- private
44
-
45
- def validate!(billing_state:, start_time_range_start:, start_time_range_end:)
46
- if billing_state && !%w[billed unbilled billable unbillable archived].include?(billing_state)
47
- raise ArgumentError, 'billing_state must be one of: "billed" "unbilled"" billable" "unbillable" "archived"'
48
- end
49
- if start_time_range_start && !start_time_range_start.is_a?(Time)
50
- raise ArgumentError, 'start_time_range_start must be a Time object'
51
- end
52
- return unless start_time_range_end && !start_time_range_end.is_a?(Time)
53
-
54
- raise ArgumentError, 'start_time_range_end must be a Time object'
55
- end
56
- end
57
- end
58
- end
59
- end