nova-api 1.0.0 → 1.2.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: b970fbc5e4e4fee3d3d4e1338421306d7e85abaea9679188715b58be18f4b20a
4
- data.tar.gz: 38c83a6a84d1092aace8f0bf8d96164a5889a28a0d70748fc5de3e2ce1975a61
3
+ metadata.gz: 95a363b8ed0d3656f925c3364ad0fe2b9a0b3bd9f0dcc36b9ecd83ce2f16a7cc
4
+ data.tar.gz: df9655cd2ffe645c767bf73f7a63d9b2b1a4fb6f1ee6511337a8503aab9bb0d6
5
5
  SHA512:
6
- metadata.gz: ac1b74bf1ef47745dfb9d4f2b33b675ab7332d4ab514b66c54e902252a79083c1f77fcd3296159297eb89b895af547813db7898b7a17072cf3389523dd59ef47
7
- data.tar.gz: 86c8cecd0efa2ea4a171739b4cf9d2d97a2426784623db651e7bd3f0bdad6040a0ae8d0da01d5d1a61dd47546f831767129e2f98d334d4e2c337ec2b5128a771
6
+ metadata.gz: e177f013e8cdbfc4c0dcb9f3658ccb295d3d32835c96682c82552d07f46bcdc195faf4605015d301fe7a826ff2ec94a16689085ce953dbdf43c15aaac6d78046
7
+ data.tar.gz: 5618212cf0a37f0a23c9d5e2d7265cf6bc88b8a01ec24ee93e25923deaffb5077bf11de225951d64a290d520d435c5ac5f4e6ccd2375b138fff4e54112949f36
data/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ 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.2.0] - 2023-09-29
9
+
10
+ ### Added
11
+
12
+ - Apportionment name to ApportionmentValue class
13
+ - Active flag to FinancialAccount class
14
+
15
+ ## [1.1.0] - 2023-09-22
16
+
17
+ ### Added
18
+
19
+ - Webhooks endpoint
20
+
8
21
  ## [1.0.0] - 2023-07-11
9
22
 
10
23
  ### Added
@@ -95,7 +108,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
95
108
 
96
109
  - Apportionment related stuff
97
110
 
98
- [unreleased]: https://github.com/coyosoftware/nova-api/compare/1.0.0...HEAD
111
+ [unreleased]: https://github.com/coyosoftware/nova-api/compare/1.2.0...HEAD
112
+ [1.2.0]: https://github.com/coyosoftware/nova-api/releases/tag/1.2.0
113
+ [1.1.0]: https://github.com/coyosoftware/nova-api/releases/tag/1.1.0
99
114
  [1.0.0]: https://github.com/coyosoftware/nova-api/releases/tag/1.0.0
100
115
  [0.8.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.8.0
101
116
  [0.7.0]: https://github.com/coyosoftware/nova-api/releases/tag/0.7.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nova-api (1.0.0)
4
+ nova-api (1.2.0)
5
5
  dry-struct (~> 1.6)
6
6
  dry-types (~> 1.7)
7
7
  httparty (~> 0.1)
@@ -41,7 +41,7 @@ GEM
41
41
  mini_mime (>= 1.0.0)
42
42
  multi_xml (>= 0.5.2)
43
43
  ice_nine (0.11.2)
44
- mini_mime (1.1.2)
44
+ mini_mime (1.1.5)
45
45
  multi_xml (0.6.0)
46
46
  public_suffix (4.0.6)
47
47
  rake (13.0.6)
@@ -8,6 +8,7 @@ module Nova
8
8
  attribute :name, Dry::Types['coercible.string']
9
9
  attribute? :active, Dry::Types['strict.bool'].optional
10
10
  attribute? :apportionment_id, Dry::Types['coercible.integer']
11
+ attribute? :apportionment_name, Dry::Types['coercible.string']
11
12
 
12
13
  def self.endpoint(apportionment_id)
13
14
  "/api/apportionments/#{apportionment_id}/apportionment_values"
@@ -22,6 +22,7 @@ module Nova
22
22
  attribute? :financial_account, Dry::Types['coercible.string'].optional
23
23
  attribute? :income, Dry::Types['strict.bool'].optional
24
24
  attribute? :outcome, Dry::Types['strict.bool'].optional
25
+ attribute? :active, Dry::Types['strict.bool'].optional
25
26
  attribute? :children, Dry::Types['strict.array'].of(Nova::API::Resource::FinancialAccount).optional
26
27
 
27
28
  def self.endpoint
@@ -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
@@ -30,13 +30,13 @@ module Nova
30
30
  protected
31
31
 
32
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)
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
37
  end
38
38
 
39
- klass.new(Hash[*data.flatten].merge(id: id))
39
+ klass.new(values.merge(id: id))
40
40
  end
41
41
 
42
42
  private
@@ -49,12 +49,12 @@ module Nova
49
49
  value.respond_to?(:allowed_attributes) ? value.allowed_attributes : value
50
50
  end
51
51
 
52
- def self.value_for_field(name, override_value, field)
53
- return [name, override_value] if override_value
52
+ def self.value_for_field(override_value, field)
53
+ return override_value if override_value
54
54
 
55
55
  type = field.type
56
56
 
57
- type.optional? ? [name, nil] : [name, generate_valid_value_for(type)]
57
+ type.optional? ? nil : generate_valid_value_for(type)
58
58
  end
59
59
 
60
60
  def self.generate_valid_value_for(type)
@@ -1,5 +1,5 @@
1
1
  module Nova
2
2
  module API
3
- VERSION = "1.0.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
data/lib/nova/api.rb CHANGED
@@ -30,6 +30,8 @@ require "nova/api/resource/write_off"
30
30
 
31
31
  require "nova/api/resource/permission"
32
32
 
33
+ require "nova/api/resource/webhook"
34
+
33
35
  require "nova/api/resource/response/current_asset_statement"
34
36
 
35
37
  require "nova/api/search_params/apportionment"
@@ -111,6 +113,10 @@ module Nova
111
113
  def third_parties
112
114
  Nova::API::Resource::ThirdParty
113
115
  end
116
+
117
+ def webhooks
118
+ Nova::API::Resource::Webhook
119
+ end
114
120
  end
115
121
  end
116
122
  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: 1.0.0
4
+ version: 1.2.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: 2023-07-17 00:00:00.000000000 Z
11
+ date: 2023-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -191,6 +191,7 @@ files:
191
191
  - lib/nova/api/resource/receivable.rb
192
192
  - lib/nova/api/resource/response/current_asset_statement.rb
193
193
  - lib/nova/api/resource/third_party.rb
194
+ - lib/nova/api/resource/webhook.rb
194
195
  - lib/nova/api/resource/write_off.rb
195
196
  - lib/nova/api/response.rb
196
197
  - lib/nova/api/search_params/apportionment.rb
@@ -225,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
226
  - !ruby/object:Gem::Version
226
227
  version: '0'
227
228
  requirements: []
228
- rubygems_version: 3.4.10
229
+ rubygems_version: 3.4.19
229
230
  signing_key:
230
231
  specification_version: 4
231
232
  summary: Nova.Money API gem