fakturoid 0.4.0 → 1.0.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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -11
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +15 -0
  5. data/README.md +597 -107
  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 -10
  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 +48 -51
  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/invoice.rb +0 -73
  58. data/lib/fakturoid/client/number_format.rb +0 -11
  59. data/lib/fakturoid/client/subject.rb +0 -41
  60. data/lib/fakturoid/client/todo.rb +0 -18
  61. data/lib/fakturoid/client/user.rb +0 -20
  62. data/lib/fakturoid/connection.rb +0 -30
  63. data/lib/fakturoid/request.rb +0 -31
  64. data/test/api_test.rb +0 -24
  65. data/test/config_test.rb +0 -40
  66. data/test/fixtures/blocked_account.json +0 -8
  67. data/test/fixtures/invoice.json +0 -81
  68. data/test/fixtures/invoice.pdf +0 -0
  69. data/test/fixtures/invoice_error.json +0 -7
  70. data/test/fixtures/subjects.json +0 -52
  71. data/test/request_test.rb +0 -20
  72. data/test/response_test.rb +0 -189
  73. data/test/test_helper.rb +0 -19
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "oauth/credentials"
4
+ require_relative "oauth/flow"
5
+ require_relative "oauth/request"
6
+ require_relative "oauth/token_response"
7
+ require_relative "oauth/access_token_service"
8
+
9
+ module Fakturoid
10
+ class Oauth
11
+ extend Forwardable
12
+
13
+ attr_reader :client, :flow, :access_token_service
14
+
15
+ def_delegators :@flow, :authorization_uri, :authorize, :fetch_access_token, :revoke_access, :authorized?
16
+
17
+ def initialize(client)
18
+ @client = client
19
+ @flow = find_flow
20
+ @access_token_service = AccessTokenService.new(self)
21
+ end
22
+
23
+ def perform_request(method, path, params)
24
+ access_token_service.perform_request(method, path, params)
25
+ end
26
+
27
+ private
28
+
29
+ def find_flow
30
+ if client.config.client_credentials_flow?
31
+ Flow::ClientCredentials.new(client)
32
+ elsif client.config.authorization_code_flow?
33
+ Flow::AuthorizationCode.new(client)
34
+ else
35
+ raise ConfigurationError, "Unsupported OAuth flow."
36
+ end
37
+ end
38
+ end
39
+ end
@@ -2,30 +2,32 @@
2
2
 
3
3
  module Fakturoid
4
4
  class Response
5
- attr_reader :response, :caller, :env, :body, :request_method
5
+ attr_reader :response, :caller, :body, :request_method
6
6
 
7
7
  def initialize(faraday_response, caller, request_method)
8
8
  @response = faraday_response
9
9
  @caller = caller
10
- @env = faraday_response.env
11
10
  @request_method = request_method.to_sym
12
11
 
12
+ env = response.env
13
+
13
14
  if !(env.body.nil? || env.body.empty? || (json? && env.body =~ /\A\s+\z/))
14
15
  @body = json? ? MultiJson.load(env.body) : env.body
15
16
  end
17
+
16
18
  handle_response
17
19
  end
18
20
 
19
21
  def status_code
20
- env["status"]
22
+ response.env["status"]
21
23
  end
22
24
 
23
25
  def json?
24
- env.request_headers["Content-Type"] == "application/json"
26
+ headers["content-type"] =~ %r{\Aapplication/json}
25
27
  end
26
28
 
27
29
  def headers
28
- env.response_headers
30
+ response.env.response_headers.transform_keys(&:downcase)
29
31
  end
30
32
 
31
33
  def inspect
@@ -36,21 +38,7 @@ module Fakturoid
36
38
 
37
39
  def handle_response
38
40
  case status_code
39
- when 400
40
- raise error(UserAgentError, "User-Agent header missing") if env.request_headers["User-Agent"].nil? || env.request_headers["User-Agent"].empty?
41
- raise error(PaginationError, "Page does not exist")
42
- when 401 then raise error(AuthenticationError, "Authentification failed")
43
- when 402 then raise error(BlockedAccountError, "Account is blocked")
44
- when 403
45
- raise error(DestroySubjectError, "Cannot destroy subject with invoices") if caller == Client::Subject && request_method == :delete
46
- raise error(SubjectLimitError, "Subject limit for account reached") if caller == Client::Subject && request_method == :post
47
- raise error(GeneratorLimitError, "Recurring generator limit for account reached") if caller == Client::Generator
48
- raise error(UnsupportedFeatureError, "Feature unavailable for account plan")
49
- when 404 then raise error(RecordNotFoundError, "Record not found")
50
- when 415 then raise error(ContentTypeError, "Unsupported Content-Type")
51
- when 422 then raise error(InvalidRecordError, "Invalid record")
52
- when 429 then raise error(RateLimitError, "Rate limit reached")
53
- when 503 then raise error(ReadOnlySiteError, "Fakturoid is in read only state")
41
+ when 401 then raise error(AuthenticationError, "Authentication failed")
54
42
  else
