fakturoid 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -10
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +11 -0
  5. data/README.md +501 -145
  6. data/Rakefile +3 -1
  7. data/fakturoid.gemspec +36 -25
  8. data/lib/fakturoid/api/account.rb +13 -0
  9. data/lib/fakturoid/api/bank_account.rb +13 -0
  10. data/lib/fakturoid/api/base.rb +18 -0
  11. data/lib/fakturoid/api/event.rb +23 -0
  12. data/lib/fakturoid/api/expense.rb +55 -0
  13. data/lib/fakturoid/api/expense_payment.rb +20 -0
  14. data/lib/fakturoid/api/generator.rb +36 -0
  15. data/lib/fakturoid/api/inbox_file.rb +34 -0
  16. data/lib/fakturoid/api/inventory_item.rb +66 -0
  17. data/lib/fakturoid/api/inventory_move.rb +40 -0
  18. data/lib/fakturoid/api/invoice.rb +62 -0
  19. data/lib/fakturoid/api/invoice_message.rb +14 -0
  20. data/lib/fakturoid/api/invoice_payment.rb +26 -0
  21. data/lib/fakturoid/api/number_format.rb +13 -0
  22. data/lib/fakturoid/api/recurring_generator.rb +36 -0
  23. data/lib/fakturoid/api/subject.rb +42 -0
  24. data/lib/fakturoid/api/todo.rb +20 -0
  25. data/lib/fakturoid/api/user.rb +17 -0
  26. data/lib/fakturoid/api.rb +84 -9
  27. data/lib/fakturoid/client.rb +46 -12
  28. data/lib/fakturoid/config.rb +69 -12
  29. data/lib/fakturoid/oauth/access_token_service.rb +46 -0
  30. data/lib/fakturoid/oauth/credentials.rb +63 -0
  31. data/lib/fakturoid/oauth/flow/authorization_code.rb +53 -0
  32. data/lib/fakturoid/oauth/flow/base.rb +42 -0
  33. data/lib/fakturoid/oauth/flow/client_credentials.rb +27 -0
  34. data/lib/fakturoid/oauth/flow.rb +5 -0
  35. data/lib/fakturoid/oauth/request/api.rb +11 -0
  36. data/lib/fakturoid/oauth/request/base.rb +60 -0
  37. data/lib/fakturoid/oauth/request/oauth.rb +24 -0
  38. data/lib/fakturoid/oauth/request.rb +5 -0
  39. data/lib/fakturoid/oauth/token_response.rb +56 -0
  40. data/lib/fakturoid/oauth.rb +39 -0
  41. data/lib/fakturoid/response.rb +8 -20
  42. data/lib/fakturoid/utils.rb +27 -0
  43. data/lib/fakturoid/version.rb +1 -1
  44. data/lib/fakturoid.rb +22 -22
  45. metadata +47 -53
  46. data/.github/workflows/rubocop.yml +0 -20
  47. data/.github/workflows/tests.yml +0 -27
  48. data/.gitignore +0 -7
  49. data/Gemfile +0 -6
  50. data/lib/fakturoid/api/arguments.rb +0 -21
  51. data/lib/fakturoid/api/http_methods.rb +0 -23
  52. data/lib/fakturoid/client/account.rb +0 -11
  53. data/lib/fakturoid/client/bank_account.rb +0 -11
  54. data/lib/fakturoid/client/event.rb +0 -19
  55. data/lib/fakturoid/client/expense.rb +0 -49
  56. data/lib/fakturoid/client/generator.rb +0 -44
  57. data/lib/fakturoid/client/inventory_items.rb +0 -59
  58. data/lib/fakturoid/client/inventory_moves.rb +0 -36
  59. data/lib/fakturoid/client/invoice.rb +0 -73
  60. data/lib/fakturoid/client/number_format.rb +0 -11
  61. data/lib/fakturoid/client/subject.rb +0 -41
  62. data/lib/fakturoid/client/todo.rb +0 -18
  63. data/lib/fakturoid/client/user.rb +0 -20
  64. data/lib/fakturoid/connection.rb +0 -30
  65. data/lib/fakturoid/request.rb +0 -31
  66. data/test/api_test.rb +0 -24
  67. data/test/config_test.rb +0 -40
  68. data/test/fixtures/blocked_account.json +0 -8
  69. data/test/fixtures/invoice.json +0 -81
  70. data/test/fixtures/invoice.pdf +0 -0
  71. data/test/fixtures/invoice_error.json +0 -7
  72. data/test/fixtures/subjects.json +0 -52
  73. data/test/request_test.rb +0 -20
  74. data/test/response_test.rb +0 -189
  75. data/test/test_helper.rb +0 -19
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
3
5
 
