fintoc 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34910f21240b0f76d808c9ab4f22b8ea4a904c9280b11e3bb1d39eee6660a0b6
4
- data.tar.gz: ce6b1ca7100789cb27067aaeccd80324e089cbaf7b819317f35472f1fd3dad6d
3
+ metadata.gz: 18a0e42f4e865dc3c9a5effb821f75cd8c0df2fd1cc74d438b70cb25197db7c3
4
+ data.tar.gz: d88a84f2581d693274770e4de27df625851116d896538f519eb4184f061e92aa
5
5
  SHA512:
6
- metadata.gz: 963c67d86b28ec2a1215720a6ddc69ff102f2f4368bc32871167750418d49e0e1b46ad95ebb6406862be93bd80034ea9398eac3622b9ced2a8b13719c7f7a519
7
- data.tar.gz: fb45a851b1ce805c9bfd31d9eeefb21646c0acccdff4e0a3be04e541e57778af090f553892127638ef2ebd623319c17c430f9a09168875fe1b94ec99392f25f5
6
+ metadata.gz: 47a1a45fdd60049a311cc7aa6458c5942de82a4a2ae4a05139d3ebe92f96da5a2b8bdff7544d5195536575cc7fa209b54092cfaa3c5e0caf2a1e463b1389fed8
7
+ data.tar.gz: 7e8677a9c72a33803a98c44ac8adedc86ed835d9bfa99505f8c17c9e8d77e0b8b6c41bbe1ad5681feefff7e88c995eb6a710b61ad8d573af29696777e13f3fe2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fintoc (1.5.0)
4
+ fintoc (1.6.0)
5
5
  http
6
6
  money-rails
7
7
  tabulate
@@ -46,6 +46,8 @@ module Fintoc
46
46
  proc do |resource, form: nil, **kwargs|
47
47
  parameters = form ? { form: build_form(form) } : params(method, **kwargs)
48
48
  response = make_request(method, resource, parameters, version:, use_jws:, idempotency_key:)
49
+ next nil if response.status.no_content?
50
+
49
51
  content = JSON.parse(response.body, symbolize_names: true)
50
52
 
51
53
  if response.status.client_error? || response.status.server_error?
@@ -1,5 +1,6 @@
1
1
  require 'fintoc/base_client'
2
2
  require 'fintoc/v2/managers/entities_manager'
3
+ require 'fintoc/v2/managers/recipients_manager'
3
4
  require 'fintoc/v2/managers/accounts_manager'
4
5
  require 'fintoc/v2/managers/account_numbers_manager'
5
6
  require 'fintoc/v2/managers/transfers_manager'
@@ -14,6 +15,10 @@ module Fintoc
14
15
  @entities ||= Managers::EntitiesManager.new(self)
15
16
  end
16
17
 
18
+ def recipients
19
+ @recipients ||= Managers::RecipientsManager.new(self)
20
+ end
21
+
17
22
  def accounts
18
23
  @accounts ||= Managers::AccountsManager.new(self)
19
24
  end
@@ -0,0 +1,47 @@
1
+ require 'fintoc/v2/resources/recipient'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class RecipientsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(entity_id:, account_number:, holder_name:, idempotency_key: nil, **params)
12
+ data = @client.post(version: :v2, idempotency_key:).call(
13
+ 'recipients', entity_id:, account_number:, holder_name:, **params
14
+ )
15
+ build_recipient(data)
16
+ end
17
+
18
+ def get(recipient_id)
19
+ data = @client.get(version: :v2).call("recipients/#{recipient_id}")
20
+ build_recipient(data)
21
+ end
22
+
23
+ def list(**params)
24
+ @client.get(version: :v2).call('recipients', **params).map do |data|
25
+ build_recipient(data)
26
+ end
27
+ end
28
+
29
+ def update(recipient_id, idempotency_key: nil, **params)
30
+ data = @client.patch(version: :v2, idempotency_key:)
31
+ .call("recipients/#{recipient_id}", **params)
32
+ build_recipient(data)
33
+ end
34
+
35
+ def delete(recipient_id)
36
+ @client.delete(version: :v2).call("recipients/#{recipient_id}")
37
+ end
38
+
39
+ private
40
+
41
+ def build_recipient(data)
42
+ Fintoc::V2::Recipient.new(**data, client: @client)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,62 @@
1
+ module Fintoc
2
+ module V2
3
+ class Recipient
4
+ attr_reader :id, :object, :account_number, :account_type, :alias, :created_at,
5
+ :email, :holder_id, :holder_name, :holder_type, :updated_at, :institution
6
+
7
+ def initialize(
8
+ id:, object:, account_number:, account_type:, holder_name:, institution:,
9
+ created_at: nil, email: nil, holder_id: nil, holder_type: nil,
10
+ updated_at: nil, client: nil, **attributes
11
+ )
12
+ @id = id
13
+ @object = object
14
+ @account_number = account_number
15
+ @account_type = account_type
16
+ @alias = attributes[:alias]
17
+ @created_at = created_at
18
+ @email = email
19
+ @holder_id = holder_id
20
+ @holder_name = holder_name
21
+ @holder_type = holder_type
22
+ @updated_at = updated_at
23
+ @institution = institution
24
+ @client = client
25
+ end
26
+
27
+ def refresh
28
+ refresh_from_recipient(@client.recipients.get(@id))
29
+ end
30
+
31
+ def update(idempotency_key: nil, **params)
32
+ refresh_from_recipient(@client.recipients.update(@id, idempotency_key:, **params))
33
+ end
34
+
35
+ def delete
36
+ @client.recipients.delete(@id)
37
+ end
38
+
39
+ private
40
+
41
+ def refresh_from_recipient(recipient)
42
+ unless recipient.id == @id
43
+ raise ArgumentError, 'Recipient must be the same instance'
44
+ end
45
+
46
+ @object = recipient.object
47
+ @account_number = recipient.account_number
48
+ @account_type = recipient.account_type
49
+ @alias = recipient.alias
50
+ @created_at = recipient.created_at
51
+ @email = recipient.email
52
+ @holder_id = recipient.holder_id
53
+ @holder_name = recipient.holder_name
54
+ @holder_type = recipient.holder_type
55
+ @updated_at = recipient.updated_at
56
+ @institution = recipient.institution
57
+
58
+ self
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module Fintoc
2
- VERSION = '1.5.0'
2
+ VERSION = '1.6.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fintoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Ca Sardin
@@ -100,6 +100,7 @@ files:
100
100
  - lib/fintoc/v2/managers/entities_manager.rb
101
101
  - lib/fintoc/v2/managers/movements_manager.rb
102
102
  - lib/fintoc/v2/managers/onboardings_manager.rb
103
+ - lib/fintoc/v2/managers/recipients_manager.rb
103
104
  - lib/fintoc/v2/managers/simulate_manager.rb
104
105
  - lib/fintoc/v2/managers/transfer_batches_manager.rb
105
106
  - lib/fintoc/v2/managers/transfers_manager.rb
@@ -110,6 +111,7 @@ files:
110
111
  - lib/fintoc/v2/resources/entity.rb
111
112
  - lib/fintoc/v2/resources/movement.rb
112
113
  - lib/fintoc/v2/resources/onboarding.rb
114
+ - lib/fintoc/v2/resources/recipient.rb
113
115
  - lib/fintoc/v2/resources/transfer.rb
114
116
  - lib/fintoc/v2/resources/transfer_batch.rb
115
117
  - lib/fintoc/version.rb