nova-api 1.4.7 → 1.6.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/.circleci/config.yml +3 -3
- data/Gemfile.lock +1 -1
- data/lib/nova/api/base.rb +7 -8
- data/lib/nova/api/resource/installment.rb +43 -0
- data/lib/nova/api/resource/invoice.rb +31 -0
- data/lib/nova/api/resource/payable.rb +18 -0
- data/lib/nova/api/resource/receivable.rb +18 -0
- data/lib/nova/api/response.rb +1 -3
- data/lib/nova/api/utils/base_struct.rb +7 -1
- data/lib/nova/api/version.rb +1 -1
- data/lib/nova/api.rb +5 -0
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3289ed438ba6a1ece5a4ff75fa6d26d85ae06960fa702225deee4304099e177
|
4
|
+
data.tar.gz: 9bb44585ef0a4d433a3a82dc5a4b5d981b63e1c5ebef56b233756c4c1606b099
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ba034021ea061029e6567e4151802a1e97035f8d8bc23b8b53dacc21267549bbde947421814d87a34c0800b793df6df42844c192a40fc121dd1c8f30e37c122
|
7
|
+
data.tar.gz: f24ae827d1050af8e957e990437f45491f994128eb9a5cdce0fae4dbc04e41f9bee856d594c93a34353fc47c51b689661b9101ab15d6ed6ba983688ec69d9ede
|
data/.circleci/config.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
version: 2.1
|
2
2
|
orbs:
|
3
|
-
ruby: circleci/ruby@2.
|
3
|
+
ruby: circleci/ruby@2.5.3
|
4
4
|
jobs:
|
5
5
|
test:
|
6
6
|
docker:
|
7
|
-
- image: cimg/ruby:3.
|
7
|
+
- image: cimg/ruby:3.2.9-node
|
8
8
|
steps:
|
9
9
|
- checkout
|
10
10
|
- ruby/install-deps
|
@@ -13,7 +13,7 @@ jobs:
|
|
13
13
|
command: bundle exec rake
|
14
14
|
deploy:
|
15
15
|
docker:
|
16
|
-
- image: cimg/ruby:3.
|
16
|
+
- image: cimg/ruby:3.2.9-node
|
17
17
|
steps:
|
18
18
|
- checkout
|
19
19
|
- ruby/install-deps
|
data/Gemfile.lock
CHANGED
data/lib/nova/api/base.rb
CHANGED
@@ -65,12 +65,12 @@ module Nova
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def do_post(endpoint, data)
|
68
|
+
def do_post(endpoint, data, object = self)
|
69
69
|
Kernel.p "[NOVA-API] Issuing POST to #{base_url}#{endpoint}, headers: #{authorization_header}" if configuration.debug?
|
70
70
|
|
71
71
|
response = HTTParty.post("#{base_url}#{endpoint}", body: data, headers: authorization_header, format: :json)
|
72
72
|
|
73
|
-
Nova::API::Response.build(response,
|
73
|
+
Nova::API::Response.build(response, object)
|
74
74
|
end
|
75
75
|
|
76
76
|
def protect_operation_from_missing_value(attribute = :id)
|
@@ -82,12 +82,11 @@ module Nova
|
|
82
82
|
def self.perform_get(endpoint, query, headers = {})
|
83
83
|
Kernel.p "[NOVA-API] Issuing GET to #{base_url}#{endpoint}, headers: #{headers.merge(authorization_header)}" if configuration.debug?
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
85
|
+
if query
|
86
|
+
HTTParty.get("#{base_url}#{endpoint}", query: query, headers: headers.merge(authorization_header), format: :json)
|
87
|
+
else
|
88
|
+
HTTParty.get("#{base_url}#{endpoint}", headers: headers.merge(authorization_header), format: :json)
|
89
|
+
end
|
91
90
|
end
|
92
91
|
|
93
92
|
def self.authorization_header
|
@@ -10,9 +10,52 @@ module Nova
|
|
10
10
|
attribute :number, Dry::Types['coercible.integer']
|
11
11
|
attribute :value, Dry::Types['coercible.float']
|
12
12
|
|
13
|
+
class WriteOffInstallment < Nova::API::Base
|
14
|
+
ALLOWED_ATTRIBUTES = [:addition, :attachments, :date, :discount, :extra_installment, :write_offs]
|
15
|
+
|
16
|
+
attribute? :id, Dry::Types['coercible.integer'].optional
|
17
|
+
attribute? :addition, Dry::Types['coercible.float'].optional
|
18
|
+
attribute? :attachments, Dry::Types['strict.array'].of(Dry::Types['coercible.string']).optional
|
19
|
+
attribute :date, Dry::Types['coercible.string'].constrained(format: DATE_REGEX)
|
20
|
+
attribute? :discount, Dry::Types['coercible.float'].optional
|
21
|
+
attribute? :extra_installment do
|
22
|
+
attribute :due_date, Dry::Types['coercible.string'].constrained(format: DATE_REGEX)
|
23
|
+
attribute :value, Dry::Types['coercible.float']
|
24
|
+
end
|
25
|
+
attribute :write_offs, Dry::Types['strict.array'] do
|
26
|
+
attribute? :card_tax_id, Dry::Types['coercible.integer'].optional
|
27
|
+
attribute :current_asset_id, Dry::Types['coercible.integer']
|
28
|
+
attribute? :document_number, Dry::Types['coercible.string']
|
29
|
+
attribute :document_type, Dry::Types['coercible.integer']
|
30
|
+
attribute :value, Dry::Types['coercible.float']
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.endpoint
|
34
|
+
Installment.endpoint
|
35
|
+
end
|
36
|
+
|
37
|
+
def write_off
|
38
|
+
protect_operation_from_missing_value
|
39
|
+
|
40
|
+
do_post("#{self.class.endpoint}/#{id}/write_off", allowed_attributes)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
13
44
|
def self.endpoint
|
14
45
|
'/api/installments'
|
15
46
|
end
|
47
|
+
|
48
|
+
def self.write_off(id, parameters)
|
49
|
+
model = WriteOffInstallment.new(parameters.merge(id:))
|
50
|
+
|
51
|
+
model.write_off
|
52
|
+
end
|
53
|
+
|
54
|
+
def write_off(parameters)
|
55
|
+
model = WriteOffInstallment.new(parameters.merge(id:))
|
56
|
+
|
57
|
+
model.write_off
|
58
|
+
end
|
16
59
|
end
|
17
60
|
end
|
18
61
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Nova
|
2
|
+
module API
|
3
|
+
module Resource
|
4
|
+
class Invoice < Nova::API::Base
|
5
|
+
module STATUS
|
6
|
+
AUTHORIZED = 2
|
7
|
+
CANCELLED = 3
|
8
|
+
end
|
9
|
+
|
10
|
+
module TYPE
|
11
|
+
PRODUCT = 0
|
12
|
+
SERVICE = 1
|
13
|
+
PRODUCT_REFUND = 2
|
14
|
+
end
|
15
|
+
|
16
|
+
ALLOWED_ATTRIBUTES = %i[danfe_url key number series status type url xml_url]
|
17
|
+
|
18
|
+
attribute? :id, Dry::Types['coercible.integer'].optional
|
19
|
+
attribute :bill_id, Dry::Types['coercible.integer']
|
20
|
+
attribute? :danfe_url, Dry::Types['coercible.string'].optional
|
21
|
+
attribute? :key, Dry::Types['coercible.string'].optional
|
22
|
+
attribute :number, Dry::Types['coercible.string']
|
23
|
+
attribute :series, Dry::Types['coercible.string']
|
24
|
+
attribute :status, Dry::Types['coercible.integer']
|
25
|
+
attribute :type, Dry::Types['coercible.integer']
|
26
|
+
attribute? :url, Dry::Types['coercible.string'].optional
|
27
|
+
attribute? :xml_url, Dry::Types['coercible.string'].optional
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -10,6 +10,10 @@ module Nova
|
|
10
10
|
do_get_search(endpoint, parameters.to_h)
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.find(id)
|
14
|
+
do_get("#{endpoint}/#{id}", nil, initialize_empty_model_with_id(self, id, date: Date.today.iso8601, first_due_date: Date.today.iso8601))
|
15
|
+
end
|
16
|
+
|
13
17
|
def self.create(parameters)
|
14
18
|
model = new parameters
|
15
19
|
|
@@ -30,6 +34,12 @@ module Nova
|
|
30
34
|
model.destroy
|
31
35
|
end
|
32
36
|
|
37
|
+
def self.save_invoice(id, parameters)
|
38
|
+
model = initialize_empty_model_with_id(self, id, date: Date.today.iso8601, first_due_date: Date.today.iso8601)
|
39
|
+
|
40
|
+
model.save_invoice(parameters)
|
41
|
+
end
|
42
|
+
|
33
43
|
def endpoint
|
34
44
|
protect_operation_from_missing_value
|
35
45
|
|
@@ -55,6 +65,14 @@ module Nova
|
|
55
65
|
|
56
66
|
do_delete("#{endpoint}")
|
57
67
|
end
|
68
|
+
|
69
|
+
def save_invoice(parameters)
|
70
|
+
protect_operation_from_missing_value
|
71
|
+
|
72
|
+
invoice = Invoice.new(parameters.merge(bill_id: id))
|
73
|
+
|
74
|
+
do_post("#{endpoint}/invoices", invoice.allowed_attributes, invoice)
|
75
|
+
end
|
58
76
|
end
|
59
77
|
end
|
60
78
|
end
|
@@ -14,6 +14,10 @@ module Nova
|
|
14
14
|
do_get_search(endpoint, parameters.to_h)
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.find(id)
|
18
|
+
do_get("#{endpoint}/#{id}", nil, initialize_empty_model_with_id(self, id, date: Date.today.iso8601, first_due_date: Date.today.iso8601))
|
19
|
+
end
|
20
|
+
|
17
21
|
def self.create(parameters)
|
18
22
|
model = new parameters
|
19
23
|
|
@@ -34,6 +38,12 @@ module Nova
|
|
34
38
|
model.destroy
|
35
39
|
end
|
36
40
|
|
41
|
+
def self.save_invoice(id, parameters)
|
42
|
+
model = initialize_empty_model_with_id(self, id, date: Date.today.iso8601, first_due_date: Date.today.iso8601)
|
43
|
+
|
44
|
+
model.save_invoice(parameters)
|
45
|
+
end
|
46
|
+
|
37
47
|
def endpoint
|
38
48
|
protect_operation_from_missing_value
|
39
49
|
|
@@ -59,6 +69,14 @@ module Nova
|
|
59
69
|
|
60
70
|
do_delete("#{endpoint}")
|
61
71
|
end
|
72
|
+
|
73
|
+
def save_invoice(parameters)
|
74
|
+
protect_operation_from_missing_value
|
75
|
+
|
76
|
+
invoice = Invoice.new(parameters.merge(bill_id: id))
|
77
|
+
|
78
|
+
do_post("#{endpoint}/invoices", invoice.allowed_attributes, invoice)
|
79
|
+
end
|
62
80
|
end
|
63
81
|
end
|
64
82
|
end
|
data/lib/nova/api/response.rb
CHANGED
@@ -22,9 +22,7 @@ module Nova
|
|
22
22
|
errors ||= extract_error_from_response('errors', parsed_response)
|
23
23
|
errors ||= []
|
24
24
|
|
25
|
-
if object
|
26
|
-
record = object.class.new(object.attributes.merge(parsed_response))
|
27
|
-
end
|
25
|
+
record = object.class.new(object.attributes.merge(parsed_response)) if object
|
28
26
|
|
29
27
|
new(success: success, errors: errors, record: record, status: status)
|
30
28
|
end
|
@@ -46,7 +46,13 @@ module Nova
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def permit_value(key, value)
|
49
|
-
value.respond_to?(:allowed_attributes)
|
49
|
+
if value.respond_to?(:allowed_attributes)
|
50
|
+
value.allowed_attributes
|
51
|
+
elsif value.respond_to?(:attributes)
|
52
|
+
value.attributes
|
53
|
+
else
|
54
|
+
value
|
55
|
+
end
|
50
56
|
end
|
51
57
|
|
52
58
|
def self.value_for_field(override_value, field)
|
data/lib/nova/api/version.rb
CHANGED
data/lib/nova/api.rb
CHANGED
@@ -14,6 +14,7 @@ require "nova/api/resource/installment"
|
|
14
14
|
require "nova/api/resource/bill"
|
15
15
|
require "nova/api/resource/payable"
|
16
16
|
require "nova/api/resource/receivable"
|
17
|
+
require "nova/api/resource/invoice"
|
17
18
|
|
18
19
|
require "nova/api/resource/direct_bill"
|
19
20
|
require "nova/api/resource/direct_payable"
|
@@ -98,6 +99,10 @@ module Nova
|
|
98
99
|
Nova::API::Resource::FinancialAccount
|
99
100
|
end
|
100
101
|
|
102
|
+
def installments
|
103
|
+
Nova::API::Resource::Installment
|
104
|
+
end
|
105
|
+
|
101
106
|
def payables
|
102
107
|
Nova::API::Resource::Payable
|
103
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nova-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Coyô Software
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -186,6 +185,7 @@ files:
|
|
186
185
|
- lib/nova/api/resource/direct_receivable.rb
|
187
186
|
- lib/nova/api/resource/financial_account.rb
|
188
187
|
- lib/nova/api/resource/installment.rb
|
188
|
+
- lib/nova/api/resource/invoice.rb
|
189
189
|
- lib/nova/api/resource/payable.rb
|
190
190
|
- lib/nova/api/resource/permission.rb
|
191
191
|
- lib/nova/api/resource/receivable.rb
|
@@ -211,7 +211,6 @@ metadata:
|
|
211
211
|
homepage_uri: https://app.swaggerhub.com/apis-docs/coyosoftware/Nova.Money/v1
|
212
212
|
source_code_uri: https://github.com/coyosoftware/nova-api
|
213
213
|
changelog_uri: https://github.com/coyosoftware/nova-api/blob/master/CHANGELOG.md
|
214
|
-
post_install_message:
|
215
214
|
rdoc_options: []
|
216
215
|
require_paths:
|
217
216
|
- lib
|
@@ -226,8 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
225
|
- !ruby/object:Gem::Version
|
227
226
|
version: '0'
|
228
227
|
requirements: []
|
229
|
-
rubygems_version: 3.
|
230
|
-
signing_key:
|
228
|
+
rubygems_version: 3.7.1
|
231
229
|
specification_version: 4
|
232
230
|
summary: Nova.Money API gem
|
233
231
|
test_files: []
|