@@ -5,6 +7,6 @@ task default: :test
5
7
 
6
8
  Rake::TestTask.new(:test) do |t|
7
9
  t.libs << "test"
8
- t.test_files = FileList['test/*_test.rb']
10
+ t.test_files = FileList["test/**/*_test.rb"]
9
11
  t.verbose = true
10
12
  end
data/fakturoid.gemspec CHANGED
@@ -1,30 +1,41 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'fakturoid/version'
1
+ # frozen_string_literal: true
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = "fakturoid"
8
- s.version = Fakturoid::VERSION
9
- s.authors = ["Eda Riedl", "Lukáš Konarovský", "Oldřich Vetešník", "Kamil Hanus"]
10
- s.email = ["podpora@fakturoid.cz"]
11
- s.summary = %q{Ruby client for web based invoicing service www.fakturoid.cz}
12
- s.description = %q{Ruby client for web based invoicing service www.fakturoid.cz}
13
- s.homepage = "https://github.com/fakturoid/fakturoid-ruby"
14
- s.license = "MIT"
3
+ require_relative "lib/fakturoid/version"
15
4
 
16
- s.files = `git ls-files -z`.split("\x0")
17
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
- s.require_paths = ["lib"]
5
+ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
6
+ spec.name = "fakturoid"
7
+ spec.version = Fakturoid::VERSION
8
+ spec.authors = ["Eda Riedl", "Lukáš Konarovský", "Oldřich Vetešník", "Kamil Hanus"]
9
+ spec.email = ["podpora@fakturoid.cz"]
20
10
 
21
- s.add_dependency 'multi_json'
22
- s.add_dependency 'faraday'
11
+ spec.summary = "Ruby client for web based invoicing service www.fakturoid.cz"
12
+ spec.description = "Ruby client for web based invoicing service www.fakturoid.cz"
13
+ spec.homepage = "https://github.com/fakturoid/fakturoid-ruby"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7.0" # rubocop:disable Gemspec/RequiredRubyVersion
23
16
 
