pina 0.14.2 → 0.14.3
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 +4 -4
- data/lib/pina.rb +1 -0
- data/lib/pina/collections/document_pairing.rb +7 -0
- data/lib/pina/document_pairing.rb +23 -0
- data/lib/pina/models/document_pairing.rb +42 -0
- data/lib/pina/models/sales_invoice.rb +1 -0
- data/lib/pina/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff6e594b9c73a20ce3693151ba982ed27e66b9571241bc75b57bcbfa29854afa
|
4
|
+
data.tar.gz: 249191684f10fd080ac0cd53f68729203c4bccd8fe19f71795a2b87da3b023cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92aa7c800628520222e12c9c344ee9d2d71c165364b5476c4b77c464cc23935eec55f40bda293365dd5072ecc186a24464a26788fcc92aa5ea1b0bffc0cdd813
|
7
|
+
data.tar.gz: d4fa14b6224fe4c5325fb8b65c3a5737a3ef8440be45cf159c06c601a941063ccb30279328e08af2577fdb7f35aa9afec3794bcd3b2db789e3d3a5c5e560e33f
|
data/lib/pina.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'pina/models/document_pairing'
|
2
|
+
require 'pina/collections/document_pairing'
|
3
|
+
|
4
|
+
module Pina
|
5
|
+
class DocumentPairing
|
6
|
+
class << self
|
7
|
+
def all(page = nil)
|
8
|
+
response = Pina::RestAdapter.get(:document_pairings, page)
|
9
|
+
|
10
|
+
return Pina::Collections::DocumentPairing.new(attributes(response)) if
|
11
|
+
response.ok?
|
12
|
+
|
13
|
+
response
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def attributes(response)
|
19
|
+
response.to_hash.merge(response: response)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'pina/models/uploaded_document'
|
2
|
+
require 'active_support/inflector'
|
3
|
+
require 'active_support/core_ext/hash/keys'
|
4
|
+
|
5
|
+
module Pina
|
6
|
+
module Models
|
7
|
+
class DocumentPairing
|
8
|
+
include Virtus.model
|
9
|
+
|
10
|
+
attribute :uploaded_document, ::Pina::Models::UploadedDocument
|
11
|
+
|
12
|
+
attribute :document_pairable_type
|
13
|
+
attribute :document_pairable_id
|
14
|
+
|
15
|
+
attribute :created_at, DateTime
|
16
|
+
|
17
|
+
def initialize(attributes = {}, *args)
|
18
|
+
extend(Virtus.model)
|
19
|
+
|
20
|
+
document_type = attributes.symbolize_keys[:document_pairable_type]
|
21
|
+
document_pairable_attribute(document_type)
|
22
|
+
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def document_pairable_attribute(document_type)
|
29
|
+
return unless document_type
|
30
|
+
|
31
|
+
attribute(:document_pairable, document_klass(document_type))
|
32
|
+
end
|
33
|
+
|
34
|
+
def document_klass(document_type)
|
35
|
+
model = document_type.camelize
|
36
|
+
return unless Pina::Models.const_defined?(model)
|
37
|
+
|
38
|
+
Pina::Models.const_get(model)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/pina/version.rb
CHANGED
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.14.
|
4
|
+
version: 0.14.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Hronek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- lib/pina.rb
|
232
232
|
- lib/pina/collections/base.rb
|
233
233
|
- lib/pina/collections/contact.rb
|
234
|
+
- lib/pina/collections/document_pairing.rb
|
234
235
|
- lib/pina/collections/my_bank_account.rb
|
235
236
|
- lib/pina/collections/petty_cash_disburstment.rb
|
236
237
|
- lib/pina/collections/processed_document.rb
|
@@ -241,10 +242,12 @@ files:
|
|
241
242
|
- lib/pina/collections/stat_processed_document.rb
|
242
243
|
- lib/pina/collections/uploaded_document.rb
|
243
244
|
- lib/pina/contact.rb
|
245
|
+
- lib/pina/document_pairing.rb
|
244
246
|
- lib/pina/models/address.rb
|
245
247
|
- lib/pina/models/coercions/nested_value.rb
|
246
248
|
- lib/pina/models/contact.rb
|
247
249
|
- lib/pina/models/contact_bank_account.rb
|
250
|
+
- lib/pina/models/document_pairing.rb
|
248
251
|
- lib/pina/models/error.rb
|
249
252
|
- lib/pina/models/errors.rb
|
250
253
|
- lib/pina/models/my_bank_account.rb
|