55
43
  raise error(ServerError, "Server error") if status_code >= 500
56
44
  raise error(ClientError, "Client error") if status_code >= 400
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fakturoid
4
+ module Utils
5
+ def self.permit_params(params_hash, *permitted_params)
6
+ params_hash.select { |param, _value| permitted_params.include?(param.to_sym) }
7
+ end
8
+
9
+ def self.validate_numerical_id(id)
10
+ raise ArgumentError, "Wrong ID given: #{id}" if !id.is_a?(Integer) && !(id.is_a?(String) && id =~ /\A\d+\z/)
11
+ true
12
+ end
13
+
14
+ def self.validate_search_query(query: nil, tags: nil, allow_tags: false)
15
+ if allow_tags && empty?(tags) && empty?(query)
16
+ raise ArgumentError, "Query or tags parameter is required"
17
+ elsif !allow_tags && empty?(query)
18
+ raise ArgumentError, "Query parameter is required"
19
+ end
20
+ true
21
+ end
22
+
23
+ def self.empty?(string)
24
+ string.nil? || string.empty?
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fakturoid
4
- VERSION = "0.4.0"
4
+ VERSION = "1.0.0"
5
5
  end
data/lib/fakturoid.rb CHANGED
@@ -1,17 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "uri"
4
+ require "forwardable"
5
+ require "time"
4
6
  require "multi_json"
5
7
  require "faraday"
6
8
 
7
- require "fakturoid/config"
8
- require "fakturoid/connection"
9
- require "fakturoid/request"
10
- require "fakturoid/response"
11
- require "fakturoid/api"
12
- require "fakturoid/client"
13
- require "fakturoid/version"
14
- require "fakturoid/railtie" if defined?(::Rails)
9
+ require_relative "fakturoid/utils"
10
+ require_relative "fakturoid/config"
11
+ require_relative "fakturoid/response"
12
+ require_relative "fakturoid/api"
13
+ require_relative "fakturoid/oauth"
14
+ require_relative "fakturoid/client"
15
+ require_relative "fakturoid/version"
16
+ require_relative "fakturoid/railtie" if defined?(::Rails)
15
17
 
16
18
  module Fakturoid
17
19
  class ApiError < StandardError
@@ -24,25 +26,23 @@ module Fakturoid
24
26
  end
25
27
  end
26
28
 
27
- class ContentTypeError < ApiError; end
28
- class UserAgentError < ApiError; end
29
+ class ConfigurationError < ApiError; end
30
+ class OauthError < ApiError; end
29
31
  class AuthenticationError < ApiError; end
30
- class BlockedAccountError < ApiError; end
31
- class RateLimitError < ApiError; end
32
- class ReadOnlySiteError < ApiError; end
33
- class PaginationError < ApiError; end
34
-
35
- class RecordNotFoundError < ApiError; end
36
- class InvalidRecordError < ApiError; end
37
- class DestroySubjectError < ApiError; end
38
- class SubjectLimitError < ApiError; end
39
- class GeneratorLimitError < ApiError; end
40
- class UnsupportedFeatureError < ApiError; end
41
32
 
42
33
  class ClientError < ApiError; end
43
34
  class ServerError < ApiError; end
44
35
 
36
+ HTTP_GET = :get
37
+ HTTP_POST = :post
38
+ HTTP_PATCH = :patch
39
+ HTTP_DELETE = :delete
40
+
45
41
  def self.configure(&block)
46
- Fakturoid::Api.configure(&block)
42
+ Client.configure(&block)
43
+ end
44
+
45
+ def self.client
46
+ @client ||= Client.new
47
47
  end
48
48
  end
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakturoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eda Riedl
8
8
  - Lukáš Konarovský
9
9
  - Oldřich Vetešník
10
+ - Kamil Hanus
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2022-03-17 00:00:00.000000000 Z
14
+ date: 2024-03-22 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
- name: multi_json
17
+ name: faraday
17
18
  requirement: !ruby/object:Gem::Requirement
18
19
  requirements:
19
20
  - - ">="
