pina 0.7.1 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3af42631a1c04e747b3850dafe2a69fce9974064
4
- data.tar.gz: 3c6a8a51d3463e38517f9dda1988f2036dae5385
3
+ metadata.gz: da1d170fdb92e263a0dbdb216abac21588769214
4
+ data.tar.gz: f396b6c0025bb1758b24a2a447614c5d368eb791
5
5
  SHA512:
6
- metadata.gz: 55a124254141aa54e78a23cac9b2d5dea488df3d1a55d887c1af4c110b8578bcb218ccc04052b326f78a1a6a06865b56588b5cbf83bcc4910f322a71991a63a8
7
- data.tar.gz: ba95f58f814d66c955e3838cac6220c898dd86c908b86e229106e902766a2fac676532f28db3ebf581bdd562b45d52e3be008b5f1bdbad70e1ac2c98545d8222
6
+ metadata.gz: 13ee83c63c8f8b5b4c4c9ee39dda2287d64676b7c32a2b6e3da948177a82f9b4a6242b5d333f58b9e8d0c31bb9e00d6945c4b2039c3c5f4c48c91ba5f3a38366
7
+ data.tar.gz: 18bb2019e379ec506593c8323cd0a6c6f3d6544ab3ac14788ee7c31fe9c2eb8875c02defdc631ff278334ccd105be31d39f3670c5cc4b4bfc70b4447e6f8d5d2
data/.travis.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
3
+ - 2.3.1
4
4
  - 2.2.3
5
5
  env:
6
6
  - secure: TENANT=test
7
7
  before_install: gem install bundler -v 1.10.6
8
+ after_success: bundle exec codeclimate-test-reporter
data/README.md CHANGED
@@ -185,6 +185,41 @@ invoices.first_page
185
185
  Pina::Receivable.find(invoice_id)
