nova-api 1.4.7 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e777554aac2b980c831bfb55c95667c4ae3aedcf9c160ef44030b7e401f9e05
4
- data.tar.gz: c7f07bf53191160beb9c472328dd7666052f97e6c533eda971a1ea43d8171076
3
+ metadata.gz: 909fbbbedbda0b6714b72a9708cf8232daf171b7c504e81c67480fed614ad808
4
+ data.tar.gz: 2330c2270fa4a67e6ea48a34e2ae124ca787e08e921b9b93ee1a9f57a863254a
5
5
  SHA512:
6
- metadata.gz: 410f761cd84115bcc1e4b6e609e36d6926f6e5a6d304b804827bf1c250d587a7b6e8ebd038f9f60ff860b52a8f9f3cc12c47307c54c3cd29e15b73bbe86daecf
7
- data.tar.gz: 47db08b4911fbd9327eac996c38ce4ae89c56223e2d8586f8e1a5ebd1f9843ad8953fe04a2dadc1b4dbb8ea8575b4d859233b6d17352a05092237da9143c5ab7
6
+ metadata.gz: '0993c57f427ea33cd105c370a73a9f5759fcd01e4eda3d4349a7287f22d896fdf224323e1cd90376e6d1bd3ec0a7fa4198fc3c1e994a3ce3afcdc4e225a2a58e'
7
+ data.tar.gz: 5d06ad945eb4e2abe335ebcf1215ac347fe74877f14ac1eeaf2b906451af972fdedaf10f46c7de038ac1f4dcac15c6d229f84228d287781d7f7f800c01da0e02
data/.circleci/config.yml CHANGED
@@ -1,10 +1,10 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby: circleci/ruby@2.0.1
3
+ ruby: circleci/ruby@2.5.3
4
4
  jobs:
5
5
  test:
6
6
  docker:
7
- - image: cimg/ruby:3.0.6-node
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.0.6-node
16
+ - image: cimg/ruby:3.2.9-node
17
17
  steps:
18
18
  - checkout
19
19
  - ruby/install-deps
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nova-api (1.4.7)
4
+ nova-api (1.5.0)
5
5
  dry-struct (~> 1.6)
6
6
  dry-types (~> 1.7)
7
7
  httparty (~> 0.1)
data/lib/nova/api/base.rb CHANGED
@@ -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
- response =
86
- if query
87
- HTTParty.get("#{base_url}#{endpoint}", query: query, headers: headers.merge(authorization_header), format: :json)
88
- else
89
- HTTParty.get("#{base_url}#{endpoint}", headers: headers.merge(authorization_header), format: :json)
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
@@ -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
 
@@ -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
 
@@ -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) ? value.allowed_attributes : value
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nova
4
4
  module API
5
- VERSION = '1.4.7'
5
+ VERSION = '1.5.0'
6
6
  end
7
7
  end
data/lib/nova/api.rb CHANGED
@@ -98,6 +98,10 @@ module Nova
98
98
  Nova::API::Resource::FinancialAccount
99
99
  end
100
100
 
101
+ def installments
102
+ Nova::API::Resource::Installment
103
+ end
104
+
101
105
  def payables
102
106
  Nova::API::Resource::Payable
103
107
  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.7
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coyô Software
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-05-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -211,7 +210,6 @@ metadata:
211
210
  homepage_uri: https://app.swaggerhub.com/apis-docs/coyosoftware/Nova.Money/v1
212
211
  source_code_uri: https://github.com/coyosoftware/nova-api
213
212
  changelog_uri: https://github.com/coyosoftware/nova-api/blob/master/CHANGELOG.md
214
- post_install_message:
215
213
  rdoc_options: []
216
214
  require_paths:
217
215
  - lib
@@ -226,8 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
224
  - !ruby/object:Gem::Version
227
225
  version: '0'
228
226
  requirements: []
229
- rubygems_version: 3.4.19
230
- signing_key:
227
+ rubygems_version: 3.7.1
231
228
  specification_version: 4
232
229
  summary: Nova.Money API gem
233
230
  test_files: []