fakturoid 0.4.0 → 0.5.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 +2 -2
- data/.github/workflows/tests.yml +1 -1
- data/.rubocop.yml +4 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +134 -0
- data/fakturoid.gemspec +1 -1
- data/lib/fakturoid/client/inventory_items.rb +59 -0
- data/lib/fakturoid/client/inventory_moves.rb +36 -0
- data/lib/fakturoid/client.rb +2 -0
- data/lib/fakturoid/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0bd9fc1b14ec03436ce4475e0a3c07a3c1bf5a4c6bb2f0feb0f9f311b2552b6
|
4
|
+
data.tar.gz: c66ecd117726d0e857949499d1a2562f7637645ae477b154715ed33580f3a4b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: affec1b4c502b6689af925a8944868a444e3d47e00e575c9ec63f45ca98f56a6c72c68771432527153ba3f0b799add0c32fabed54bf6f5fd0fb1f48ceeac152f
|
7
|
+
data.tar.gz: fbbcea0fd540d7ece9b88237749d3c2b50218bd5320daaf21dc543c0bc2adabe389229e190f8ca09a712db98d09f5ef02816298ee7c87c914b5f74174c551f5f
|
@@ -8,12 +8,12 @@ jobs:
|
|
8
8
|
test:
|
9
9
|
runs-on: ubuntu-latest
|
10
10
|
steps:
|
11
|
-
- uses: actions/checkout@
|
11
|
+
- uses: actions/checkout@v3
|
12
12
|
|
13
13
|
- name: Set up Ruby
|
14
14
|
uses: ruby/setup-ruby@v1
|
15
15
|
with:
|
16
|
-
ruby-version:
|
16
|
+
ruby-version: 3.0
|
17
17
|
bundler-cache: true
|
18
18
|
|
19
19
|
- name: Rubocop
|
data/.github/workflows/tests.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2
|
2
|
+
TargetRubyVersion: 3.2
|
3
3
|
SuggestExtensions: false
|
4
4
|
NewCops: disable
|
5
5
|
Exclude:
|
@@ -63,6 +63,9 @@ Layout/EmptyLineAfterGuardClause:
|
|
63
63
|
Layout/EmptyLineBetweenDefs:
|
64
64
|
Enabled: false
|
65
65
|
|
66
|
+
Style/HashSyntax:
|
67
|
+
Enabled: false
|
68
|
+
|
66
69
|
Style/RescueStandardError:
|
67
70
|
Exclude:
|
68
71
|
- 'test/response_test.rb'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0
|
1
|
+
3.2.0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -207,6 +207,140 @@ response = Fakturoid::Client::Invoice.delete(invoice_id)
|
|
207
207
|
|
208
208
|
For the list of all invoice fields and options see the [Invoices API documentation](https://fakturoid.docs.apiary.io/#reference/invoices)
|
209
209
|
|
210
|
+
### InventoryItem resource
|
211
|
+
|
212
|
+
To get all inventory items:
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
response = Fakturoid::Client::InventoryItems.all
|
216
|
+
```
|
217
|
+
|
218
|
+
To filter inventory items by certain SKU code:
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
response = Fakturoid::Client::InventoryItems.all(sku: 'SKU1234')
|
222
|
+
```
|
223
|
+
|
224
|
+
To search inventory items (searches in `name`, `article_number` and `sku`):
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
response = Fakturoid::Client::InventoryItems.search('Item name')
|
228
|
+
```
|
229
|
+
|
230
|
+
To get all archived inventory items:
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
response = Fakturoid::Client::InventoryItems.archived
|
234
|
+
```
|
235
|
+
|
236
|
+
To get a single inventory item:
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
response = Fakturoid::Client::InventoryItems.find(inventory_item_id)
|
240
|
+
```
|
241
|
+
|
242
|
+
To create an inventory item:
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
inventory_item = {
|
246
|
+
name: "Item name",
|
247
|
+
sku: "SKU1234",
|
248
|
+
track_quantity: true,
|
249
|
+
quantity: 100,
|
250
|
+
native_purchase_price: 500,
|
251
|
+
native_retail_price: 1000
|
252
|
+
}
|
253
|
+
response = Fakturoid::Client::InventoryItems.create(inventory_item)
|
254
|
+
```
|
255
|
+
|
256
|
+
To update an inventory item:
|
257
|
+
|
258
|
+
```ruby
|
259
|
+
response = Fakturoid::Client::InventoryItems.update(inventory_item_id, name: "Another name")
|
260
|
+
```
|
261
|
+
|
262
|
+
To archive an inventory item:
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
response = Fakturoid::Client::InventoryItems.archive(inventory_item_id)
|
266
|
+
```
|
267
|
+
|
268
|
+
To unarchive an inventory item:
|
269
|
+
|
270
|
+
```ruby
|
271
|
+
response = Fakturoid::Client::InventoryItems.unarchive(inventory_item_id)
|
272
|
+
```
|
273
|
+
|
274
|
+
To delete an inventory item:
|
275
|
+
|
276
|
+
```ruby
|
277
|
+
response = Fakturoid::Client::InventoryItems.delete(inventory_item_id)
|
278
|
+
```
|
279
|
+
|
280
|
+
### InventoryMove resource
|
281
|
+
|
282
|
+
To get get all inventory moves across all inventory items:
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
response = Fakturoid::Client::InventoryMoves.all
|
286
|
+
```
|
287
|
+
|
288
|
+
To get inventory moves for a single inventory item:
|
289
|
+
|
290
|
+
```ruby
|
291
|
+
response = Fakturoid::Client::InventoryMoves.all(inventory_item_id: inventory_item_id)
|
292
|
+
```
|
293
|
+
|
294
|
+
To get a single inventory move:
|
295
|
+
|
296
|
+
```ruby
|
297
|
+
response = Fakturoid::Client::InventoryMoves.find(inventory_item_id, inventory_move_id)
|
298
|
+
```
|
299
|
+
|
300
|
+
To create a stock-in inventory move:
|
301
|
+
|
302
|
+
```ruby
|
303
|
+
response = Fakturoid::Client::InventoryMoves.create(
|
304
|
+
inventory_item_id,
|
305
|
+
direction: "in",
|
306
|
+
moved_on: Date.today,
|
307
|
+
quantity_change: 5,
|
308
|
+
purchase_price: "249.99",
|
309
|
+
purchase_currency: "CZK",
|
310
|
+
private_note: "Bought with discount"
|
311
|
+
)
|
312
|
+
```
|
313
|
+
|
314
|
+
To create a stock-out inventory move:
|
315
|
+
|
316
|
+
```ruby
|
317
|
+
response = Fakturoid::Client::InventoryMoves.create(
|
318
|
+
inventory_item_id,
|
319
|
+
direction: "out",
|
320
|
+
moved_on: Date.today,
|
321
|
+
quantity_change: "1.5",
|
322
|
+
retail_price: 50,
|
323
|
+
retail_currency: "EUR",
|
324
|
+
native_retail_price: "1250"
|
325
|
+
)
|
326
|
+
```
|
327
|
+
|
328
|
+
To update an inventory move:
|
329
|
+
|
330
|
+
```ruby
|
331
|
+
inventory_move = {
|
332
|
+
private_note: "Text"
|
333
|
+
# Plus other fields if necessary
|
334
|
+
}
|
335
|
+
response = Fakturoid::Client::InventoryMoves.update(inventory_item_id, inventory_move_id, inventory_move)
|
336
|
+
```
|
337
|
+
|
338
|
+
To delete an inventory move:
|
339
|
+
|
340
|
+
```ruby
|
341
|
+
response = Fakturoid::Client::InventoryMoves.delete(inventory_item_id, inventory_move_id)
|
342
|
+
```
|
343
|
+
|
210
344
|
## Handling error responses
|
211
345
|
|
212
346
|
The Fakturoid gem raises exceptions if error response is returned from the servers. All exceptions contains following attributes:
|
data/fakturoid.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'fakturoid/version'
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "fakturoid"
|
8
8
|
s.version = Fakturoid::VERSION
|
9
|
-
s.authors = ["Eda Riedl", "Lukáš Konarovský", "Oldřich Vetešník"]
|
9
|
+
s.authors = ["Eda Riedl", "Lukáš Konarovský", "Oldřich Vetešník", "Kamil Hanus"]
|
10
10
|
s.email = ["podpora@fakturoid.cz"]
|
11
11
|
s.summary = %q{Ruby client for web based invoicing service www.fakturoid.cz}
|
12
12
|
s.description = %q{Ruby client for web based invoicing service www.fakturoid.cz}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Fakturoid
|
4
|
+
module Client
|
5
|
+
class InventoryItems < Fakturoid::Api
|
6
|
+
INDEX_PARAMS = [:page, :since, :updated_since, :article_number, :sku].freeze
|
7
|
+
|
8
|
+
def self.all(params = {})
|
9
|
+
request_params = permit_params(params, *INDEX_PARAMS) || {}
|
10
|
+
|
11
|
+
get_request("inventory_items.json", request_params: request_params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.archived(params = {})
|
15
|
+
request_params = permit_params(params, *INDEX_PARAMS) || {}
|
16
|
+
|
17
|
+
get_request("inventory_items/archived.json", request_params: request_params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find(id)
|
21
|
+
validate_numerical_id(id)
|
22
|
+
get_request("inventory_items/#{id}.json")
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.search(query, params = {})
|
26
|
+
validate_search_query(query)
|
27
|
+
|
28
|
+
request_params = permit_params(params, :page)
|
29
|
+
request_params[:query] = query
|
30
|
+
|
31
|
+
get_request("inventory_items/search.json", request_params: request_params)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.archive(id)
|
35
|
+
validate_numerical_id(id)
|
36
|
+
post_request("inventory_items/#{id}/archive.json")
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.unarchive(id)
|
40
|
+
validate_numerical_id(id)
|
41
|
+
post_request("inventory_items/#{id}/unarchive.json")
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.create(payload = {})
|
45
|
+
post_request("inventory_items.json", payload: payload)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.update(id, payload = {})
|
49
|
+
validate_numerical_id(id)
|
50
|
+
patch_request("inventory_items/#{id}.json", payload: payload)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.delete(id)
|
54
|
+
validate_numerical_id(id)
|
55
|
+
delete_request("inventory_items/#{id}.json")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Fakturoid
|
4
|
+
module Client
|
5
|
+
class InventoryMoves < Fakturoid::Api
|
6
|
+
def self.all(params = {})
|
7
|
+
request_params = permit_params(params, :page, :since, :updated_since, :inventory_item_id) || {}
|
8
|
+
|
9
|
+
get_request("inventory_moves.json", request_params: request_params)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find(inventory_item_id, id)
|
13
|
+
validate_numerical_id(inventory_item_id)
|
14
|
+
validate_numerical_id(id)
|
15
|
+
get_request("inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json")
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.create(inventory_item_id, payload = {})
|
19
|
+
validate_numerical_id(inventory_item_id)
|
20
|
+
post_request("inventory_items/#{inventory_item_id}/inventory_moves.json", payload: payload)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.update(inventory_item_id, id, payload = {})
|
24
|
+
validate_numerical_id(inventory_item_id)
|
25
|
+
validate_numerical_id(id)
|
26
|
+
patch_request("inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json", payload: payload)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.delete(inventory_item_id, id)
|
30
|
+
validate_numerical_id(inventory_item_id)
|
31
|
+
validate_numerical_id(id)
|
32
|
+
delete_request("inventory_items/#{inventory_item_id}/inventory_moves/#{id}.json")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/fakturoid/client.rb
CHANGED
@@ -6,6 +6,8 @@ require "fakturoid/client/number_format"
|
|
6
6
|
require "fakturoid/client/user"
|
7
7
|
require "fakturoid/client/subject"
|
8
8
|
require "fakturoid/client/invoice"
|
9
|
+
require "fakturoid/client/inventory_items"
|
10
|
+
require "fakturoid/client/inventory_moves"
|
9
11
|
require "fakturoid/client/expense"
|
10
12
|
require "fakturoid/client/generator"
|
11
13
|
require "fakturoid/client/event"
|
data/lib/fakturoid/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakturoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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:
|
14
|
+
date: 2023-01-13 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: multi_json
|
@@ -152,6 +153,8 @@ files:
|
|
152
153
|
- lib/fakturoid/client/event.rb
|
153
154
|
- lib/fakturoid/client/expense.rb
|
154
155
|
- lib/fakturoid/client/generator.rb
|
156
|
+
- lib/fakturoid/client/inventory_items.rb
|
157
|
+
- lib/fakturoid/client/inventory_moves.rb
|
155
158
|
- lib/fakturoid/client/invoice.rb
|
156
159
|
- lib/fakturoid/client/number_format.rb
|
157
160
|
- lib/fakturoid/client/subject.rb
|
@@ -192,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
195
|
- !ruby/object:Gem::Version
|
193
196
|
version: '0'
|
194
197
|
requirements: []
|
195
|
-
rubygems_version: 3.2
|
198
|
+
rubygems_version: 3.4.2
|
196
199
|
signing_key:
|
197
200
|
specification_version: 4
|
198
201
|
summary: Ruby client for web based invoicing service www.fakturoid.cz
|