nova-api 0.8.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2901a43e9252f408062dc2dc8277a7d725171d1a444b836b5183504253a18780
4
- data.tar.gz: bcab8361a4cbac715fc77c9f7d1edfee01f9625a145b0d6a591fda100b37e369
3
+ metadata.gz: d410fdaa147a6cd242a39c66045adc47398f59f175b93c760d53f041c3d101a6
4
+ data.tar.gz: 3d9d057da1e97fb373b299599fa2bce0dd51419f97b0bde30996d4ef3a1e8147
5
5
  SHA512:
6
- metadata.gz: 606bbc5298434ce3924c205d0b59e84b400113ea21dbb640cb0ad587d5e868b8a688b637b247a402c77e28e7b2f96d7c695f5518f421ccf578ad06293bb38514
7
- data.tar.gz: ba18520bb7f9daa0dc951539c9a321bd3a30c83a9b0d4ab8490a9827398c816771a2d76d867b9d1c4603e65417da5230698ba6cbfc1f44ccee32911f6a977dc3
6
+ metadata.gz: 46f13e1baa522137120e1431cd3fd4ccd5ff9a98f729eb518b4ab190998303c06c4f4ae7b8712f08f8d63678245f582cc8d0fbf3aedb6ccee84762630dac1b15
7
+ data.tar.gz: 19a9131c280fadc21a7ddef76119ce680211e84cf0227e7dc87eaa956c2636ed468167ad8cd08cddd1bb72e1cf77245294d3f11f852d8a0fa6f8d0683b1e8d8a
data/.circleci/config.yml CHANGED
@@ -1,43 +1,38 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby: circleci/ruby@0.1.2
4
-
3
+ ruby: circleci/ruby@2.0.1
5
4
  jobs:
6
5
  test:
7
6
  docker:
8
- - image: circleci/ruby:2.6.3-stretch-node
9
- executor: ruby/default
7
+ - image: cimg/ruby:3.0.6-node
10
8
  steps:
11
9
  - checkout
12
- - run:
13
- name: Bundle
14
- command: bash bin/setup
10
+ - ruby/install-deps
15
11
  - run:
16
12
  name: Run tests
17
- command: bundle exec rspec
13
+ command: bundle exec rake
18
14
  deploy:
19
15
  docker:
20
- - image: circleci/ruby:2.6.3-stretch-node
21
- executor: ruby/default
16
+ - image: cimg/ruby:3.0.6-node
22
17
  steps:
23
18
  - checkout
19
+ - ruby/install-deps
24
20
  - run:
25
- name: Setup Rubygems
26
- command: bash .circleci/setup-rubygems.sh
27
- - run:
28
- name: Publish to Rubygems
29
- command: |
30
- gem build nova-api.gemspec
31
- gem push "nova-api-$(git describe --tags).gem"
32
-
21
+ name: Publish gem to Rubygems
22
+ command: bundle exec rake release
33
23
  workflows:
34
24
  version: 2
35
25
  test-deploy:
36
26
  jobs:
37
- - test
38
- - deploy:
27
+ - test:
39
28
  filters:
40
29
  tags:
41
30
  only: /.*/
31
+ - deploy:
32
+ requires:
33
+ - test
34
+ filters:
35
+ tags:
36
+ only: /^v.*/
42
37
  branches:
43
38
  ignore: /.*/
data/.travis.yml CHANGED
@@ -3,5 +3,5 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.6.5
7
- before_install: gem install bundler -v 1.17.3
6
+ - 3.0.3
7
+ before_install: gem install bundler -v 2.4.10
data/CHANGELOG.md CHANGED
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.0] - 2023-09-22
9
+
10
+ ### Added
11
+
12
+ - Webhooks endpoint
13
+
14
+ ## [1.0.0] - 2023-07-11
15
+
16
+ ### Added
17
+
18
+ - Permissions list endpoint
19
+
20
+ - Direct bill endpoint
21
+
22
+ - New bill document type (ORDER_NUMBER)
23
+
24
+ - Attachment support for bills
25
+
26
+ - Write off document types enum
27
+
28
+ - CardTax id on card list endpoint
29
+
30
+ - CardTax type enum
31
+
32
+ ### Changed
33
+
34
+ - No longer accepting financial_account_id parameter in Receivable and Payable creation/update endpoints. Now the financial account information must be sent using the new financial_accounts array parameter. This was made to accept multiple financial accounts for the same bill.
35
+
8
36
  ## [0.8.0] - 2021-03-16