24
- s.add_development_dependency "bundler", "> 1"
25
- s.add_development_dependency "rake"
26
- s.add_development_dependency "minitest"
27
- s.add_development_dependency "shoulda-context"
28
- s.add_development_dependency "mocha"
29
- s.add_development_dependency "rubocop"
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/fakturoid/fakturoid-ruby"
19
+ spec.metadata["changelog_uri"] = "https://github.com/fakturoid/fakturoid-ruby/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
27
+ end
28
+ end
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "faraday"
32
+ spec.add_dependency "multi_json"
33
+
34
+ spec.add_development_dependency "bundler", "> 1"
35
+ spec.add_development_dependency "minitest"
36
+ spec.add_development_dependency "mocha"
37
+ # spec.add_development_dependency "pry"
38
+ spec.add_development_dependency "rake"
39
+ spec.add_development_dependency "rubocop"
40
+ spec.add_development_dependency "shoulda-context"
30
41
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class Account
6
+ include Base
7
+
8
+ def current
9
+ perform_request(HTTP_GET, "account.json")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class BankAccount
6
+ include Base
7
+
8
+ def all
9
+ perform_request(HTTP_GET, "bank_accounts.json")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ module Base
6
+ attr_reader :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def perform_request(method, path, params = {})
13
+ raw_response = client.perform_request(method, path, params)
14
+ Response.new(raw_response, self.class, method)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class Event
6
+ include Base
7
+
8
+ INDEX_PARAMS = [:page, :since, :subject_id].freeze
9
+
10
+ def all(params = {})
11
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
12
+
13
+ perform_request(HTTP_GET, "events.json", request_params: request_params)
14
+ end
15
+
16
+ def paid(params = {})
17
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
18
+
19
+ perform_request(HTTP_GET, "events/paid.json", request_params: request_params)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class Expense
6
+ include Base
7
+
8
+ def all(params = {})
9
+ request_params = Utils.permit_params(params, :since, :updated_since, :page, :subject_id, :custom_id, :number, :variable_symbol, :status) || {}
10
+
11
+ perform_request(HTTP_GET, "expenses.json", request_params: request_params)
12
+ end
13
+
14
+ def search(params = {})
15
+ Utils.validate_search_query(query: params[:query], tags: params[:tags], allow_tags: true)
16
+
17
+ request_params = Utils.permit_params(params, :query, :tags, :page)
18
+
19
+ perform_request(HTTP_GET, "expenses/search.json", request_params: request_params)
20
+ end
21
+
22
+ def find(id)
23
+ Utils.validate_numerical_id(id)
24
+ perform_request(HTTP_GET, "expenses/#{id}.json")
25
+ end
26
+
27
+ def download_attachment(expense_id, id)
28
+ Utils.validate_numerical_id(expense_id)
29
+ Utils.validate_numerical_id(id)
30
+ perform_request(HTTP_GET, "expenses/#{expense_id}/attachments/#{id}/download")
31
+ end
32
+
33
+ def fire(id, event)
34
+ request_params = { event: event }
35
+
36
+ Utils.validate_numerical_id(id)
37
+ perform_request(HTTP_POST, "expenses/#{id}/fire.json", request_params: request_params)
38
+ end
39
+
40
+ def create(payload = {})
41
+ perform_request(HTTP_POST, "expenses.json", payload: payload)
42
+ end
43
+
44
+ def update(id, payload = {})
45
+ Utils.validate_numerical_id(id)
46
+ perform_request(HTTP_PATCH, "expenses/#{id}.json", payload: payload)
47
+ end
48
+
49
+ def delete(id)
50
+ Utils.validate_numerical_id(id)
51
+ perform_request(HTTP_DELETE, "expenses/#{id}.json")
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class ExpensePayment
6
+ include Base
7
+
8
+ def create(expense_id, payload = {})
9
+ Utils.validate_numerical_id(expense_id)
10
+ perform_request(HTTP_POST, "expenses/#{expense_id}/payments.json", payload: payload)
11
+ end
12
+
13
+ def delete(expense_id, id)
14
+ Utils.validate_numerical_id(expense_id)
15
+ Utils.validate_numerical_id(id)
16
+ perform_request(HTTP_DELETE, "expenses/#{expense_id}/payments/#{id}.json")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class Generator
6
+ include Base
7
+
8
+ INDEX_PARAMS = [:since, :updated_since, :page, :subject_id].freeze
9
+
10
+ def all(params = {})
11
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
12
+
13
+ perform_request(HTTP_GET, "generators.json", request_params: request_params)
14
+ end
15
+
16
+ def find(id)
17
+ Utils.validate_numerical_id(id)
18
+ perform_request(HTTP_GET, "generators/#{id}.json")
19
+ end
20
+
21
+ def create(payload = {})
22
+ perform_request(HTTP_POST, "generators.json", payload: payload)
23
+ end
24
+
25
+ def update(id, payload = {})
26
+ Utils.validate_numerical_id(id)
27
+ perform_request(HTTP_PATCH, "generators/#{id}.json", payload: payload)
28
+ end
29
+
30
+ def delete(id)
31
+ Utils.validate_numerical_id(id)
32
+ perform_request(HTTP_DELETE, "generators/#{id}.json")
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class InboxFile
6
+ include Base
7
+
8
+ def all(params = {})
9
+ request_params = Utils.permit_params(params, :page)
10
+
11
+ perform_request(HTTP_GET, "inbox_files.json", request_params: request_params)
12
+ end
13
+
14
+ def create(payload = {})
15
+ perform_request(HTTP_POST, "inbox_files.json", payload: payload)
16
+ end
17
+
18
+ def send_to_ocr(id)
19
+ Utils.validate_numerical_id(id)
20
+ perform_request(HTTP_POST, "inbox_files/#{id}/send_to_ocr.json")
21
+ end
22
+
23
+ def download(id)
24
+ Utils.validate_numerical_id(id)
25
+ perform_request(HTTP_GET, "inbox_files/#{id}/download")
26
+ end
27
+
28
+ def delete(id)
29
+ Utils.validate_numerical_id(id)
30
+ perform_request(HTTP_DELETE, "inbox_files/#{id}.json")
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class InventoryItem
6
+ include Base
7
+
8
+ INDEX_PARAMS = [:since, :until, :updated_since, :updated_until, :page, :article_number, :sku].freeze
9
+
10
+ def all(params = {})
11
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
12
+
13
+ perform_request(HTTP_GET, "inventory_items.json", request_params: request_params)
14
+ end
15
+
16
+ def archived(params = {})
17
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
18
+
19
+ perform_request(HTTP_GET, "inventory_items/archived.json", request_params: request_params)
20
+ end
21
+
22
+ def low_quantity(params = {})
23
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
24
+
25
+ perform_request(HTTP_GET, "inventory_items/low_quantity.json", request_params: request_params)
26
+ end
27
+
28
+ def search(params = {})
29
+ Utils.validate_search_query(query: params[:query])
30
+
31
+ request_params = Utils.permit_params(params, :query, :page)
32
+
33
+ perform_request(HTTP_GET, "inventory_items/search.json", request_params: request_params)
34
+ end
35
+
36
+ def find(id)
37
+ Utils.validate_numerical_id(id)
38
+ perform_request(HTTP_GET, "inventory_items/#{id}.json")
39
+ end
40
+
41
+ def create(payload = {})
42
+ perform_request(HTTP_POST, "inventory_items.json", payload: payload)
43
+ end
44
+
45
+ def update(id, payload = {})
46
+ Utils.validate_numerical_id(id)
47
+ perform_request(HTTP_PATCH, "inventory_items/#{id}.json", payload: payload)
48
+ end
49
+
50
+ def delete(id)
51
+ Utils.validate_numerical_id(id)
52
+ perform_request(HTTP_DELETE, "inventory_items/#{id}.json")
53
+ end
54
+
55
+ def archive(id)
56
+ Utils.validate_numerical_id(id)
57
+ perform_request(HTTP_POST, "inventory_items/#{id}/archive.json")
58
+ end
59
+
60
+ def unarchive(id)
61
+ Utils.validate_numerical_id(id)
62
+ perform_request(HTTP_POST, "inventory_items/#{id}/unarchive.json")
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class InventoryMove
6
+ include Base
7
+
8
+ INDEX_PARAMS = [:since, :until, :updated_since, :updated_until, :page, :inventory_item_id].freeze
9
+
10
+ def all(params = {})
11
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
12
+
13
+ perform_request(HTTP_GET, "inventory_moves.json", request_params: request_params)
14
+ end
15
+
16
+ def find(inventory_item_id, id)
17
+ Utils.validate_numerical_id(inventory_item_id)
18
+ Utils.validate_numerical_id(id)
19
+ perform_request(HTTP_GET, "inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json")
20
+ end
21
+
22
+ def create(inventory_item_id, payload = {})
23
+ Utils.validate_numerical_id(inventory_item_id)
24
+ perform_request(HTTP_POST, "inventory_items/#{inventory_item_id}/inventory_moves.json", payload: payload)
25
+ end
26
+
27
+ def update(inventory_item_id, id, payload = {})
28
+ Utils.validate_numerical_id(inventory_item_id)
29
+ Utils.validate_numerical_id(id)
30
+ perform_request(HTTP_PATCH, "inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json", payload: payload)
31
+ end
32
+
33
+ def delete(inventory_item_id, id)
34
+ Utils.validate_numerical_id(inventory_item_id)
35
+ Utils.validate_numerical_id(id)
36
+ perform_request(HTTP_DELETE, "inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json")
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class Invoice
6
+ include Base
7
+
8
+ INDEX_PARAMS = [:since, :until, :updated_since, :updated_until, :page, :subject_id, :custom_id, :number, :status, :document_type].freeze
9
+
10
+ def all(params = {})
11
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
12
+
13
+ perform_request(HTTP_GET, "invoices.json", request_params: request_params)
14
+ end
15
+
16
+ def search(params = {})
17
+ Utils.validate_search_query(query: params[:query], tags: params[:tags], allow_tags: true)
18
+
19
+ request_params = Utils.permit_params(params, :query, :tags, :page)
20
+
21
+ perform_request(HTTP_GET, "invoices/search.json", request_params: request_params)
22
+ end
23
+
24
+ def find(id)
25
+ Utils.validate_numerical_id(id)
26
+ perform_request(HTTP_GET, "invoices/#{id}.json")
27
+ end
28
+
29
+ def download_pdf(id)
30
+ Utils.validate_numerical_id(id)
31
+ perform_request(HTTP_GET, "invoices/#{id}/download.pdf", headers: { content_type: "application/pdf" })
32
+ end
33
+
34
+ def download_attachment(invoice_id, id)
35
+ Utils.validate_numerical_id(invoice_id)
36
+ Utils.validate_numerical_id(id)
37
+ perform_request(HTTP_GET, "invoices/#{invoice_id}/attachments/#{id}/download")
38
+ end
39
+
40
+ def fire(id, event)
41
+ request_params = { event: event }
42
+
43
+ Utils.validate_numerical_id(id)
44
+ perform_request(HTTP_POST, "invoices/#{id}/fire.json", request_params: request_params)
45
+ end
46
+
47
+ def create(payload = {})
48
+ perform_request(HTTP_POST, "invoices.json", payload: payload)
49
+ end
50
+
51
+ def update(id, payload = {})
52
+ Utils.validate_numerical_id(id)
53
+ perform_request(HTTP_PATCH, "invoices/#{id}.json", payload: payload)
54
+ end
55
+
56
+ def delete(id)
57
+ Utils.validate_numerical_id(id)
58
+ perform_request(HTTP_DELETE, "invoices/#{id}.json")
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class InvoiceMessage
6
+ include Base
7
+
8
+ def create(invoice_id, payload = {})
9
+ Utils.validate_numerical_id(invoice_id)
10
+ perform_request(HTTP_POST, "invoices/#{invoice_id}/message.json", payload: payload)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class InvoicePayment
6
+ include Base
7
+
8
+ def create(invoice_id, payload = {})
9
+ Utils.validate_numerical_id(invoice_id)
10
+ perform_request(HTTP_POST, "invoices/#{invoice_id}/payments.json", payload: payload)
11
+ end
12
+
13
+ def create_tax_document(invoice_id, id)
14
+ Utils.validate_numerical_id(invoice_id)
15
+ Utils.validate_numerical_id(id)
16
+ perform_request(HTTP_POST, "invoices/#{invoice_id}/payments/#{id}/create_tax_document.json")
17
+ end
18
+
19
+ def delete(invoice_id, id)
20
+ Utils.validate_numerical_id(invoice_id)
21
+ Utils.validate_numerical_id(id)
22
+ perform_request(HTTP_DELETE, "invoices/#{invoice_id}/payments/#{id}.json")
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class NumberFormat
6
+ include Base
7
+
8
+ def invoices
9
+ perform_request(HTTP_GET, "number_formats/invoices.json")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class RecurringGenerator
6
+ include Base
7
+
8
+ INDEX_PARAMS = [:since, :updated_since, :page, :subject_id].freeze
9
+
10
+ def all(params = {})
11
+ request_params = Utils.permit_params(params, *INDEX_PARAMS) || {}
12
+
13
+ perform_request(HTTP_GET, "recurring_generators.json", request_params: request_params)
14
+ end
15
+
16
+ def find(id)
17
+ Utils.validate_numerical_id(id)
18
+ perform_request(HTTP_GET, "recurring_generators/#{id}.json")
19
+ end
20
+
21
+ def create(payload = {})
22
+ perform_request(HTTP_POST, "recurring_generators.json", payload: payload)
23
+ end
24
+
25
+ def update(id, payload = {})
26
+ Utils.validate_numerical_id(id)
27
+ perform_request(HTTP_PATCH, "recurring_generators/#{id}.json", payload: payload)
28
+ end
29
+
30
+ def delete(id)
31
+ Utils.validate_numerical_id(id)
32
+ perform_request(HTTP_DELETE, "recurring_generators/#{id}.json")
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class Subject
6
+ include Base
7
+
8
+ def all(params = {})
9
+ request_params = Utils.permit_params(params, :since, :updated_since, :page, :custom_id) || {}
10
+
11
+ perform_request(HTTP_GET, "subjects.json", request_params: request_params)
12
+ end
13
+
14
+ def search(params = {})
15
+ Utils.validate_search_query(query: params[:query])
16
+
17
+ request_params = Utils.permit_params(params, :query, :page)
18
+
19
+ perform_request(HTTP_GET, "subjects/search.json", request_params: request_params)
20
+ end
21
+
22
+ def find(id)
23
+ Utils.validate_numerical_id(id)
24
+ perform_request(HTTP_GET, "subjects/#{id}.json")
25
+ end
26
+
27
+ def create(payload = {})
28
+ perform_request(HTTP_POST, "subjects.json", payload: payload)
29
+ end
30
+
31
+ def update(id, payload = {})
32
+ Utils.validate_numerical_id(id)
33
+ perform_request(HTTP_PATCH, "subjects/#{id}.json", payload: payload)
34
+ end
35
+
36
+ def delete(id)
37
+ Utils.validate_numerical_id(id)
38
+ perform_request(HTTP_DELETE, "subjects/#{id}.json")
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class Todo
6
+ include Base
7
+
8
+ def all(params = {})
9
+ request_params = Utils.permit_params(params, :page, :since) || {}
10
+
11
+ perform_request(HTTP_GET, "todos.json", request_params: request_params)
12
+ end
13
+
14
+ def toggle_completion(id)
15
+ Utils.validate_numerical_id(id)
16
+ perform_request(HTTP_POST, "todos/#{id}/toggle_completion.json")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Api
5
+ class User
6
+ include Base
7
+
8
+ def current
9
+ perform_request(HTTP_GET, "user.json", url: client.config.api_endpoint_without_account)
10
+ end
11
+
12
+ def all
13
+ perform_request(HTTP_GET, "users.json")
14
+ end
15
+ end
16
+ end
17
+ end