@@ -27,7 +28,7 @@ dependencies:
27
28
  - !ruby/object:Gem::Version
28
29
  version: '0'
29
30
  - !ruby/object:Gem::Dependency
30
- name: faraday
31
+ name: multi_json
31
32
  requirement: !ruby/object:Gem::Requirement
32
33
  requirements:
33
34
  - - ">="
@@ -55,7 +56,7 @@ dependencies:
55
56
  - !ruby/object:Gem::Version
56
57
  version: '1'
57
58
  - !ruby/object:Gem::Dependency
58
- name: rake
59
+ name: minitest
59
60
  requirement: !ruby/object:Gem::Requirement
60
61
  requirements:
61
62
  - - ">="
@@ -69,7 +70,7 @@ dependencies:
69
70
  - !ruby/object:Gem::Version
70
71
  version: '0'
71
72
  - !ruby/object:Gem::Dependency
72
- name: minitest
73
+ name: mocha
73
74
  requirement: !ruby/object:Gem::Requirement
74
75
  requirements:
75
76
  - - ">="
@@ -83,7 +84,7 @@ dependencies:
83
84
  - !ruby/object:Gem::Version
84
85
  version: '0'
85
86
  - !ruby/object:Gem::Dependency
86
- name: shoulda-context
87
+ name: rake
87
88
  requirement: !ruby/object:Gem::Requirement
88
89
  requirements:
89
90
  - - ">="
@@ -97,7 +98,7 @@ dependencies:
97
98
  - !ruby/object:Gem::Version
98
99
  version: '0'
99
100
  - !ruby/object:Gem::Dependency
100
- name: mocha
101
+ name: rubocop
101
102
  requirement: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
@@ -111,7 +112,7 @@ dependencies:
111
112
  - !ruby/object:Gem::Version
112
113
  version: '0'
113
114
  - !ruby/object:Gem::Dependency
114
- name: rubocop
115
+ name: shoulda-context
115
116
  requirement: !ruby/object:Gem::Requirement
116
117
  requirements:
117
118
  - - ">="
@@ -131,52 +132,58 @@ executables: []
131
132
  extensions: []
132
133
  extra_rdoc_files: []
133
134
  files:
134
- - ".github/workflows/rubocop.yml"
135
- - ".github/workflows/tests.yml"
136
- - ".gitignore"
137
135
  - ".rubocop.yml"
138
136
  - ".ruby-version"
139
137
  - CHANGELOG.md
140
- - Gemfile
141
138
  - LICENSE.txt
142
139
  - README.md
143
140
  - Rakefile
144
141
  - fakturoid.gemspec
145
142
  - lib/fakturoid.rb
146
143
  - lib/fakturoid/api.rb
147
- - lib/fakturoid/api/arguments.rb
148
- - lib/fakturoid/api/http_methods.rb
144
+ - lib/fakturoid/api/account.rb
145
+ - lib/fakturoid/api/bank_account.rb
146
+ - lib/fakturoid/api/base.rb
147
+ - lib/fakturoid/api/event.rb
148
+ - lib/fakturoid/api/expense.rb
149
+ - lib/fakturoid/api/expense_payment.rb
150
+ - lib/fakturoid/api/generator.rb
151
+ - lib/fakturoid/api/inbox_file.rb
152
+ - lib/fakturoid/api/inventory_item.rb
153
+ - lib/fakturoid/api/inventory_move.rb
154
+ - lib/fakturoid/api/invoice.rb
155
+ - lib/fakturoid/api/invoice_message.rb
156
+ - lib/fakturoid/api/invoice_payment.rb
157
+ - lib/fakturoid/api/number_format.rb
158
+ - lib/fakturoid/api/recurring_generator.rb
159
+ - lib/fakturoid/api/subject.rb
160
+ - lib/fakturoid/api/todo.rb
161
+ - lib/fakturoid/api/user.rb
149
162
  - lib/fakturoid/client.rb
150
- - lib/fakturoid/client/account.rb
151
- - lib/fakturoid/client/bank_account.rb
152
- - lib/fakturoid/client/event.rb
153
- - lib/fakturoid/client/expense.rb
154
- - lib/fakturoid/client/generator.rb
155
- - lib/fakturoid/client/invoice.rb
156
- - lib/fakturoid/client/number_format.rb
157
- - lib/fakturoid/client/subject.rb
158
- - lib/fakturoid/client/todo.rb
159
- - lib/fakturoid/client/user.rb
160
163
  - lib/fakturoid/config.rb
