pina 0.13.0 → 0.14.0
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/.gitignore +3 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +0 -1
- data/Dockerfile +13 -0
- data/README.md +77 -29
- data/docker-compose.yml +19 -0
- data/docker-sync.yml +8 -0
- data/lib/pina.rb +18 -6
- data/lib/pina/collections/contact.rb +3 -1
- data/lib/pina/collections/petty_cash_disburstment.rb +9 -0
- data/lib/pina/models/coercions/nested_value.rb +9 -0
- data/lib/pina/models/error.rb +15 -0
- data/lib/pina/models/errors.rb +11 -0
- data/lib/pina/models/nested_value.rb +11 -0
- data/lib/pina/models/petty_cash_disburstment.rb +30 -0
- data/lib/pina/models/petty_cash_disburstment_item.rb +22 -0
- data/lib/pina/models/uploaded_document_pairing.rb +9 -0
- data/lib/pina/petty_cash_disburstment.rb +32 -0
- data/lib/pina/rest_adapter.rb +65 -18
- data/lib/pina/uploaded_document.rb +24 -8
- data/lib/pina/uploaded_document_pairing.rb +38 -0
- data/lib/pina/version.rb +1 -1
- data/pina.gemspec +2 -0
- metadata +30 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 457ff4607c434ec35f86694fee458ec1cbf7a3a4
|
4
|
+
data.tar.gz: 8fcac7850e11f3b7fbfb17e0cc1ccf4c6d50717d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa983a4ade13e4ae7292f204652aba67c6e414b517d6fefd30f531f323bedf2f8c0776604fb8fb9aa1e6b868e8c4c805544fe1a886a626ed1c5e0b087b8777cb
|
7
|
+
data.tar.gz: c241904cec297a365e0652714069f6975eb88d44d3ee34cf8aed6d8661aee928d7a6cc274bc784fd41a3356fd6a31d4c9b7f62bd83507a57b01f152c17afd160
|
data/.gitignore
CHANGED
@@ -26,6 +26,9 @@ build/
|
|
26
26
|
/vendor/bundle
|
27
27
|
/lib/bundler/man/
|
28
28
|
|
29
|
+
## Docker sync
|
30
|
+
.docker-sync/
|
31
|
+
|
29
32
|
# for a library or gem, you might want to ignore these files since the code is
|
30
33
|
# intended to run in multiple environments; otherwise, check them in:
|
31
34
|
# Gemfile.lock
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Dockerfile
ADDED
data/README.md
CHANGED
@@ -25,15 +25,50 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
$ gem install pina
|
27
27
|
|
28
|
+
## Docker dev setup
|
29
|
+
To open development environment in docker:
|
30
|
+
1) install prerequisites
|
31
|
+
`gem install docker-sync`
|
32
|
+
2) run
|
33
|
+
```sh
|
34
|
+
docker volume create --name=gem_store_235
|
35
|
+
docker-sync start
|
36
|
+
docker-compose run web bash
|
37
|
+
```
|
38
|
+
|
39
|
+
## Fantozzi API coverage
|
40
|
+
| Resource | All | Find | Find_by | Where | Create | Update | Delete |
|
41
|
+
| ----------------------- | :---: | :---: | :-----: | :---: | :-----:| :----: | :----: |
|
42
|
+
| Contacts | o | o | o | o | o | o | - |
|
43
|
+
| MyBankAccount | o | o | - | o | o | o | - |
|
44
|
+
| PettyCashDisburstment | o | - | - | - | - | - | - |
|
45
|
+
| ProcessedDocument | o | o | - | o | - | - | o |
|
46
|
+
| Receivable | o | o | - | o | - | - | - |
|
47
|
+
| SalesInvoice | o | o | - | o | o | o | - |
|
48
|
+
| SalesOrder | o | o | - | o | - | - | - |
|
49
|
+
| StatProcessedDocument | o | o | - | o | - | - | - |
|
50
|
+
| UploadedDocument | o | o | - | o | o | o | - |
|
51
|
+
| UploadedDocumentPairing | - | - | - | - | o | - | - |
|
52
|
+
|
53
|
+
Resources not mentioned = resources not covered.
|
54
|
+
|
28
55
|
## Usage
|
29
56
|
|
30
57
|
Before you start using Pina you have to configure it.
|
31
58
|
|
32
59
|
```ruby
|
33
60
|
Pina.configure do |config|
|
34
|
-
config.email
|
35
|
-
config.tenant
|
36
|
-
config.api_token
|
61
|
+
config.email = 'your_email@domain.com'
|
62
|
+
config.tenant = 'your tenant database name'
|
63
|
+
config.api_token = 'your secret token'
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
Optionally, you can configure Pina to run against other than production instance of Fantozzi:
|
68
|
+
```ruby
|
69
|
+
Pina.configure do |config|
|
70
|
+
config.api_host = 'localhost:3000'
|
71
|
+
config.use_ssl = true | false # defaults to true
|
37
72
|
end
|
38
73
|
```
|
39
74
|
|
@@ -156,33 +191,11 @@ orders.first_page
|
|
156
191
|
Pina::SalesOrder.find(order_id)
|
157
192
|
```
|
158
193
|
|
159
|
-
###
|
160
|
-
|
161
|
-
#### All receivables
|
162
|
-
|
163
|
-
```ruby
|
164
|
-
Pina::Receivable.all
|
165
|
-
```
|
166
|
-
|
167
|
-
Gets all receivables from your database. Results are paginated and you can access
|
168
|
-
first, next or previous page like this:
|
169
|
-
|
170
|
-
```ruby
|
171
|
-
receivables = Pina::Receivable.all
|
172
|
-
receivables.next_page
|
173
|
-
```
|
174
|
-
|
175
|
-
```ruby
|
176
|
-
invoices = Pina::Receivable.all
|
177
|
-
invoices.previous_page
|
178
|
-
|
179
|
-
invoices.first_page
|
180
|
-
```
|
181
|
-
|
182
|
-
#### Fetching specific receivable
|
194
|
+
### Petty Cash Disburstments
|
183
195
|
|
196
|
+
#### All petty cash disburstments
|
184
197
|
```ruby
|
185
|
-
Pina::
|
198
|
+
Pina::PettyCashDisburstment.all
|
186
199
|
```
|
187
200
|
|
188
201
|
### Processed Documents
|
@@ -220,6 +233,35 @@ Pina::ProcessedDocument.find(gid)
|
|
220
233
|
Pina::ProcessedDocument.delete(gid)
|
221
234
|
```
|
222
235
|
|
236
|
+
### Receivables
|
237
|
+
|
238
|
+
#### All receivables
|
239
|
+
|
240
|
+
```ruby
|
241
|
+
Pina::Receivable.all
|
242
|
+
```
|
243
|
+
|
244
|
+
Gets all receivables from your database. Results are paginated and you can access
|
245
|
+
first, next or previous page like this:
|
246
|
+
|
247
|
+
```ruby
|
248
|
+
receivables = Pina::Receivable.all
|
249
|
+
receivables.next_page
|
250
|
+
```
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
invoices = Pina::Receivable.all
|
254
|
+
invoices.previous_page
|
255
|
+
|
256
|
+
invoices.first_page
|
257
|
+
```
|
258
|
+
|
259
|
+
#### Fetching specific receivable
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
Pina::Receivable.find(invoice_id)
|
263
|
+
```
|
264
|
+
|
223
265
|
### Stat Processed Documents
|
224
266
|
|
225
267
|
#### All stat processed documents
|
@@ -338,7 +380,13 @@ uploaded_document = Pina::UploadedDocument.find(1)
|
|
338
380
|
uploaded_document.state = 'processed'
|
339
381
|
Pina::UploadedDocument.update(1, uploaded_document)
|
340
382
|
```
|
341
|
-
|
383
|
+
### UploadedDocumentPairing
|
384
|
+
#### Pair uploaded document with a book-keeping document
|
385
|
+
```ruby
|
386
|
+
Pina::UploadedDocumentPairing.create(uploaded_document_id: 1,
|
387
|
+
document_pairable_type: 'purchase_invoice',
|
388
|
+
document_pairable_id: 201700001)
|
389
|
+
```
|
342
390
|
|
343
391
|
## Development
|
344
392
|
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
version: "2"
|
2
|
+
|
3
|
+
volumes:
|
4
|
+
pina-sync:
|
5
|
+
external: true
|
6
|
+
gem_store_235:
|
7
|
+
external: true
|
8
|
+
|
9
|
+
services:
|
10
|
+
web:
|
11
|
+
build:
|
12
|
+
context: .
|
13
|
+
command: bash
|
14
|
+
tty: true
|
15
|
+
stdin_open: true
|
16
|
+
volumes:
|
17
|
+
- gem_store_235:/gems
|
18
|
+
- .:/app
|
19
|
+
- pina-sync:/app:nocopy
|
data/docker-sync.yml
ADDED
data/lib/pina.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support'
|
2
4
|
require 'base64'
|
3
5
|
require 'virtus'
|
@@ -6,6 +8,8 @@ require 'uri'
|
|
6
8
|
|
7
9
|
require 'pina/utils/pagination'
|
8
10
|
|
11
|
+
require 'pina/models/errors'
|
12
|
+
require 'pina/models/error'
|
9
13
|
require 'pina/collections/base'
|
10
14
|
|
11
15
|
require 'pina/contact'
|
@@ -15,9 +19,11 @@ require 'pina/rest_adapter'
|
|
15
19
|
require 'pina/sales_order'
|
16
20
|
require 'pina/receivable'
|
17
21
|
require 'pina/processed_document'
|
22
|
+
require 'pina/petty_cash_disburstment'
|
18
23
|
require 'pina/stat_processed_document'
|
19
24
|
require 'pina/my_bank_account'
|
20
25
|
require 'pina/uploaded_document'
|
26
|
+
require 'pina/uploaded_document_pairing'
|
21
27
|
|
22
28
|
module Pina
|
23
29
|
class ConfigurationNotSet < StandardError; end
|
@@ -27,8 +33,7 @@ module Pina
|
|
27
33
|
DEFAULT_EMAIL = 'dummy@email.com'
|
28
34
|
DEFAULT_TENANT = 'imaginary'
|
29
35
|
|
30
|
-
|
31
|
-
API_PATH = '.ucetnictvi.uol.cz/api/'
|
36
|
+
API_HOST = 'ucetnictvi.uol.cz'
|
32
37
|
|
33
38
|
class << self
|
34
39
|
attr_accessor :configuration
|
@@ -41,8 +46,9 @@ module Pina
|
|
41
46
|
end
|
42
47
|
|
43
48
|
class Configuration
|
44
|
-
attr_accessor :api_token, :email, :tenant
|
49
|
+
attr_accessor :api_token, :email, :api_host, :use_ssl, :tenant
|
45
50
|
attr_reader :api_version
|
51
|
+
attr_writer :base_url
|
46
52
|
|
47
53
|
def initialize
|
48
54
|
set_defaults
|
@@ -52,15 +58,21 @@ module Pina
|
|
52
58
|
@api_version = DEFAULT_API_VERSION
|
53
59
|
@email = DEFAULT_EMAIL
|
54
60
|
@tenant = DEFAULT_TENANT
|
61
|
+
@api_host = API_HOST
|
62
|
+
@use_ssl = true
|
55
63
|
@base_url = nil
|
56
64
|
end
|
57
65
|
|
58
|
-
def
|
59
|
-
|
66
|
+
def schema
|
67
|
+
use_ssl ? 'https://' : 'http://'
|
68
|
+
end
|
69
|
+
|
70
|
+
def tenant_formatted
|
71
|
+
@tenant.blank? ? '' : @tenant + '.'
|
60
72
|
end
|
61
73
|
|
62
74
|
def base_url
|
63
|
-
@base_url =
|
75
|
+
@base_url = schema + tenant_formatted + api_host + '/api/' + "#{api_version}/"
|
64
76
|
end
|
65
77
|
end
|
66
78
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'pina/models/petty_cash_disburstment_item'
|
2
|
+
require 'pina/models/coercions/nested_value'
|
3
|
+
|
4
|
+
module Pina
|
5
|
+
module Models
|
6
|
+
class PettyCashDisburstment
|
7
|
+
include Virtus.model
|
8
|
+
|
9
|
+
attribute :created_at
|
10
|
+
attribute :updated_at
|
11
|
+
attribute :creator, NestedValue
|
12
|
+
attribute :modifier, NestedValue
|
13
|
+
attribute :items, Array[Pina::Models::PettyCashDisburstmentItem]
|
14
|
+
attribute :number
|
15
|
+
attribute :issue_date
|
16
|
+
attribute :receipt_date
|
17
|
+
attribute :note
|
18
|
+
attribute :coefficient
|
19
|
+
attribute :petty_cash, NestedValue
|
20
|
+
attribute :department, NestedValue
|
21
|
+
attribute :total
|
22
|
+
attribute :contact, NestedValue
|
23
|
+
attribute :contract, NestedValue
|
24
|
+
attribute :vat_document
|
25
|
+
attribute :confirmed
|
26
|
+
attribute :status
|
27
|
+
attribute :gid
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'pina/models/coercions/nested_value'
|
2
|
+
|
3
|
+
module Pina
|
4
|
+
module Models
|
5
|
+
class PettyCashDisburstmentItem
|
6
|
+
include Virtus.model
|
7
|
+
|
8
|
+
attribute :created_at
|
9
|
+
attribute :updated_at
|
10
|
+
attribute :creator, NestedValue
|
11
|
+
attribute :modifier, NestedValue
|
12
|
+
attribute :external_id
|
13
|
+
attribute :rule_id, NestedValue
|
14
|
+
attribute :variable_symbol
|
15
|
+
attribute :price
|
16
|
+
attribute :description
|
17
|
+
attribute :department, NestedValue
|
18
|
+
attribute :contract, NestedValue
|
19
|
+
attribute :linked_doc_number
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'pina/models/petty_cash_disburstment'
|
2
|
+
require 'pina/collections/petty_cash_disburstment'
|
3
|
+
|
4
|
+
module Pina
|
5
|
+
class PettyCashDisburstment
|
6
|
+
class << self
|
7
|
+
def find(gid)
|
8
|
+
response = Pina::RestAdapter.get(:petty_cash_disburstments, gid)
|
9
|
+
|
10
|
+
return Pina::Models::PettyCashDisburstment.new(attributes(response)) if
|
11
|
+
response.ok?
|
12
|
+
|
13
|
+
response
|
14
|
+
end
|
15
|
+
|
16
|
+
def all
|
17
|
+
response = Pina::RestAdapter.get(:petty_cash_disburstments)
|
18
|
+
|
19
|
+
return Pina::Collections::PettyCashDisburstment.new(attributes(response)) if
|
20
|
+
response.ok?
|
21
|
+
|
22
|
+
response
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def attributes(response)
|
28
|
+
response.to_hash.merge(response: response)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pina/rest_adapter.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
|
+
require 'net/http/post/multipart'
|
2
|
+
|
1
3
|
module Pina
|
2
4
|
class RestAdapter
|
3
5
|
include ActiveSupport::JSON
|
4
6
|
|
7
|
+
REQUEST_TIMEOUT = 408
|
8
|
+
SERVICE_UNAVAILABLE = 503
|
9
|
+
|
5
10
|
class << self
|
6
11
|
def get(resource, id_or_params = nil)
|
7
12
|
net_http_for(:get, resource, id_or_params)
|
8
13
|
end
|
9
14
|
|
10
|
-
def post(resource, payload)
|
11
|
-
net_http_for(:post, resource, nil, payload)
|
15
|
+
def post(resource, payload, multipart: false)
|
16
|
+
net_http_for(:post, resource, nil, payload, multipart: multipart)
|
12
17
|
end
|
13
18
|
|
14
19
|
def patch(resource, id, payload)
|
15
|
-
net_http_for(:patch, resource, id, payload)
|
20
|
+
net_http_for(:patch, resource, id, payload, multipart: false)
|
16
21
|
end
|
17
22
|
|
18
23
|
def delete(resource, id = nil)
|
@@ -21,19 +26,24 @@ module Pina
|
|
21
26
|
|
22
27
|
private
|
23
28
|
|
24
|
-
def net_http_for(method, resource, id, payload = nil)
|
25
|
-
|
29
|
+
def net_http_for(method, resource, id, payload = nil, multipart: false)
|
30
|
+
raise ConfigurationNotSet unless Pina.configuration
|
26
31
|
|
27
32
|
uri = URI(url(resource, id))
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
request = multipart ? multipart_request(uri, payload) : request(uri, method, payload)
|
34
|
+
|
35
|
+
begin
|
36
|
+
response = Net::HTTP.start(uri.hostname,
|
37
|
+
uri.port,
|
38
|
+
use_ssl: Pina.configuration.use_ssl) do |http|
|
39
|
+
http.request(request)
|
40
|
+
end
|
41
|
+
rescue SocketError
|
42
|
+
return Pina::Models::Error.new(status_code: SERVICE_UNAVAILABLE,
|
43
|
+
message: "služba nedostupná - #{Pina.configuration.api_host}")
|
44
|
+
rescue Net::ReadTimeout
|
45
|
+
return Pina::Models::Error.new(status_code: REQUEST_TIMEOUT,
|
46
|
+
message: "služba neodpovídá - #{Pina.configuration.api_host}")
|
37
47
|
end
|
38
48
|
|
39
49
|
Response.new(response.code.to_i, response.body)
|
@@ -43,16 +53,49 @@ module Pina
|
|
43
53
|
Kernel.const_get("Net::HTTP::#{method.capitalize}")
|
44
54
|
end
|
45
55
|
|
46
|
-
def
|
56
|
+
def auth_header
|
47
57
|
{
|
48
58
|
'Authorization' => 'Basic ' + Base64
|
49
|
-
|
50
|
-
'Accept-Encoding' => 'application/json',
|
51
|
-
'Content-Type' => 'application/json'
|
59
|
+
.strict_encode64("#{Pina.configuration.email}:#{Pina.configuration.api_token}")
|
52
60
|
}
|
53
61
|
end
|
54
62
|
|
63
|
+
def headers
|
64
|
+
auth_header.merge('Accept-Encoding' => 'application/json',
|
65
|
+
'Content-Type' => 'application/json')
|
66
|
+
end
|
67
|
+
|
68
|
+
def request(uri, method, payload)
|
69
|
+
request = net_http_class_for(method).new(uri)
|
70
|
+
headers.each do |k, v|
|
71
|
+
request[k] = v
|
72
|
+
end
|
73
|
+
request.body = payload.to_json if payload
|
74
|
+
request
|
75
|
+
end
|
76
|
+
|
77
|
+
def multipart_request(uri, payload)
|
78
|
+
request = Net::HTTP::Post::Multipart.new uri, multipart_payload(payload)
|
79
|
+
auth_header.each do |k, v|
|
80
|
+
request[k] = v
|
81
|
+
end
|
82
|
+
request
|
83
|
+
end
|
84
|
+
|
85
|
+
def multipart_payload(payload)
|
86
|
+
return payload unless payload.is_a? Hash
|
87
|
+
|
88
|
+
payload.map do |key, val|
|
89
|
+
next unless val.respond_to?(:path)
|
90
|
+
payload[key] = UploadIO.new(val, 'application/pdf', val.path.split('/').last)
|
91
|
+
end
|
92
|
+
|
93
|
+
payload
|
94
|
+
end
|
95
|
+
|
55
96
|
def url(resource, id_or_params)
|
97
|
+
resource = resource_with_namespace(resource)
|
98
|
+
|
56
99
|
if id_or_params.is_a? Hash
|
57
100
|
params = prepare_params_for_request(id_or_params)
|
58
101
|
Pina.configuration.base_url + "#{resource}?#{params}"
|
@@ -64,6 +107,10 @@ module Pina
|
|
64
107
|
def prepare_params_for_request(params)
|
65
108
|
params.map { |key, value| "#{URI::escape(key.to_s)}=#{URI::escape(value.to_s)}" }.join('&')
|
66
109
|
end
|
110
|
+
|
111
|
+
def resource_with_namespace(*resource)
|
112
|
+
resource.join('/')
|
113
|
+
end
|
67
114
|
end
|
68
115
|
|
69
116
|
class Response
|
@@ -4,13 +4,24 @@ require 'pina/collections/uploaded_document'
|
|
4
4
|
module Pina
|
5
5
|
class UploadedDocument
|
6
6
|
class << self
|
7
|
+
def create(uploaded_document)
|
8
|
+
response = Pina::RestAdapter.post(:uploaded_documents, uploaded_document, multipart: true)
|
9
|
+
|
10
|
+
if response.ok?
|
11
|
+
Pina::Models::UploadedDocument.new(attributes(response))
|
12
|
+
else
|
13
|
+
Pina::Models::Error.new(attributes_for_error(response))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
def find(id)
|
8
18
|
response = Pina::RestAdapter.get(:uploaded_documents, id)
|
9
19
|
|
10
|
-
|
11
|
-
response
|
12
|
-
|
13
|
-
|
20
|
+
if response.ok?
|
21
|
+
Pina::Models::UploadedDocument.new(attributes(response))
|
22
|
+
else
|
23
|
+
Pina::Models::Error.new(attributes_for_error(response))
|
24
|
+
end
|
14
25
|
end
|
15
26
|
|
16
27
|
def where(hash, page = nil)
|
@@ -34,10 +45,11 @@ module Pina
|
|
34
45
|
def update(id, uploaded_document)
|
35
46
|
response = Pina::RestAdapter.patch(:uploaded_documents, id, uploaded_document)
|
36
47
|
|
37
|
-
|
38
|
-
response
|
39
|
-
|
40
|
-
|
48
|
+
if response.ok?
|
49
|
+
Pina::Models::UploadedDocument.new(attributes(response))
|
50
|
+
else
|
51
|
+
Pina::Models::Error.new(attributes_for_error(response))
|
52
|
+
end
|
41
53
|
end
|
42
54
|
|
43
55
|
private
|
@@ -45,6 +57,10 @@ module Pina
|
|
45
57
|
def attributes(response)
|
46
58
|
response.to_hash.merge(response: response)
|
47
59
|
end
|
60
|
+
|
61
|
+
def attributes_for_error(response)
|
62
|
+
response.to_hash.merge(status_code: response.status_code)
|
63
|
+
end
|
48
64
|
end
|
49
65
|
end
|
50
66
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'pina/models/uploaded_document_pairing'
|
2
|
+
|
3
|
+
module Pina
|
4
|
+
class UploadedDocumentPairing
|
5
|
+
class << self
|
6
|
+
def find(id)
|
7
|
+
response = Pina::RestAdapter.get([:uploaded_documents, id, :pairings])
|
8
|
+
|
9
|
+
return Pina::Models::UploadedDocumentPairing.new(attributes(response)) if
|
10
|
+
response.ok?
|
11
|
+
|
12
|
+
response
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(params)
|
16
|
+
response = Pina::RestAdapter.post([:uploaded_documents, params[:uploaded_document_id], :pairings],
|
17
|
+
params.except(:uploaded_document_id))
|
18
|
+
|
19
|
+
if response.ok?
|
20
|
+
# TODO: implement uploaded_documents/:id/pairings response object in Fantozzi api
|
21
|
+
response
|
22
|
+
else
|
23
|
+
Pina::Models::Error.new(attributes_for_error(response))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def attributes(response)
|
30
|
+
response.to_hash.merge(response: response)
|
31
|
+
end
|
32
|
+
|
33
|
+
def attributes_for_error(response)
|
34
|
+
response.to_hash.merge(status_code: response.status_code)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/pina/version.rb
CHANGED
data/pina.gemspec
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.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Hronek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: multipart-post
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
195
209
|
description: Fantozzi REST API client
|
196
210
|
email:
|
197
211
|
- hronek@uol.cz
|
@@ -206,15 +220,19 @@ files:
|
|
206
220
|
- ".ruby-version"
|
207
221
|
- ".travis.yml"
|
208
222
|
- CHANGELOG.md
|
223
|
+
- Dockerfile
|
209
224
|
- Gemfile
|
210
225
|
- LICENSE
|
211
226
|
- README.md
|
212
227
|
- Rakefile
|
213
228
|
- bin/console
|
229
|
+
- docker-compose.yml
|
230
|
+
- docker-sync.yml
|
214
231
|
- lib/pina.rb
|
215
232
|
- lib/pina/collections/base.rb
|
216
233
|
- lib/pina/collections/contact.rb
|
217
234
|
- lib/pina/collections/my_bank_account.rb
|
235
|
+
- lib/pina/collections/petty_cash_disburstment.rb
|
218
236
|
- lib/pina/collections/processed_document.rb
|
219
237
|
- lib/pina/collections/receivable.rb
|
220
238
|
- lib/pina/collections/sales_invoice.rb
|
@@ -223,8 +241,14 @@ files:
|
|
223
241
|
- lib/pina/collections/uploaded_document.rb
|
224
242
|
- lib/pina/contact.rb
|
225
243
|
- lib/pina/models/address.rb
|
244
|
+
- lib/pina/models/coercions/nested_value.rb
|
226
245
|
- lib/pina/models/contact.rb
|
246
|
+
- lib/pina/models/error.rb
|
247
|
+
- lib/pina/models/errors.rb
|
227
248
|
- lib/pina/models/my_bank_account.rb
|
249
|
+
- lib/pina/models/nested_value.rb
|
250
|
+
- lib/pina/models/petty_cash_disburstment.rb
|
251
|
+
- lib/pina/models/petty_cash_disburstment_item.rb
|
228
252
|
- lib/pina/models/processed_document.rb
|
229
253
|
- lib/pina/models/receivable.rb
|
230
254
|
- lib/pina/models/sales_invoice.rb
|
@@ -232,7 +256,9 @@ files:
|
|
232
256
|
- lib/pina/models/sales_order.rb
|
233
257
|
- lib/pina/models/stat_processed_document.rb
|
234
258
|
- lib/pina/models/uploaded_document.rb
|
259
|
+
- lib/pina/models/uploaded_document_pairing.rb
|
235
260
|
- lib/pina/my_bank_account.rb
|
261
|
+
- lib/pina/petty_cash_disburstment.rb
|
236
262
|
- lib/pina/processed_document.rb
|
237
263
|
- lib/pina/receivable.rb
|
238
264
|
- lib/pina/rest_adapter.rb
|
@@ -240,6 +266,7 @@ files:
|
|
240
266
|
- lib/pina/sales_order.rb
|
241
267
|
- lib/pina/stat_processed_document.rb
|
242
268
|
- lib/pina/uploaded_document.rb
|
269
|
+
- lib/pina/uploaded_document_pairing.rb
|
243
270
|
- lib/pina/utils/pagination.rb
|
244
271
|
- lib/pina/version.rb
|
245
272
|
- pina.gemspec
|
@@ -263,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
290
|
version: '0'
|
264
291
|
requirements: []
|
265
292
|
rubyforge_project:
|
266
|
-
rubygems_version: 2.6.
|
293
|
+
rubygems_version: 2.6.8
|
267
294
|
signing_key:
|
268
295
|
specification_version: 4
|
269
296
|
summary: Fantozzi REST API client
|