fakturoid 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop.yml +20 -0
- data/.github/workflows/tests.yml +27 -0
- data/.rubocop.yml +54 -12
- data/.ruby-version +1 -1
- data/CHANGELOG.md +33 -0
- data/Gemfile +3 -1
- data/README.md +39 -31
- data/lib/fakturoid/api/arguments.rb +3 -1
- data/lib/fakturoid/api/http_methods.rb +2 -0
- data/lib/fakturoid/api.rb +4 -2
- data/lib/fakturoid/client/account.rb +3 -1
- data/lib/fakturoid/client/bank_account.rb +3 -1
- data/lib/fakturoid/client/event.rb +4 -2
- data/lib/fakturoid/client/expense.rb +11 -5
- data/lib/fakturoid/client/generator.rb +6 -4
- data/lib/fakturoid/client/invoice.rb +18 -10
- data/lib/fakturoid/client/number_format.rb +11 -0
- data/lib/fakturoid/client/subject.rb +10 -4
- data/lib/fakturoid/client/todo.rb +3 -1
- data/lib/fakturoid/client/user.rb +4 -2
- data/lib/fakturoid/client.rb +12 -9
- data/lib/fakturoid/config.rb +14 -2
- data/lib/fakturoid/connection.rb +11 -3
- data/lib/fakturoid/railtie.rb +2 -0
- data/lib/fakturoid/request.rb +5 -2
- data/lib/fakturoid/response.rb +21 -19
- data/lib/fakturoid/version.rb +3 -1
- data/lib/fakturoid.rb +14 -12
- data/test/api_test.rb +12 -10
- data/test/config_test.rb +23 -21
- data/test/request_test.rb +8 -6
- data/test/response_test.rb +68 -66
- data/test/test_helper.rb +8 -6
- metadata +9 -7
- data/.circleci/config.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ef863bf7aae45cfbf91d5c50c8f8b28d6b50aba851fcb2a0478f04364127d60
|
4
|
+
data.tar.gz: bf9e9c5cad8973615dc48e9c76c7e3c6061ad9bef6558725740348c751a201c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec705fea7250afb8fef4cd70ed1b20c472a9510d21122d9cfffaf83b3cd1e32158d55612d34492ce5cef662e07d1738dc0c577c666cb0818a108c1d2c7ef70c
|
7
|
+
data.tar.gz: 9242d93bba87c3c15f479d6c042b26cfae52831ec327105b1f1ecebd6fecadfcb4aeaea98f99c242555b944ddb1797e54ad6cc6ffcf504d7d52c76761dbd076b
|
@@ -0,0 +1,20 @@
|
|
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
|
@@ -0,0 +1,27 @@
|
|
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/.rubocop.yml
CHANGED
@@ -1,35 +1,77 @@
|
|
1
|
-
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
SuggestExtensions: false
|
4
|
+
NewCops: disable
|
5
|
+
Exclude:
|
6
|
+
- 'Rakefile'
|
7
|
+
- 'fakturoid.gemspec'
|
8
|
+
- 'vendor/**/*'
|
9
|
+
|
10
|
+
Style/Documentation:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Layout/LineLength:
|
2
14
|
Enabled: false
|
3
15
|
|
4
16
|
Metrics/ClassLength:
|
5
17
|
Exclude:
|
6
18
|
- 'test/**/*'
|
7
19
|
|
8
|
-
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Exclude:
|
22
|
+
- 'test/**/*'
|
23
|
+
|
24
|
+
Layout/AccessModifierIndentation:
|
9
25
|
EnforcedStyle: outdent
|
10
26
|
|
11
|
-
|
27
|
+
Layout/CaseIndentation:
|
12
28
|
IndentOneStep: true
|
13
29
|
|
14
30
|
Style/SignalException:
|
15
31
|
EnforcedStyle: only_raise
|
16
32
|
|
17
|
-
|
33
|
+
Layout/TrailingWhitespace:
|
18
34
|
Enabled: false
|
19
35
|
|
20
36
|
Style/ClassAndModuleChildren:
|
21
37
|
Exclude:
|
22
38
|
- 'test/**/*'
|
23
39
|
|
24
|
-
|
25
|
-
|
26
|
-
- '<'
|
27
|
-
- '='
|
40
|
+
Metrics/PerceivedComplexity:
|
41
|
+
Enabled: false
|
28
42
|
|
29
|
-
|
43
|
+
Metrics/MethodLength:
|
30
44
|
Enabled: false
|
31
45
|
|
32
|
-
|
46
|
+
Metrics/AbcSize:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Metrics/CyclomaticComplexity:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Style/NegatedIf:
|
33
53
|
Exclude:
|
34
|
-
- '
|
35
|
-
|
54
|
+
- 'lib/fakturoid/response.rb'
|
55
|
+
|
56
|
+
Naming/MemoizedInstanceVariableName:
|
57
|
+
Exclude:
|
58
|
+
- 'lib/fakturoid/api.rb'
|
59
|
+
|
60
|
+
Layout/EmptyLineAfterGuardClause:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Layout/EmptyLineBetweenDefs:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
Style/RescueStandardError:
|
67
|
+
Exclude:
|
68
|
+
- 'test/response_test.rb'
|
69
|
+
|
70
|
+
Style/TrivialAccessors:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/StringLiterals:
|
74
|
+
EnforcedStyle: double_quotes
|
75
|
+
|
76
|
+
Style/SymbolArray:
|
77
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
## 0.4.0
|
2
|
+
|
3
|
+
- Fix Faraday v1.x deprecations.
|
4
|
+
- Add support for Faraday v2.x.
|
5
|
+
- Add support form number formats endpoint
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
number_formats = Fakturoid::Client::NumberFormat.invoices
|
9
|
+
```
|
10
|
+
|
11
|
+
- Add support for `until`, `updated_until` and `custom_id`
|
12
|
+
params to invoice index action methods
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
invoices = Fakturoid::Client::Invoice.all(since: "2022-03-01T00:00:00+01:00", until: "2022-03-31T23:59:59+01:00")
|
16
|
+
invoices = Fakturoid::Client::Invoice.regular(updated_since: "2022-03-01T00:00:00+01:00", updated_until: "2022-03-31T23:59:59+01:00")
|
17
|
+
proformas = Fakturoid::Client::Invoice.proforma(custom_id: "custom-123")
|
18
|
+
```
|
19
|
+
|
20
|
+
- Add support for `custom_id` param to expense index action method
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
Fakturoid::Client::Expense.all(custom_id: "custom-123")
|
24
|
+
```
|
25
|
+
|
26
|
+
- Add support for pagination to search endpoints
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Fakturoid::Client::Invoice.search("apples", page: 3)
|
30
|
+
Fakturoid::Client::Expense.search("computers", page: 2)
|
31
|
+
Fakturoid::Client::Subject.search("apple", page: 2)
|
32
|
+
```
|
33
|
+
|
1
34
|
## 0.3.0
|
2
35
|
|
3
36
|
- Add support for `variable_symbol` and `bank_account_id` param in invoice `fire` method.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
# Fakturoid
|
2
2
|
|
3
3
|
The Fakturoid gem is ruby library for API communication with web based invoicing service [www.fakturoid.cz](https://fakturoid.cz).
|
4
|
-
Fakturoid [API documentation](
|
4
|
+
Fakturoid [API documentation](https://fakturoid.docs.apiary.io/).
|
5
5
|
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/fakturoid.svg)](http://badge.fury.io/rb/fakturoid)
|
7
|
-
[![
|
7
|
+
[![Tests](https://github.com/fakturoid/fakturoid-ruby/actions/workflows/tests.yml/badge.svg)](https://github.com/fakturoid/fakturoid-ruby/actions/workflows/tests.yml)
|
8
|
+
[![Rubocop](https://github.com/fakturoid/fakturoid-ruby/actions/workflows/rubocop.yml/badge.svg)](https://github.com/fakturoid/fakturoid-ruby/actions/workflows/rubocop.yml)
|
8
9
|
|
9
10
|
## Installation
|
10
11
|
|
11
12
|
Add this line to your application's Gemfile:
|
12
13
|
|
13
14
|
```ruby
|
14
|
-
gem
|
15
|
+
gem "fakturoid"
|
15
16
|
```
|
16
17
|
|
17
18
|
And then run:
|
@@ -24,10 +25,10 @@ Fakturoid gem is configured within config block placed in `config/initializers/f
|
|
24
25
|
|
25
26
|
```ruby
|
26
27
|
Fakturoid.configure do |config|
|
27
|
-
config.email =
|
28
|
-
config.api_key =
|
29
|
-
config.account =
|
30
|
-
config.user_agent =
|
28
|
+
config.email = "yourfakturoid@email.com"
|
29
|
+
config.api_key = "fasdff823fdasWRFKW843ladfjklasdf834"
|
30
|
+
config.account = "applecorp" # former subdomain (first part of URL)
|
31
|
+
config.user_agent = "Name of your app (your@email.com)"
|
31
32
|
end
|
32
33
|
```
|
33
34
|
|
@@ -35,7 +36,7 @@ end
|
|
35
36
|
|
36
37
|
### Account resource
|
37
38
|
|
38
|
-
To get
|
39
|
+
To get information about your account in Fakturoid run following code:
|
39
40
|
|
40
41
|
```ruby
|
41
42
|
response = Fakturoid::Client::Account.current
|
@@ -46,11 +47,11 @@ response.body # contains hash with returned body
|
|
46
47
|
Accessing content of returned body:
|
47
48
|
|
48
49
|
```ruby
|
49
|
-
response.body[
|
50
|
+
response.body["name"] # return name of your company
|
50
51
|
response.name # alternative way of getting the name of your company
|
51
52
|
```
|
52
53
|
|
53
|
-
For the list of all returned account fields see the [Account API documentation](
|
54
|
+
For the list of all returned account fields see the [Account API documentation](https://fakturoid.docs.apiary.io/#reference/account)
|
54
55
|
|
55
56
|
### User resource
|
56
57
|
|
@@ -72,7 +73,17 @@ If you want to get information about one user which belongs to account use:
|
|
72
73
|
response = Fakturoid::Client::User.find(user_id)
|
73
74
|
```
|
74
75
|
|
75
|
-
For the list of all returned user fields see the [Users API documentation](
|
76
|
+
For the list of all returned user fields see the [Users API documentation](https://fakturoid.docs.apiary.io/#reference/users)
|
77
|
+
|
78
|
+
### Number Format resource
|
79
|
+
|
80
|
+
For the list of invoice number formats which belong to the current account:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
response = Fakturoid::Client::NumberFormat.invoices
|
84
|
+
```
|
85
|
+
|
86
|
+
For the list of all returned user fields see the [Number formats API documentation](https://fakturoid.docs.apiary.io/#reference/number-formats)
|
76
87
|
|
77
88
|
### Subject resource
|
78
89
|
|
@@ -85,7 +96,7 @@ response = Fakturoid::Client::Subject.all(page: 2)
|
|
85
96
|
Fulltext search subjects:
|
86
97
|
|
87
98
|
```ruby
|
88
|
-
response = Fakturoid::Client::Subject.search(
|
99
|
+
response = Fakturoid::Client::Subject.search("Client name")
|
89
100
|
```
|
90
101
|
|
91
102
|
To find one subject use:
|
@@ -97,13 +108,13 @@ response = Fakturoid::Client::Subject.find(subject_id)
|
|
97
108
|
You can create new subject with:
|
98
109
|
|
99
110
|
```ruby
|
100
|
-
response = Fakturoid::Client::Subject.create(name:
|
111
|
+
response = Fakturoid::Client::Subject.create(name: "New client")
|
101
112
|
```
|
102
113
|
|
103
114
|
To update subject use following code:
|
104
115
|
|
105
116
|
```ruby
|
106
|
-
response = Fakturoid::Client::Subject.update(subject_id, name:
|
117
|
+
response = Fakturoid::Client::Subject.update(subject_id, name: "Updated client")
|
107
118
|
```
|
108
119
|
|
109
120
|
Delete subject:
|
@@ -112,7 +123,7 @@ Delete subject:
|
|
112
123
|
Fakturoid::Client::Subject.delete subject_id
|
113
124
|
```
|
114
125
|
|
115
|
-
For the list of all subject fields and options see the [Subjects API documentation](
|
126
|
+
For the list of all subject fields and options see the [Subjects API documentation](https://fakturoid.docs.apiary.io/#reference/subjects)
|
116
127
|
|
117
128
|
### Invoice resource
|
118
129
|
|
@@ -125,7 +136,7 @@ response = Fakturoid::Client::Invoice.all(page: 2)
|
|
125
136
|
Fulltext search invoices:
|
126
137
|
|
127
138
|
```ruby
|
128
|
-
response = Fakturoid::Client::Invoice.search(
|
139
|
+
response = Fakturoid::Client::Invoice.search("Client name")
|
129
140
|
```
|
130
141
|
|
131
142
|
To find one invoice use:
|
@@ -139,8 +150,8 @@ To download invoice in PDF format you can use following code:
|
|
139
150
|
```ruby
|
140
151
|
response = Fakturoid::Client::Invoice.download_pdf(invoice_id)
|
141
152
|
|
142
|
-
File.open
|
143
|
-
f.write
|
153
|
+
File.open("/path/to/file.pdf", "wb") do |f|
|
154
|
+
f.write(response.body)
|
144
155
|
end
|
145
156
|
```
|
146
157
|
|
@@ -152,9 +163,9 @@ invoice = {
|
|
152
163
|
lines: [
|
153
164
|
{
|
154
165
|
quantity: 5,
|
155
|
-
unit_name:
|
156
|
-
name:
|
157
|
-
unit_price:
|
166
|
+
unit_name: "kg",
|
167
|
+
name: "Sand",
|
168
|
+
unit_price: "100",
|
158
169
|
vat_rate: 21
|
159
170
|
}
|
160
171
|
]
|
@@ -165,16 +176,16 @@ response = Fakturoid::Client::Invoice.create(invoice)
|
|
165
176
|
Invoice actions (eg. pay invoice):
|
166
177
|
|
167
178
|
```ruby
|
168
|
-
response = Fakturoid::Client::Invoice.fire(invoice_id,
|
179
|
+
response = Fakturoid::Client::Invoice.fire(invoice_id, "pay")
|
169
180
|
```
|
170
181
|
|
171
|
-
Send invoice with customized message (for more information see [the API Documentation](
|
182
|
+
Send invoice with customized message (for more information see [the API Documentation](https://fakturoid.docs.apiary.io/#reference/messages)):
|
172
183
|
|
173
184
|
```ruby
|
174
185
|
message = {
|
175
|
-
email:
|
176
|
-
email_copy:
|
177
|
-
subject:
|
186
|
+
email: "testemail@testemail.cz",
|
187
|
+
email_copy: "some@emailcopy.cz",
|
188
|
+
subject: "I have an invoice for you",
|
178
189
|
message: "Hi,\n\nyou can find invoice no. #no# on the following page #link#\n\nHave a nice day"
|
179
190
|
}
|
180
191
|
|
@@ -185,7 +196,7 @@ response.status_code # => 201
|
|
185
196
|
To update invoice use following code:
|
186
197
|
|
187
198
|
```ruby
|
188
|
-
response = Fakturoid::Client::Invoice.update(invoice_id, number:
|
199
|
+
response = Fakturoid::Client::Invoice.update(invoice_id, number: "2015-0015")
|
189
200
|
```
|
190
201
|
|
191
202
|
Delete invoice:
|
@@ -194,7 +205,7 @@ Delete invoice:
|
|
194
205
|
response = Fakturoid::Client::Invoice.delete(invoice_id)
|
195
206
|
```
|
196
207
|
|
197
|
-
For the list of all invoice fields and options see the [Invoices API documentation](
|
208
|
+
For the list of all invoice fields and options see the [Invoices API documentation](https://fakturoid.docs.apiary.io/#reference/invoices)
|
198
209
|
|
199
210
|
## Handling error responses
|
200
211
|
|
@@ -258,6 +269,3 @@ The Fakturoid gem raises exceptions if error response is returned from the serve
|
|
258
269
|
</tr>
|
259
270
|
</tbody>
|
260
271
|
</table>
|
261
|
-
|
262
|
-
## Thanks
|
263
|
-
Development was supported by [eBallance Creative s.r.o.](http://www.eballance.cz)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fakturoid
|
2
4
|
class Api
|
3
5
|
module Arguments
|
@@ -11,7 +13,7 @@ module Fakturoid
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def validate_search_query(query)
|
14
|
-
raise ArgumentError,
|
16
|
+
raise ArgumentError, "Query parameter is required" if query.nil? || query.empty?
|
15
17
|
true
|
16
18
|
end
|
17
19
|
end
|
data/lib/fakturoid/api.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fakturoid
|
2
4
|
module Client
|
3
5
|
class Event < Fakturoid::Api
|
4
6
|
def self.all(params = {})
|
5
7
|
request_params = permit_params(params, :page, :since, :subject_id) || {}
|
6
8
|
|
7
|
-
get_request(
|
9
|
+
get_request("events.json", request_params: request_params)
|
8
10
|
end
|
9
11
|
|
10
12
|
def self.paid(params = {})
|
11
13
|
request_params = permit_params(params, :page, :since, :subject_id) || {}
|
12
14
|
|
13
|
-
get_request(
|
15
|
+
get_request("events/paid.json", request_params: request_params)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fakturoid
|
2
4
|
module Client
|
3
5
|
class Expense < Fakturoid::Api
|
4
6
|
def self.all(params = {})
|
5
|
-
request_params = permit_params(params, :page, :since, :updated_since, :number, :variable_symbol, :status, :subject_id) || {}
|
7
|
+
request_params = permit_params(params, :page, :since, :updated_since, :number, :variable_symbol, :status, :subject_id, :custom_id) || {}
|
6
8
|
|
7
|
-
get_request(
|
9
|
+
get_request("expenses.json", request_params: request_params)
|
8
10
|
end
|
9
11
|
|
10
12
|
def self.find(id)
|
@@ -12,9 +14,13 @@ module Fakturoid
|
|
12
14
|
get_request("expenses/#{id}.json")
|
13
15
|
end
|
14
16
|
|
15
|
-
def self.search(query)
|
17
|
+
def self.search(query, params = {})
|
16
18
|
validate_search_query(query)
|
17
|
-
|
19
|
+
|
20
|
+
request_params = permit_params(params, :page)
|
21
|
+
request_params[:query] = query
|
22
|
+
|
23
|
+
get_request("expenses/search.json", request_params: request_params)
|
18
24
|
end
|
19
25
|
|
20
26
|
def self.fire(id, event, params = {})
|
@@ -26,7 +32,7 @@ module Fakturoid
|
|
26
32
|
end
|
27
33
|
|
28
34
|
def self.create(payload = {})
|
29
|
-
post_request(
|
35
|
+
post_request("expenses.json", payload: payload)
|
30
36
|
end
|
31
37
|
|
32
38
|
def self.update(id, payload = {})
|
@@ -1,22 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fakturoid
|
2
4
|
module Client
|
3
5
|
class Generator < Fakturoid::Api
|
4
6
|
def self.all(params = {})
|
5
7
|
request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
|
6
8
|
|
7
|
-
get_request(
|
9
|
+
get_request("generators.json", request_params: request_params)
|
8
10
|
end
|
9
11
|
|
10
12
|
def self.recurring(params = {})
|
11
13
|
request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
|
12
14
|
|
13
|
-
get_request(
|
15
|
+
get_request("generators/recurring.json", request_params: request_params)
|
14
16
|
end
|
15
17
|
|
16
18
|
def self.template(params = {})
|
17
19
|
request_params = permit_params(params, :page, :since, :updated_since, :subject_id) || {}
|
18
20
|
|
19
|
-
get_request(
|
21
|
+
get_request("generators/template.json", request_params: request_params)
|
20
22
|
end
|
21
23
|
|
22
24
|
def self.find(id)
|
@@ -25,7 +27,7 @@ module Fakturoid
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.create(payload = {})
|
28
|
-
post_request(
|
30
|
+
post_request("generators.json", payload: payload)
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.update(id, payload = {})
|
@@ -1,22 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fakturoid
|
2
4
|
module Client
|
3
5
|
class Invoice < Fakturoid::Api
|
6
|
+
INDEX_PARAMS = [:page, :since, :until, :updated_since, :updated_until, :number, :status, :subject_id, :custom_id].freeze
|
7
|
+
|
4
8
|
def self.all(params = {})
|
5
|
-
request_params = permit_params(params,
|
9
|
+
request_params = permit_params(params, *INDEX_PARAMS) || {}
|
6
10
|
|
7
|
-
get_request(
|
11
|
+
get_request("invoices.json", request_params: request_params)
|
8
12
|
end
|
9
13
|
|
10
14
|
def self.regular(params = {})
|
11
|
-
request_params = permit_params(params,
|
15
|
+
request_params = permit_params(params, *INDEX_PARAMS) || {}
|
12
16
|
|
13
|
-
get_request(
|
17
|
+
get_request("invoices/regular.json", request_params: request_params)
|
14
18
|
end
|
15
19
|
|
16
20
|
def self.proforma(params = {})
|
17
|
-
request_params = permit_params(params,
|
21
|
+
request_params = permit_params(params, *INDEX_PARAMS) || {}
|
18
22
|
|
19
|
-
get_request(
|
23
|
+
get_request("invoices/proforma.json", request_params: request_params)
|
20
24
|
end
|
21
25
|
|
22
26
|
def self.find(id)
|
@@ -24,14 +28,18 @@ module Fakturoid
|
|
24
28
|
get_request("invoices/#{id}.json")
|
25
29
|
end
|
26
30
|
|
27
|
-
def self.search(query)
|
31
|
+
def self.search(query, params = {})
|
28
32
|
validate_search_query(query)
|
29
|
-
|
33
|
+
|
34
|
+
request_params = permit_params(params, :page)
|
35
|
+
request_params[:query] = query
|
36
|
+
|
37
|
+
get_request("invoices/search.json", request_params: request_params)
|
30
38
|
end
|
31
39
|
|
32
40
|
def self.download_pdf(id)
|
33
41
|
validate_numerical_id(id)
|
34
|
-
get_request("invoices/#{id}/download.pdf", headers: { content_type:
|
42
|
+
get_request("invoices/#{id}/download.pdf", headers: { content_type: "application/pdf" })
|
35
43
|
end
|
36
44
|
|
37
45
|
def self.fire(id, event, params = {})
|
@@ -48,7 +56,7 @@ module Fakturoid
|
|
48
56
|
end
|
49
57
|
|
50
58
|
def self.create(payload = {})
|
51
|
-
post_request(
|
59
|
+
post_request("invoices.json", payload: payload)
|
52
60
|
end
|
53
61
|
|
54
62
|
def self.update(id, payload = {})
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fakturoid
|
2
4
|
module Client
|
3
5
|
class Subject < Fakturoid::Api
|
4
6
|
def self.all(params = {})
|
5
7
|
request_params = permit_params(params, :page, :since, :updated_since, :custom_id) || {}
|
6
8
|
|
7
|
-
get_request(
|
9
|
+
get_request("subjects.json", request_params: request_params)
|
8
10
|
end
|
9
11
|
|
10
12
|
def self.find(id)
|
@@ -12,13 +14,17 @@ module Fakturoid
|
|
12
14
|
get_request("subjects/#{id}.json")
|
13
15
|
end
|
14
16
|
|
15
|
-
def self.search(query)
|
17
|
+
def self.search(query, params = {})
|
16
18
|
validate_search_query(query)
|
17
|
-
|
19
|
+
|
20
|
+
request_params = permit_params(params, :page)
|
21
|
+
request_params[:query] = query
|
22
|
+
|
23
|
+
get_request("subjects/search.json", request_params: request_params)
|
18
24
|
end
|
19
25
|
|
20
26
|
def self.create(payload = {})
|
21
|
-
post_request(
|
27
|
+
post_request("subjects.json", payload: payload)
|
22
28
|
end
|
23
29
|
|
24
30
|
def self.update(id, payload = {})
|