161
- - lib/fakturoid/connection.rb
164
+ - lib/fakturoid/oauth.rb
165
+ - lib/fakturoid/oauth/access_token_service.rb
166
+ - lib/fakturoid/oauth/credentials.rb
167
+ - lib/fakturoid/oauth/flow.rb
168
+ - lib/fakturoid/oauth/flow/authorization_code.rb
169
+ - lib/fakturoid/oauth/flow/base.rb
170
+ - lib/fakturoid/oauth/flow/client_credentials.rb
171
+ - lib/fakturoid/oauth/request.rb
172
+ - lib/fakturoid/oauth/request/api.rb
173
+ - lib/fakturoid/oauth/request/base.rb
174
+ - lib/fakturoid/oauth/request/oauth.rb
175
+ - lib/fakturoid/oauth/token_response.rb
162
176
  - lib/fakturoid/railtie.rb
163
- - lib/fakturoid/request.rb
164
177
  - lib/fakturoid/response.rb
178
+ - lib/fakturoid/utils.rb
165
179
  - lib/fakturoid/version.rb
166
- - test/api_test.rb
167
- - test/config_test.rb
168
- - test/fixtures/blocked_account.json
169
- - test/fixtures/invoice.json
170
- - test/fixtures/invoice.pdf
171
- - test/fixtures/invoice_error.json
172
- - test/fixtures/subjects.json
173
- - test/request_test.rb
174
- - test/response_test.rb
175
- - test/test_helper.rb
176
180
  homepage: https://github.com/fakturoid/fakturoid-ruby
177
181
  licenses:
178
182
  - MIT
179
- metadata: {}
183
+ metadata:
184
+ homepage_uri: https://github.com/fakturoid/fakturoid-ruby
185
+ source_code_uri: https://github.com/fakturoid/fakturoid-ruby
186
+ changelog_uri: https://github.com/fakturoid/fakturoid-ruby/blob/main/CHANGELOG.md
180
187
  post_install_message:
181
188
  rdoc_options: []
182
189
  require_paths:
@@ -185,25 +192,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
192
  requirements:
186
193
  - - ">="
187
194
  - !ruby/object:Gem::Version
188
- version: '0'
195
+ version: 2.7.0
189
196
  required_rubygems_version: !ruby/object:Gem::Requirement
190
197
  requirements:
191
198
  - - ">="
192
199
  - !ruby/object:Gem::Version
193
200
  version: '0'
194
201
  requirements: []
195
- rubygems_version: 3.2.32
202
+ rubygems_version: 3.5.5
196
203
  signing_key:
197
204
  specification_version: 4
198
205
  summary: Ruby client for web based invoicing service www.fakturoid.cz