9
37
 
10
38
  ### Added
@@ -73,7 +101,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
73
101
 
74
102
  - Apportionment related stuff
75
103
 
76
- [unreleased]: https://github.com/coyosoftware/nova-api/compare/0.8.0...HEAD
104
+ [unreleased]: https://github.com/coyosoftware/nova-api/compare/1.1.0...HEAD
105
+ [1.1.0]: https://github.com/coyosoftware/nova-api/releases/tag/1.1.0
106
+ [1.0.0]: https://github.com/coyosoftware/nova-api/releases/tag/1.0.0
77
107
  [0.8.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.8.0
78
108
  [0.7.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.7.0
79
109
  [0.6.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.6.0
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nova-api (0.7.0)
5
- dry-struct (~> 1.4.0)
6
- dry-types (~> 1.5.1)
4
+ nova-api (1.1.0)
5
+ dry-struct (~> 1.6)
6
+ dry-types (~> 1.7)
7
7
  httparty (~> 0.1)
8
8
 
9
9
  GEM
@@ -17,39 +17,34 @@ GEM
17
17
  rexml
18
18
  diff-lcs (1.4.4)
19
19
  docile (1.3.5)
20
- dry-configurable (0.12.1)
20
+ dry-core (1.0.0)
21
21
  concurrent-ruby (~> 1.0)
22
- dry-core (~> 0.5, >= 0.5.0)
23
- dry-container (0.7.2)
22
+ zeitwerk (~> 2.6)
23
+ dry-inflector (1.0.0)
24
+ dry-logic (1.5.0)
24
25
  concurrent-ruby (~> 1.0)
25
- dry-configurable (~> 0.1, >= 0.1.3)
26
- dry-core (0.5.0)
27
- concurrent-ruby (~> 1.0)
28
- dry-inflector (0.2.0)
29
- dry-logic (1.1.0)
30
- concurrent-ruby (~> 1.0)
31
- dry-core (~> 0.5, >= 0.5)
32
- dry-struct (1.4.0)
33
- dry-core (~> 0.5, >= 0.5)
34
- dry-types (~> 1.5)
26
+ dry-core (~> 1.0, < 2)
27
+ zeitwerk (~> 2.6)
28
+ dry-struct (1.6.0)
29
+ dry-core (~> 1.0, < 2)
30
+ dry-types (>= 1.7, < 2)
35
31
  ice_nine (~> 0.11)
36
- dry-types (1.5.1)
32
+ zeitwerk (~> 2.6)
33
+ dry-types (1.7.1)
37
34
  concurrent-ruby (~> 1.0)
38
- dry-container (~> 0.3)
39
- dry-core (~> 0.5, >= 0.5)
40
- dry-inflector (~> 0.1, >= 0.1.2)
41
- dry-logic (~> 1.0, >= 1.0.2)
35
+ dry-core (~> 1.0)
36
+ dry-inflector (~> 1.0)
37
+ dry-logic (~> 1.4)
38
+ zeitwerk (~> 2.6)
42
39
  hashdiff (1.0.1)
43
- httparty (0.18.1)
44
- mime-types (~> 3.0)
40
+ httparty (0.21.0)
41
+ mini_mime (>= 1.0.0)
45
42
  multi_xml (>= 0.5.2)
46
43
  ice_nine (0.11.2)
47
- mime-types (3.3.1)
48
- mime-types-data (~> 3.2015)
49
- mime-types-data (3.2021.0225)
44
+ mini_mime (1.1.2)
50
45
  multi_xml (0.6.0)
51
46
  public_suffix (4.0.6)
52
- rake (10.5.0)
47
+ rake (13.0.6)
53
48
  rexml (3.2.4)
54
49
  rspec (3.10.0)
55
50
  rspec-core (~> 3.10.0)
@@ -78,19 +73,20 @@ GEM
78
73
  addressable (>= 2.3.6)
79
74
  crack (>= 0.3.2)
80
75
  hashdiff (>= 0.4.0, < 2.0.0)
76
+ zeitwerk (2.6.8)
81
77
 
82
78
  PLATFORMS
83
79
  ruby
84
80
 
85
81
  DEPENDENCIES
86
- bundler (~> 1.17)
82
+ bundler (~> 2)
87
83
  byebug (~> 11.1.3)
88
84
  nova-api!
89
- rake (~> 10.0)
85
+ rake (~> 13)
90
86
  rspec (~> 3.0)
91
87
  rspec-dry-struct (~> 0.1)
92
88
  simplecov (~> 0.21)
93
89
  webmock (~> 3.11.2)
94
90
 
95
91
  BUNDLED WITH
96
- 1.17.3
92
+ 2.4.10
data/lib/nova/api/base.rb CHANGED
@@ -4,7 +4,6 @@ require 'forwardable'
4
4
  module Nova
5
5
  module API
6
6
  class Base < Nova::API::Utils::BaseStruct
7
- extend Forwardable
8
7
  include HTTParty
9
8
 
10
9
  format :json
@@ -28,16 +27,6 @@ module Nova
28
27
 
29
28
  protected
30
29
 
31
- def self.initialize_empty_model_with_id(klass, id, additional_attributes = {})
32
- data = klass.schema.type.keys.map do |field|
33
- name = field.name
34
-
35
- value_for_field(name, additional_attributes[name], field)
36
- end
37
-
38
- klass.new(Hash[*data.flatten].merge(id: id))
39
- end
40
-
41
30
  def self.do_get_search(endpoint, query, object = self)
42
31
  response = perform_get(endpoint, query, headers)
43
32
 
@@ -90,14 +79,6 @@ module Nova
90
79
 
91
80
  private
92
81
 
93
- def self.value_for_field(name, override_value, field)
94
- return [name, override_value] if override_value
95
-
96
- type = field.type
97
-
98
- type.optional? ? [name, nil] : [name, generate_valid_value_for(type)]
99
- end
100
-
101
82
  def self.perform_get(endpoint, query, headers = {})
102
83
  set_base_uri
103
84
 
@@ -123,18 +104,6 @@ module Nova
123
104
  base_uri base_url
124
105
  end
125
106
  def_delegator self, :set_base_uri
126
-
127
- def self.generate_valid_value_for(type)
128
- case type.name
129
- when Dry::Types['integer'].name, Dry::Types['float'].name, Dry::Types['decimal'].name
130
- 0
131
- when Dry::Types['bool'].name
132
- false
133
- else
134
- nil
135
- end
136
- end
137
- def_delegator self, :generate_valid_value_for
138
107
  end
139
108
  end
140
109
  end
@@ -14,6 +14,7 @@ module Nova
14
14
  CONTRACT = 8
15
15
  OTHER = 9
16
16
  STATEMENT = 10
17
+ ORDER_NUMBER = 11
17
18
  end
18
19
 
19
20
  module DUE_TYPE
@@ -31,20 +32,28 @@ module Nova
31
32
  attribute :value, Dry::Types['coercible.float']
32
33
  end
33
34
 
35
+ class FinancialAccount < Nova::API::Utils::BaseStruct
36
+ ALLOWED_ATTRIBUTES = [:value, :financial_account_id]
37
+
38
+ attribute :financial_account_id, Dry::Types['coercible.integer']
39
+ attribute :value, Dry::Types['coercible.float']
40
+ end
41
+
34
42
  ALLOWED_ATTRIBUTES = [
35
- :additional_information, :apportionments, :company_id, :date, :document_type, :document_number, :due_type, :financial_account_id,
43
+ :additional_information, :apportionments, :attachments, :company_id, :date, :document_type, :document_number, :due_type, :financial_accounts,
36
44
  :first_due_date, :forecast, :identifier, :installments, :installments_number, :third_party_id, :total_value
37
45
  ]
38
46
 
39
47
  attribute? :id, Dry::Types['coercible.integer'].optional
40
48
  attribute? :additional_information, Dry::Types['coercible.string'].optional
41
49
  attribute? :apportionments, Dry::Types['strict.array'].of(Nova::API::Resource::Bill::Apportionment).optional
50
+ attribute? :attachments, Dry::Types['strict.array'].of(Dry::Types['coercible.string']).optional
42
51
  attribute :company_id, Dry::Types['coercible.integer']
43
52
  attribute :date, Dry::Types['coercible.string'].constrained(format: DATE_REGEX)
44
53
  attribute :document_type, Dry::Types['coercible.integer']
45
54
  attribute? :document_number, Dry::Types['coercible.string']
46
55
  attribute? :due_type, Dry::Types['coercible.integer']
47
- attribute :financial_account_id, Dry::Types['coercible.integer']
56
+ attribute? :financial_accounts, Dry::Types['strict.array'].of(Nova::API::Resource::Bill::FinancialAccount).optional
48
57
  attribute :first_due_date, Dry::Types['coercible.string'].constrained(format: DATE_REGEX)
49
58
  attribute :forecast, Dry::Types['strict.bool']
50
59
  attribute? :identifier, Dry::Types['coercible.string'].optional
@@ -3,13 +3,38 @@ module Nova
3
3
  module Resource
4
4
  class Card < Nova::API::Resource::CurrentAsset
5
5
  class Tax < Nova::API::Utils::BaseStruct
6
+ module TYPE
7
+ DEBIT = 0
8
+ CREDIT = 1
9
+ CREDIT_WITH_INSTALLMENTS = 2
10
+ BANK_SLIP = 3
11
+ PIX = 4
12
+ end
13
+
6
14
  ALLOWED_ATTRIBUTES = %i[]
7
15
 
8
16
  attribute :percentage, Dry::Types['coercible.float']
9
17
  attribute :fixed, Dry::Types['coercible.float']
10
- attribute :type, Dry::Types['coercible.string']
18
+ attribute :type, Dry::Types['coercible.integer']
19
+ attribute :id, Dry::Types['coercible.integer']
11
20
  attribute :installments, Dry::Types['coercible.integer']
12
21
  attribute :days, Dry::Types['coercible.integer']
22
+
23
+ def debit?
24
+ type == TYPE::DEBIT
25
+ end
26
+
27
+ def credit?
28
+ type == TYPE::CREDIT || type == TYPE::CREDIT_WITH_INSTALLMENTS
29
+ end
30
+
31
+ def bank_slip?
32
+ type == TYPE::BANK_SLIP
33
+ end
34
+
35
+ def pix?
36
+ type == TYPE::PIX
37
+ end
13
38
  end
14
39
 
15
40
  ALLOWED_ATTRIBUTES = %i[]
@@ -0,0 +1,43 @@
1
+ module Nova
2
+ module API
3
+ module Resource
4
+ class DirectBill < Nova::API::Base
5
+ class Installment < Nova::API::Utils::BaseStruct
6
+ ALLOWED_ATTRIBUTES = %i[current_asset_id document_number document_type due_date value]
7
+
8
+ attribute :current_asset_id, Dry::Types['coercible.integer']
9
+ attribute? :document_number, Dry::Types['coercible.string']
10
+ attribute :document_type, Dry::Types['coercible.integer']
11
+ attribute :due_date, Dry::Types['coercible.string'].constrained(format: DATE_REGEX)
12
+ attribute :value, Dry::Types['coercible.float']
13
+ end
14
+
15
+ ALLOWED_ATTRIBUTES = [
16
+ :addition, :additional_information, :apportionments, :attachments, :company_id, :date, :discount, :document_type, :document_number,
17
+ :financial_accounts, :first_due_date, :identifier, :installments, :third_party_id, :total_value
18
+ ]
19
+
20
+ attribute? :id, Dry::Types['coercible.integer'].optional
21
+ attribute? :addition, Dry::Types['coercible.float'].optional
22
+ attribute? :additional_information, Dry::Types['coercible.string'].optional
23
+ attribute? :apportionments, Dry::Types['strict.array'].of(Nova::API::Resource::Bill::Apportionment).optional
24
+ attribute? :attachments, Dry::Types['strict.array'].of(Dry::Types['coercible.string']).optional
25
+ attribute :company_id, Dry::Types['coercible.integer']
26
+ attribute :date, Dry::Types['coercible.string'].constrained(format: DATE_REGEX)
27
+ attribute? :discount, Dry::Types['coercible.float'].optional
28
+ attribute :document_type, Dry::Types['coercible.integer']
29
+ attribute? :document_number, Dry::Types['coercible.string']
30
+ attribute? :financial_accounts, Dry::Types['strict.array'].of(Nova::API::Resource::Bill::FinancialAccount).optional
31
+ attribute :first_due_date, Dry::Types['coercible.string'].constrained(format: DATE_REGEX)
32
+ attribute? :identifier, Dry::Types['coercible.string'].optional
33
+ attribute? :installments, Dry::Types['strict.array'].of(Nova::API::Resource::DirectBill::Installment).optional
34
+ attribute :third_party_id, Dry::Types['coercible.integer']
35
+ attribute :total_value, Dry::Types['coercible.float']
36
+
37
+ def self.endpoint
38
+ nil
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,21 @@
1
+ module Nova
2
+ module API
3
+ module Resource
4
+ class DirectPayable < Nova::API::Resource::DirectBill
5
+ def self.endpoint
6
+ '/api/payables/save_direct'
7
+ end
8
+
9
+ def self.create(parameters)
10
+ model = new parameters
11
+
12
+ model.create
13
+ end
14
+
15
+ def create
16
+ do_post(self.class.endpoint, allowed_attributes)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ module Nova
2
+ module API
3
+ module Resource
4
+ class DirectReceivable < Nova::API::Resource::DirectBill
5
+ class Installment < Nova::API::Resource::DirectBill::Installment
6
+ ALLOWED_ATTRIBUTES = Nova::API::Resource::DirectBill::Installment::ALLOWED_ATTRIBUTES.dup.concat([:card_tax_id, :gross_value])
7
+
8
+ attribute? :card_tax_id, Dry::Types['coercible.integer'].optional
9
+ attribute? :gross_value, Dry::Types['coercible.float'].optional
10
+ end
11
+
12
+ ALLOWED_ATTRIBUTES = Nova::API::Resource::DirectBill::ALLOWED_ATTRIBUTES.dup << :gross_value
13
+
14
+ attribute? :gross_value, Dry::Types['coercible.float'].optional
15
+ attribute? :installments, Dry::Types['strict.array'].of(Nova::API::Resource::DirectReceivable::Installment).optional
16
+
17
+ def self.endpoint
18
+ '/api/receivables/save_direct'
19
+ end
20
+
21
+ def self.create(parameters)
22
+ model = new parameters
23
+
24
+ model.create
25
+ end
26
+
27
+ def create
28
+ do_post(self.class.endpoint, allowed_attributes)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ module Nova
2
+ module API
3
+ module Resource
4
+ class Permission < Nova::API::Base
5
+ ALLOWED_ATTRIBUTES = %i[]
6
+
7
+ attribute :action, Dry::Types['coercible.string']
8
+ attribute :can, Dry::Types['strict.bool']
9
+ attribute :subject, Dry::Types['coercible.string']
10
+
11
+ def self.endpoint
12
+ '/api/users/permissions'
13
+ end
14
+
15
+ def self.list
16
+ do_get_search(endpoint, nil)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,75 @@
1
+ module Nova
2
+ module API
3
+ module Resource
4
+ class Webhook < Nova::API::Base
5
+ ALLOWED_ATTRIBUTES = %i[events url]
6
+
7
+ attribute? :id, Dry::Types['coercible.integer'].optional
8
+ attribute :events, Dry::Types['strict.array'].of(Dry::Types['coercible.string'])
9
+ attribute :url, Dry::Types['coercible.string']
10
+
11
+ def self.endpoint
12
+ '/api/webhooks'
13
+ end
14
+
15
+ def self.create(parameters)
16
+ model = new parameters
17
+
18
+ model.attributes.delete(:id)
19
+
20
+ model.save
21
+ end
22
+
23
+ def self.update(id, parameters)
24
+ model = new parameters.merge(id: id)
25
+
26
+ model.update
27
+ end
28
+
29
+ def self.destroy(id)
30
+ model = initialize_empty_model_with_id(self, id, events: [])
31
+
32
+ model.destroy
33
+ end
34
+
35
+ def self.restore(id)
36
+ model = initialize_empty_model_with_id(self, id, events: [])
37
+
38
+ model.restore
39
+ end
40
+
41
+ def endpoint
42
+ protect_operation_from_missing_value
43
+
44
+ "/api/webhooks/#{id}"
45
+ end
46
+
47
+ def save
48
+ if id.nil?
49
+ do_post(self.class.endpoint, allowed_attributes)
50
+ else
51
+ do_patch("#{endpoint}", allowed_attributes)
52
+ end
53
+ end
54
+
55
+ def update
56
+ protect_operation_from_missing_value
57
+
58
+ do_patch("#{endpoint}", allowed_attributes)
59
+ end
60
+
61
+ def destroy
62
+ protect_operation_from_missing_value
63
+
64
+ do_delete("#{endpoint}")
65
+ end
66
+
67
+ def restore
68
+ protect_operation_from_missing_value
69
+
70
+ do_patch("#{endpoint}/restore", {})
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -2,6 +2,25 @@ module Nova
2
2
  module API
3
3
  module Resource
4
4
  class WriteOff < Nova::API::Base
5
+ module DOCUMENT_TYPE
6
+ DOC = 0
7
+ TED = 1
8
+ CHEQUE_DEPOSIT = 2
9
+ CASH_DEPOSIT = 3
10
+ CARD = 4
11
+ BANK_SLIP = 5
12
+ CASH = 6
13
+ CHEQUE = 7
14
+ RECEIPT = 8
15
+ BANK_WRITE_OFF = 9
16
+ STATEMENT = 11
17
+ WITHDRAWAL = 12
18
+ SUPPLY = 13
19
+ PICK_UP = 14
20
+ DEPOSIT = 15
21
+ PIX = 19
22
+ end
23
+
5
24
  ALLOWED_ATTRIBUTES = %i[]
6
25
 
7
26
  attribute? :date, Dry::Types['coercible.string'].constrained(format: DATE_REGEX).optional
@@ -5,6 +5,8 @@ module Nova
5
5
  module API
6
6
  module Utils
7
7
  class BaseStruct < Dry::Struct
8
+ extend Forwardable
9
+
8
10
  DATE_REGEX = /\A\d{4}-\d{2}-\d{2}\z/
9
11
 
10
12
  transform_keys(&:to_sym)
@@ -25,6 +27,18 @@ module Nova
25
27
  data
26
28
  end
27
29
 
30
+ protected
31
+
32
+ def self.initialize_empty_model_with_id(klass, id, additional_attributes = {})
33
+ values = Hash.new.tap do |hash|
34
+ klass.schema.type.keys.each do |field|
35
+ hash[field.name] = value_for_field(additional_attributes[field.name], field)
36
+ end
37
+ end
38
+
39
+ klass.new(values.merge(id: id))
40
+ end
41
+
28
42
  private
29
43
 
30
44
  def extract_value(key, value)
@@ -34,6 +48,26 @@ module Nova
34
48
  def permit_value(key, value)
35
49
  value.respond_to?(:allowed_attributes) ? value.allowed_attributes : value
36
50
  end
51
+
52
+ def self.value_for_field(override_value, field)
53
+ return override_value if override_value
54
+
55
+ type = field.type
56
+
57
+ type.optional? ? nil : generate_valid_value_for(type)
58
+ end
59
+
60
+ def self.generate_valid_value_for(type)
61
+ case type.name
62
+ when Dry::Types['integer'].name, Dry::Types['float'].name, Dry::Types['decimal'].name
63
+ 0
64
+ when Dry::Types['bool'].name
65
+ false
66
+ else
67
+ nil
68
+ end
69
+ end
70
+ def_delegator self, :generate_valid_value_for
37
71
  end
38
72
  end
39
73
  end
@@ -1,5 +1,5 @@
1
1
  module Nova
2
2
  module API
3
- VERSION = "0.8.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
data/lib/nova/api.rb CHANGED
@@ -15,6 +15,10 @@ require "nova/api/resource/bill"
15
15
  require "nova/api/resource/payable"
16
16
  require "nova/api/resource/receivable"
17
17
 
18
+ require "nova/api/resource/direct_bill"
19
+ require "nova/api/resource/direct_payable"
20
+ require "nova/api/resource/direct_receivable"
21
+
18
22
  require "nova/api/resource/current_asset"
19
23
  require "nova/api/resource/bank"
20
24
  require "nova/api/resource/card"
@@ -24,6 +28,10 @@ require "nova/api/resource/financial_account"
24
28
  require "nova/api/resource/third_party"
25
29
  require "nova/api/resource/write_off"
26
30
 
31
+ require "nova/api/resource/permission"
32
+
33
+ require "nova/api/resource/webhook"
34
+
27
35
  require "nova/api/resource/response/current_asset_statement"
28
36
 
29
37
  require "nova/api/search_params/apportionment"
@@ -78,6 +86,14 @@ module Nova
78
86
  Nova::API::Resource::CurrentAsset
79
87
  end
80
88
 
89
+ def direct_payables
90
+ Nova::API::Resource::DirectPayable
91
+ end
92
+
93
+ def direct_receivables
94
+ Nova::API::Resource::DirectReceivable
95
+ end
96
+
81
97
  def financial_accounts
82
98
  Nova::API::Resource::FinancialAccount
83
99
  end
@@ -86,6 +102,10 @@ module Nova
86
102
  Nova::API::Resource::Payable
87
103
  end
88
104
 
105
+ def permissions
106
+ Nova::API::Resource::Permission
107
+ end
108
+
89
109
  def receivables
90
110
  Nova::API::Resource::Receivable
91
111
  end
@@ -93,6 +113,10 @@ module Nova
93
113
  def third_parties
94
114
  Nova::API::Resource::ThirdParty
95
115
  end
116
+
117
+ def webhooks
118
+ Nova::API::Resource::Webhook
119
+ end
96
120
  end
97
121
  end
98
122
  end
data/nova-api.gemspec CHANGED
@@ -38,8 +38,8 @@ Gem::Specification.new do |spec|
38
38
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
39
39
  spec.require_paths = ["lib"]
40
40
 
41
- spec.add_development_dependency "bundler", "~> 1.17"
42
- spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "bundler", "~> 2"
42
+ spec.add_development_dependency "rake", "~> 13"
43
43
  spec.add_development_dependency "rspec", "~> 3.0"
44
44
  spec.add_development_dependency "simplecov", "~> 0.21"
45
45
  spec.add_development_dependency "byebug", "~> 11.1.3"
@@ -47,6 +47,6 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency "rspec-dry-struct", "~> 0.1"
48
48
 
49
49
  spec.add_dependency "httparty", "~> 0.1"
50
- spec.add_dependency "dry-struct", "~> 1.4.0"
51
- spec.add_dependency "dry-types", "~> 1.5.1"
50
+ spec.add_dependency "dry-struct", "~> 1.6"
51
+ spec.add_dependency "dry-types", "~> 1.7"
52
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nova-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coyô Software
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-16 00:00:00.000000000 Z
11
+ date: 2023-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,28 +128,28 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.4.0
131
+ version: '1.6'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.4.0
138
+ version: '1.6'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: dry-types
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.5.1
145
+ version: '1.7'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.5.1
152
+ version: '1.7'
153
153
  description: This gem was designed to be used as an easy way to comunicate with the
154
154
  Nova.Money API
155
155
  email:
@@ -159,7 +159,6 @@ extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
161
  - ".circleci/config.yml"
162
- - ".circleci/setup-rubygems.sh"
163
162
  - ".gitignore"
164
163
  - ".rspec"
165
164
  - ".travis.yml"
@@ -182,12 +181,17 @@ files:
182
181
  - lib/nova/api/resource/cash.rb
183
182
  - lib/nova/api/resource/company.rb
184
183
  - lib/nova/api/resource/current_asset.rb
184
+ - lib/nova/api/resource/direct_bill.rb
185
+ - lib/nova/api/resource/direct_payable.rb
186
+ - lib/nova/api/resource/direct_receivable.rb
185
187
  - lib/nova/api/resource/financial_account.rb
186
188
  - lib/nova/api/resource/installment.rb
187
189
  - lib/nova/api/resource/payable.rb
190
+ - lib/nova/api/resource/permission.rb
188
191
  - lib/nova/api/resource/receivable.rb
189
192
  - lib/nova/api/resource/response/current_asset_statement.rb
190
193
  - lib/nova/api/resource/third_party.rb
194
+ - lib/nova/api/resource/webhook.rb
191
195
  - lib/nova/api/resource/write_off.rb
192
196
  - lib/nova/api/response.rb
193
197
  - lib/nova/api/search_params/apportionment.rb
@@ -222,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
226
  - !ruby/object:Gem::Version
223
227
  version: '0'
224
228
  requirements: []
225
- rubygems_version: 3.0.3
229
+ rubygems_version: 3.4.19
226
230
  signing_key:
227
231
  specification_version: 4
228
232
  summary: Nova.Money API gem
@@ -1,3 +0,0 @@
1
- mkdir ~/.gem
2
- echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
3
- chmod 0600 /home/circleci/.gem/credentials