186
186
  ```
187
187
 
188
+ ### Processed Documents
189
+
190
+ #### All processed documents
191
+
192
+ ```ruby
193
+ Pina::ProcessedDocument.all
194
+ ```
195
+
196
+ Gets all processed documents from your database. Results are paginated and you can access
197
+ first, next or previous page like this:
198
+
199
+ ```ruby
200
+ documents = Pina::ProcessedDocument.all
201
+ documents.next_page
202
+ ```
203
+
204
+ ```ruby
205
+ documents = Pina::ProcessedDocument.all
206
+ documents.previous_page
207
+
208
+ documents.first_page
209
+ ```
210
+
211
+ #### Fetching specific processed document
212
+
213
+ ```ruby
214
+ Pina::ProcessedDocument.find(gid)
215
+ ```
216
+
217
+ #### Deleting specific processed document
218
+
219
+ ```ruby
220
+ Pina::ProcessedDocument.delete(gid)
221
+ ```
222
+
188
223
  ## Development
189
224
 
190
225
  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
@@ -15,6 +15,7 @@ require 'pina/version'
15
15
  require 'pina/rest_adapter'
16
16
  require 'pina/sales_order'
17
17
  require 'pina/receivable'
18
+ require 'pina/processed_document'
18
19
 
19
20
  module Pina
20
21
  class ConfigurationNotSet < StandardError; end
@@ -57,7 +58,7 @@ module Pina
57
58
  end
58
59
 
59
60
  def base_url
60
- @base_url ||= SCHEME + tenant + API_PATH + "#{api_version}/"
61
+ @base_url = SCHEME + tenant + API_PATH + "#{api_version}/"
61
62
  end
62
63
  end
63
64
  end
@@ -0,0 +1,7 @@
1
+ module Pina
2
+ module Collections
3
+ class ProcessedDocument < Base
4
+ attribute :items, Array[::Pina::Models::ProcessedDocument]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ module Pina
2
+ module Models
3
+ class ProcessedDocument
4
+ include Virtus.model
5
+
6
+ attribute :gid
7
+ attribute :external_id
8
+ attribute :status
9
+ attribute :table
10
+ attribute :date
11
+ attribute :user
12
+ attribute :number_of_created_documents
13
+ attribute :document_creation_time
14
+ attribute :number_of_modified_documents
15
+ attribute :document_modification_time
16
+ attribute :number_of_modified_original_documents
17
+ attribute :original_document_modification_time
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ require 'pina/models/processed_document'
2
+ require 'pina/collections/processed_document'
3
+
4
+ module Pina
5
+ class ProcessedDocument
6
+ class << self
7
+ def new(params = nil)
8
+ Pina::Models::ProcessedDocument.new(params)
9
+ end
10
+
11
+ def find(id)
12
+ response = Pina::RestAdapter.get(:processed_documents, id)
13
+
14
+ return Pina::Models::ProcessedDocument.new(attributes(response)) if
15
+ response.ok?
16
+
17
+ response
18
+ end
19
+
20
+ def where(hash, page = nil)
21
+ response = Pina::RestAdapter.get(:processed_documents, hash)
22
+
23
+ return Pina::Collections::ProcessedDocument.new(attributes(response)) if
24
+ response.ok?
25
+
26
+ response
27
+ end
28
+
29
+ def all(page = nil)
30
+ response = Pina::RestAdapter.get(:processed_documents, page)
31
+
32
+ return Pina::Collections::ProcessedDocument.new(attributes(response)) if
33
+ response.ok?
34
+
35
+ response
36
+ end
37
+
38
+ def delete(id)
39
+ response = Pina::RestAdapter.delete(:processed_documents, id)
40
+
41
+ return Pina::Models::ProcessedDocument.new(attributes(response)) if
42
+ response.ok?
43
+
44
+ response
45
+ end
46
+
47
+ private
48
+
49
+ def attributes(response)
50
+ response.to_hash.merge(response: response)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -26,6 +26,13 @@ module Pina
26
26
  Response.new(request.response_code, request.body)
27
27
  end
28
28
 
29
+ def delete(resource, id = nil)
30
+ fail ConfigurationNotSet unless Pina.configuration
31
+
32
+ request = Typhoeus.delete(url(resource, id), headers: auth)
33
+ Response.new(request.response_code, request.body)
34
+ end
35
+
29
36
  private
30
37
 
31
38
  def content_type
data/lib/pina/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pina
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.1'
3
3
  end
data/pina.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'vcr'
28
28
  spec.add_development_dependency 'factory_girl'
29
29
  spec.add_development_dependency 'dotenv'
30
+ spec.add_development_dependency 'simplecov'
30
31
  spec.add_development_dependency('codeclimate-test-reporter')
31
32
 
32
33
  spec.add_runtime_dependency 'typhoeus'
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.7.1
4
+ version: 0.8.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: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: codeclimate-test-reporter
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -199,16 +213,19 @@ files:
199
213
  - lib/pina.rb
200
214
  - lib/pina/collections/base.rb
201
215
  - lib/pina/collections/contact.rb
216
+ - lib/pina/collections/processed_document.rb
202
217
  - lib/pina/collections/receivable.rb
203
218
  - lib/pina/collections/sales_invoice.rb
204
219
  - lib/pina/collections/sales_order.rb
205
220
  - lib/pina/contact.rb
206
221
  - lib/pina/models/address.rb
207
222
  - lib/pina/models/contact.rb
223
+ - lib/pina/models/processed_document.rb
208
224
  - lib/pina/models/receivable.rb
209
225
  - lib/pina/models/sales_invoice.rb
210
226
  - lib/pina/models/sales_item.rb
211
227
  - lib/pina/models/sales_order.rb
228
+ - lib/pina/processed_document.rb
212
229
  - lib/pina/receivable.rb
213
230
  - lib/pina/rest_adapter.rb
214
231
  - lib/pina/sales_invoice.rb