pina 0.9.1 → 0.10.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e39da309aa0116522c4409d93ecd7210614e90f9
4
- data.tar.gz: 32906d34c74d67a52c49fb3b6c197030e67663ef
3
+ metadata.gz: a4dd3aab514f9f4c44138264714c6ebe6dbebd20
4
+ data.tar.gz: 5f21cbbb3333e7dbe526cf72a552d165c3e88b7a
5
5
  SHA512:
6
- metadata.gz: 48df18383896fa70ecd5adc18b1960ceddd54b807ebbbbc80464ac618fde58df45e89d8465f03fd9f7017e8fc70ff5a4174a6b8d3ac1b91fd910f32db0002b88
7
- data.tar.gz: a65f4fe4ed69a858f4c2b888966d272392854d500a0403725da640c7c3d8cd8ba6aaf2b16caca3244636157c7d6fd087b7f4d35e09889119b759dc16418ffebc
6
+ metadata.gz: f384c7d6eb4fd5ecc076faad3969875afd561b12c04220c760e6a59e1fec498205df09901e038b747219fd33438e3aa18a87d668695e4499afa20ae716a3f21a
7
+ data.tar.gz: 33a752019b09792ec1dca6a77343056d600e8f18935098325f3e6b12aef899603c62ac9d1c204d82675f11b190f0e153867020e7053902511d7d73071d83d246
data/README.md CHANGED
@@ -273,6 +273,44 @@ bank_account.download_type = 'none'
273
273
  Pina::MyBankAccount.update('existing', bank_account)
274
274
  ```
275
275
 
276
+ ### UploadedDocuments
277
+
278
+ #### All Uploaded documents
279
+
280
+ ```ruby
281
+ Pina::UploadedDocument.all
282
+ ```
283
+
284
+ Gets all uploaded documents from your database. Results are paginated and you can access
285
+ first, next or previous page like this:
286
+
287
+ ```ruby
288
+ uploaded_documents = Pina::UploadedDocument.all
289
+ uploaded_documents.next_page
290
+ ```
291
+
292
+ ```ruby
293
+ uploaded_documents = Pina::UploadedDocument.all
294
+ uploaded_documents.previous_page
295
+
296
+ uploaded_documents.first_page
297
+ ```
298
+
299
+ #### Fetching specific uploaded document (by ID)
300
+
301
+ ```ruby
302
+ Pina::UploadedDocument.find(1)
303
+ ```
304
+
305
+ #### Update existing uploaded document
306
+
307
+ ```ruby
308
+ uploaded_document = Pina::UploadedDocument.find(1)
309
+ uploaded_document.state = 'processed'
310
+ Pina::UploadedDocument.update(1, uploaded_document)
311
+ ```
312
+
313
+
276
314
  ## Development
277
315
 
278
316
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/pina.rb CHANGED
@@ -17,6 +17,7 @@ require 'pina/sales_order'
17
17
  require 'pina/receivable'
18
18
  require 'pina/processed_document'
19
19
  require 'pina/my_bank_account'
20
+ require 'pina/uploaded_document'
20
21
 
21
22
  module Pina
22
23
  class ConfigurationNotSet < StandardError; end
@@ -0,0 +1,7 @@
1
+ module Pina
2
+ module Collections
3
+ class UploadedDocument < Base
4
+ attribute :items, Array[::Pina::Models::UploadedDocument]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module Pina
2
+ module Models
3
+ class UploadedDocument
4
+ include Virtus.model
5
+
6
+ attribute :id
7
+ attribute :file
8
+ attribute :created_at
9
+ attribute :state
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,50 @@
1
+ require 'pina/models/uploaded_document'
2
+ require 'pina/collections/uploaded_document'
3
+
4
+ module Pina
5
+ class UploadedDocument
6
+ class << self
7
+ def find(id)
8
+ response = Pina::RestAdapter.get(:uploaded_documents, id)
9
+
10
+ return Pina::Models::UploadedDocument.new(attributes(response)) if
11
+ response.ok?
12
+
13
+ response
14
+ end
15
+
16
+ def where(hash, page = nil)
17
+ response = Pina::RestAdapter.get(:uploaded_documents, hash)
18
+
19
+ return Pina::Collections::UploadedDocument.new(attributes(response)) if
20
+ response.ok?
21
+
22
+ response
23
+ end
24
+
25
+ def all(page = nil)
26
+ response = Pina::RestAdapter.get(:uploaded_documents, page)
27
+
28
+ return Pina::Collections::UploadedDocument.new(attributes(response)) if
29
+ response.ok?
30
+
31
+ response
32
+ end
33
+
34
+ def update(id, uploaded_document)
35
+ response = Pina::RestAdapter.patch(:uploaded_documents, id, uploaded_document)
36
+
37
+ return Pina::Models::UploadedDocument.new(attributes(response)) if
38
+ response.ok?
39
+
40
+ response
41
+ end
42
+
43
+ private
44
+
45
+ def attributes(response)
46
+ response.to_hash.merge(response: response)
47
+ end
48
+ end
49
+ end
50
+ end
data/lib/pina/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pina
2
- VERSION = '0.9.1'
2
+ VERSION = '0.10.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Hronek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-12 00:00:00.000000000 Z
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -218,6 +218,7 @@ files:
218
218
  - lib/pina/collections/receivable.rb
219
219
  - lib/pina/collections/sales_invoice.rb
220
220
  - lib/pina/collections/sales_order.rb
221
+ - lib/pina/collections/uploaded_document.rb
221
222
  - lib/pina/contact.rb
222
223
  - lib/pina/models/address.rb
223
224
  - lib/pina/models/contact.rb
@@ -227,12 +228,14 @@ files:
227
228
  - lib/pina/models/sales_invoice.rb
228
229
  - lib/pina/models/sales_item.rb
229
230
  - lib/pina/models/sales_order.rb
231
+ - lib/pina/models/uploaded_document.rb
230
232
  - lib/pina/my_bank_account.rb
231
233
  - lib/pina/processed_document.rb
232
234
  - lib/pina/receivable.rb
233
235
  - lib/pina/rest_adapter.rb
234
236
  - lib/pina/sales_invoice.rb
235
237
  - lib/pina/sales_order.rb
238
+ - lib/pina/uploaded_document.rb
236
239
  - lib/pina/utils/pagination.rb
237
240
  - lib/pina/version.rb
238
241
  - pina.gemspec