199
- test_files:
200
- - test/api_test.rb
201
- - test/config_test.rb
202
- - test/fixtures/blocked_account.json
203
- - test/fixtures/invoice.json
204
- - test/fixtures/invoice.pdf
205
- - test/fixtures/invoice_error.json
206
- - test/fixtures/subjects.json
207
- - test/request_test.rb
208
- - test/response_test.rb
209
- - test/test_helper.rb
206
+ test_files: []
@@ -1,20 +0,0 @@
1
- # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-ruby
2
- # https://github.com/actions/starter-workflows/blob/main/ci/ruby.yml
3
-
4
- name: Rubocop
5
- on: [push, pull_request]
6
-
7
- jobs:
8
- test:
9
- runs-on: ubuntu-latest
10
- steps:
11
- - uses: actions/checkout@v2
12
-
13
- - name: Set up Ruby
14
- uses: ruby/setup-ruby@v1
15
- with:
16
- ruby-version: 2.7
17
- bundler-cache: true
18
-
19
- - name: Rubocop
20
- run: bundle exec rubocop
@@ -1,27 +0,0 @@
1
- # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-ruby
2
- # https://github.com/actions/starter-workflows/blob/main/ci/ruby.yml
3
-
4
- name: Tests
5
- on: [push, pull_request]
6
-
7
- jobs:
8
- test:
9
-
10
- runs-on: ubuntu-latest
11
- strategy:
12
- matrix:
13
- ruby-version: ['2.6', '2.7', '3.0']
14
-
15
- steps:
16
- - uses: actions/checkout@v2
17
-
18
- - name: Set up Ruby
19
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
20
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
21
- uses: ruby/setup-ruby@v1
22
- with:
23
- ruby-version: ${{ matrix.ruby-version }}
24
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
-
26
- - name: Run tests
27
- run: bundle exec rake
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- .bundle/
2
- Gemfile.lock
3
- coverage/
4
- doc/
5
- pkg/
6
- .DS_Store
7
- rubocop.html
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in fakturoid.gemspec
6
- gemspec
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- class Api
5
- module Arguments
6
- def permit_params(params_hash, *permitted_params)
7
- params_hash.select { |param, _value| permitted_params.include?(param.to_sym) }
8
- end
9
-
10
- def validate_numerical_id(id)
11
- raise ArgumentError, "Wrong ID given: #{id}" if !id.is_a?(Integer) && !(id.is_a?(String) && id =~ /\A\d+\z/)
12
- true
13
- end
14
-
15
- def validate_search_query(query)
16
- raise ArgumentError, "Query parameter is required" if query.nil? || query.empty?
17
- true
18
- end
19
- end
20
- end
21
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- class Api
5
- module HttpMethods
6
- def get_request(path, params = {})
7
- Request.new(:get, path, self).call(params)
8
- end
9
-
10
- def post_request(path, params = {})
11
- Request.new(:post, path, self).call(params)
12
- end
13
-
14
- def patch_request(path, params = {})
15
- Request.new(:patch, path, self).call(params)
16
- end
17
-
18
- def delete_request(path, params = {})
19
- Request.new(:delete, path, self).call(params)
20
- end
21
- end
22
- end
23
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class Account < Fakturoid::Api
6
- def self.current
7
- get_request("account.json")
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class BankAccount < Fakturoid::Api
6
- def self.all
7
- get_request("bank_accounts.json")
8
- end
9
- end
10
- end
11
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class Event < Fakturoid::Api
6
- def self.all(params = {})
7
- request_params = permit_params(params, :page, :since, :subject_id) || {}
8
-
9
- get_request("events.json", request_params: request_params)
10
- end
11
-
12
- def self.paid(params = {})
13
- request_params = permit_params(params, :page, :since, :subject_id) || {}
14
-
15
- get_request("events/paid.json", request_params: request_params)
16
- end
17
- end
18
- end
19
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class Expense < Fakturoid::Api
6
- def self.all(params = {})
7
- request_params = permit_params(params, :page, :since, :updated_since, :number, :variable_symbol, :status, :subject_id, :custom_id) || {}
8
-
9
- get_request("expenses.json", request_params: request_params)
10
- end
11
-
12
- def self.find(id)
13
- validate_numerical_id(id)
14
- get_request("expenses/#{id}.json")
15
- end
16
-
17
- def self.search(query, params = {})
18
- validate_search_query(query)
19
-
20
- request_params = permit_params(params, :page)
21
- request_params[:query] = query
22
-
23
- get_request("expenses/search.json", request_params: request_params)
24
- end
25
-
26
- def self.fire(id, event, params = {})
27
- request_params = permit_params(params, :paid_on, :paid_amount, :variable_symbol, :bank_account_id) || {}
28
- request_params[:event] = event
29
-
30
- validate_numerical_id(id)
31
- post_request("expenses/#{id}/fire.json", request_params: request_params)
32
- end
33
-
34
- def self.create(payload = {})
35
- post_request("expenses.json", payload: payload)
36
- end
37
-
38
- def self.update(id, payload = {})
39
- validate_numerical_id(id)
40
- patch_request("expenses/#{id}.json", payload: payload)
41
- end
42
-
43
- def self.delete(id)
44
- validate_numerical_id(id)
45
- delete_request("expenses/#{id}.json")
46
- end
47
- end
48
- end
49
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fakturoid
4
- module Client
5
- class Generator < Fakturoid::Api
6
- def self.all(params = {})
7
- request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
8
-
9
- get_request("generators.json", request_params: request_params)
10
- end
11
-
12
- def self.recurring(params = {})
13
- request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
14
-
15
- get_request("generators/recurring.json", request_params: request_params)
16
- end
17
-
18
- def self.template(params = {})
19
- request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
20
-
21
- get_request("generators/template.json", request_params: request_params)
22
- end
23
-
24
- def self.find(id)
25
- validate_numerical_id(id)
26
- get_request("generators/#{id}.json")
27
- end
28
-
29
- def self.create(payload = {})
30
- post_request("generators.json", payload: payload)
31
- end
32
-
33
- def self.update(id, payload = {})
34
- validate_numerical_id(id)
35
- patch_request("generators/#{id}.json", payload: payload)
36
- end
37
-
38
- def self.delete(id)
39
- validate_numerical_id(id)
40
- delete_request("generators/#{id}.json")
41
- end
42
- end
43
- end
44
- end