nova-api 1.5.0 → 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/Gemfile.lock +1 -1
- data/lib/nova/api/base.rb +2 -2
- data/lib/nova/api/resource/invoice.rb +31 -0
- data/lib/nova/api/resource/payable.rb +14 -0
- data/lib/nova/api/resource/receivable.rb +14 -0
- data/lib/nova/api/version.rb +1 -1
- data/lib/nova/api.rb +1 -0
- metadata +2 -1
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/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)
|
@@ -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
|
@@ -34,6 +34,12 @@ module Nova
|
|
34
34
|
model.destroy
|
35
35
|
end
|
36
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
|
+
|
37
43
|
def endpoint
|
38
44
|
protect_operation_from_missing_value
|
39
45
|
|
@@ -59,6 +65,14 @@ module Nova
|
|
59
65
|
|
60
66
|
do_delete("#{endpoint}")
|
61
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
|
62
76
|
end
|
63
77
|
end
|
64
78
|
end
|
@@ -38,6 +38,12 @@ module Nova
|
|
38
38
|
model.destroy
|
39
39
|
end
|
40
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
|
+
|
41
47
|
def endpoint
|
42
48
|
protect_operation_from_missing_value
|
43
49
|
|
@@ -63,6 +69,14 @@ module Nova
|
|
63
69
|
|
64
70
|
do_delete("#{endpoint}")
|
65
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
|
66
80
|
end
|
67
81
|
end
|
68
82
|
end
|
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"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- lib/nova/api/resource/direct_receivable.rb
|
186
186
|
- lib/nova/api/resource/financial_account.rb
|
187
187
|
- lib/nova/api/resource/installment.rb
|
188
|
+
- lib/nova/api/resource/invoice.rb
|
188
189
|
- lib/nova/api/resource/payable.rb
|
189
190
|
- lib/nova/api/resource/permission.rb
|
190
191
|
- lib/nova/api/resource/receivable.rb
|