nova-api 0.7.0 → 1.0.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: b216822cbce6773c2c57891e535c183cce4fa84a659c58ea03b57f9137fd7a06
4
- data.tar.gz: 9a0203ee8e6fffda09ea938d49d02394148ba5cb04514962aaa6150d8a918fa1
3
+ metadata.gz: b970fbc5e4e4fee3d3d4e1338421306d7e85abaea9679188715b58be18f4b20a
4
+ data.tar.gz: 38c83a6a84d1092aace8f0bf8d96164a5889a28a0d70748fc5de3e2ce1975a61
5
5
  SHA512:
6
- metadata.gz: c02e39188f050e491dae8d8cea5cf96650e7718bef05b8d9bb0d5161396e89daecd10ff5751b2c1cb68030bdef3bfb07d8f0f6ff5489a5bdaefe2d31144fcd7d
7
- data.tar.gz: 603d6ec2bad145e6e7917819407c6db33f03ec9a2e23c0ab17768fc3b71763a3a239115110e622335ac0b838cb10d8a8fc25cebdb44a758aa0f8cba9d7ce83f6
6
+ metadata.gz: ac1b74bf1ef47745dfb9d4f2b33b675ab7332d4ab514b66c54e902252a79083c1f77fcd3296159297eb89b895af547813db7898b7a17072cf3389523dd59ef47
7
+ data.tar.gz: 86c8cecd0efa2ea4a171739b4cf9d2d97a2426784623db651e7bd3f0bdad6040a0ae8d0da01d5d1a61dd47546f831767129e2f98d334d4e2c337ec2b5128a771
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.0.0] - 2023-07-11
9
+
10
+ ### Added
11
+
12
+ - Permissions list endpoint
13
+
14
+ - Direct bill endpoint
15
+
16
+ - New bill document type (ORDER_NUMBER)
17
+
18
+ - Attachment support for bills
19
+
20
+ - Write off document types enum
21
+
22
+ - CardTax id on card list endpoint
23
+
24
+ - CardTax type enum
25
+
26
+ ### Changed
27
+
28
+ - 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.
29
+
30
+ ## [0.8.0] - 2021-03-16
31
+
32
+ ### Added
33
+
34
+ - HTTP status code to Response and ListResponse classes
35
+
8
36
  ## [0.7.0] - 2021-03-12
9
37
 
10
38
  ### Added
@@ -67,7 +95,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
67
95
 
68
96
  - Apportionment related stuff
69
97
 
70
- [unreleased]: https://github.com/coyosoftware/nova-api/compare/0.6.0...HEAD
98
+ [unreleased]: https://github.com/coyosoftware/nova-api/compare/1.0.0...HEAD
99
+ [1.0.0]: https://github.com/coyosoftware/nova-api/releases/tag/1.0.0
100
+ [0.8.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.8.0
101
+ [0.7.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.7.0
71
102
  [0.6.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.6.0
72
103
  [0.5.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.5.0
73
104
  [0.4.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.4.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.0.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
@@ -8,9 +8,11 @@ module Nova
8
8
  attribute :records, Dry::Types['strict.array'].of(Dry::Types['nominal.any']).optional
9
9
  attribute :errors, Dry::Types['strict.array'].of(Dry::Types['coercible.string'])
10
10
  attribute :success, Dry::Types['strict.bool']
11
+ attribute :status, Dry::Types['coercible.integer']
11
12
 
12
13
  def self.build(response, klass)
13
14
  success = response.success?
15
+ status = response.code
14
16
 
15
17
  parsed_response = response.parsed_response
16
18
 
@@ -27,7 +29,7 @@ module Nova
27
29
 
28
30
  errors ||= []
29
31
 
30
- new(success: success, errors: errors, records: records)
32
+ new(success: success, errors: errors, records: records, status: status)
31
33
  end
32
34
 
33
35
  private
@@ -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
@@ -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
@@ -6,11 +6,13 @@ module Nova
6
6
  module API
7
7
  class Response < Nova::API::Utils::BaseStruct
8
8
  attribute? :record, Dry::Types['nominal.any']
9
- attribute :errors, Dry::Types['strict.array'].of(Dry::Types['coercible.string'])
9
+ attribute :errors, Dry::Types['strict.array'].of(Dry::Types['coercible.string'])
10
10
  attribute :success, Dry::Types['strict.bool']
11
+ attribute :status, Dry::Types['coercible.integer']
11
12
 
12
13
  def self.build(response, object = nil)
13
14
  success = response.success?
15
+ status = response.code
14
16
 
15
17
  parsed_response = response.parsed_response.to_h
16
18
 
@@ -24,7 +26,7 @@ module Nova
24
26
  record = object.class.new(object.attributes.merge(parsed_response))
25
27
  end
26
28
 
27
- new(success: success, errors: errors, record: record)
29
+ new(success: success, errors: errors, record: record, status: status)
28
30
  end
29
31
 
30
32
  private
@@ -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
+ data = klass.schema.type.keys.map do |field|
34
+ name = field.name
35
+
36
+ value_for_field(name, additional_attributes[name], field)
37
+ end
38
+
39
+ klass.new(Hash[*data.flatten].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(name, override_value, field)
53
+ return [name, override_value] if override_value
54
+
55
+ type = field.type
56
+
57
+ type.optional? ? [name, nil] : [name, 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.7.0"
3
+ VERSION = "1.0.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,8 @@ 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
+
27
33
  require "nova/api/resource/response/current_asset_statement"
28
34
 
29
35
  require "nova/api/search_params/apportionment"
@@ -78,6 +84,14 @@ module Nova
78
84
  Nova::API::Resource::CurrentAsset
79
85
  end
80
86
 
87
+ def direct_payables
88
+ Nova::API::Resource::DirectPayable
89
+ end
90
+
91
+ def direct_receivables
92
+ Nova::API::Resource::DirectReceivable
93
+ end
94
+
81
95
  def financial_accounts
82
96
  Nova::API::Resource::FinancialAccount
83
97
  end
@@ -86,6 +100,10 @@ module Nova
86
100
  Nova::API::Resource::Payable
87
101
  end
88
102
 
103
+ def permissions
104
+ Nova::API::Resource::Permission
105
+ end
106
+
89
107
  def receivables
90
108
  Nova::API::Resource::Receivable
91
109
  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.7.0
4
+ version: 1.0.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-12 00:00:00.000000000 Z
11
+ date: 2023-07-17 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,9 +181,13 @@ 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
@@ -222,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
225
  - !ruby/object:Gem::Version
223
226
  version: '0'
224
227
  requirements: []
225
- rubygems_version: 3.0.3
228
+ rubygems_version: 3.4.10
226
229
  signing_key:
227
230
  specification_version: 4
228
231
  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