modulr-api 0.0.24 → 0.0.27

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: 4c1dc8aa140f6be1d96ad9b068a6d9a1020b3c1e553aa332598915699e657f99
4
- data.tar.gz: af067bdb4a8cd588b71e86e43aa6f0bf5f1a2c9af22fe6792a6a3c6055875c05
3
+ metadata.gz: 3a8dc5b6d30c7a03695474663299d7144939699e1c02a95d2a7cf99137142912
4
+ data.tar.gz: 92f676165aff5e801db76c001da6373a56454a97dbd18901dd53a07ac0656ef3
5
5
  SHA512:
6
- metadata.gz: 34cada4ed145c82954fd8e9d2206eb7814d1fb3d4c49de1a5949ad99783c7a7dd8f47626c8a11b7a2cf6feee2b1c3c3cb548d0fd8df6e24ef3a98a98f101a07e
7
- data.tar.gz: b455c299a24441b12d3cbe79fe4c3b2d34e845a0fe32db391a1592ad60d29b77a5b51271969e4d767b7007420874eb46cd818309e59fb79f34cef2099f6552b0
6
+ metadata.gz: 93df6c1115b144cf48b6483873a336deb266698067b7cb2bb68934757bf8a81cb4ff44f67af0447fd5039708f93b1da7899989e6243d26e158bfb12aadebecb1
7
+ data.tar.gz: 684f71d53386979cfb5840d468b9d461e8f373960a06a76e961fcaa3f052d72bc4a2626c28c345e0fd30e4938b33b4de35ff3c475ac49ad217626f668519c989
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- modulr-api (0.0.24)
4
+ modulr-api (0.0.27)
5
5
  faraday (~> 1.0)
6
6
  faraday_middleware (~> 1.0)
7
7
 
@@ -5,6 +5,7 @@ module Modulr
5
5
  module Accounts
6
6
  class Identifier < Base
7
7
  map :type
8
+ map :id
8
9
  map :iban
9
10
  map :bic
10
11
  map :currency
@@ -37,6 +37,7 @@ require_relative "notifications/collection"
37
37
  require_relative "payments/payment"
38
38
  require_relative "payments/counterparty"
39
39
  require_relative "payments/details/incoming/general"
40
+ require_relative "payments/details/incoming/internal"
40
41
  require_relative "payments/details/outgoing/general"
41
42
  require_relative "payments/destination"
42
43
  require_relative "payments/collection"
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modulr
4
+ module Resources
5
+ module Payments
6
+ module Details
7
+ module Incoming
8
+ class Internal < Base
9
+ attr_reader :destination
10
+
11
+ map :sourceAccountId, :source_account_id
12
+ map :currency
13
+ map :amount
14
+ map :reference
15
+
16
+ def initialize(raw_response, attributes = {})
17
+ super(raw_response, attributes)
18
+ @destination = Destination.new(nil, attributes[:destination])
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -4,7 +4,7 @@ module Modulr
4
4
  module Resources
5
5
  module Payments
6
6
  class Payment < Base
7
- attr_reader :details
7
+ attr_reader :details, :end_to_end_id
8
8
 
9
9
  map :id, [:id, :payment_reference_id]
10
10
  map :status
@@ -12,18 +12,53 @@ module Modulr
12
12
  map :externalReference, :external_reference
13
13
  map :createdDate, :created_at
14
14
  map :approvalStatus, :approval_status
15
+ map :message, :message
15
16
 
16
17
  def initialize(raw_response, attributes = {})
17
18
  super(raw_response, attributes)
18
19
  @details = parse_details(attributes)
20
+ @end_to_end_id = if incoming_sepa?(attributes)
21
+ sepa_end_to_end_id(attributes)
22
+ elsif incoming_faster_payments?(attributes)
23
+ faster_payments_end_to_end_id(attributes)
24
+ end
25
+ end
26
+
27
+ private def incoming_sepa?(attributes)
28
+ %w[PI_SECT PI_SEPA_INST].include?(attributes[:details]&.dig(:type))
29
+ end
30
+
31
+ private def incoming_faster_payments?(attributes)
32
+ attributes[:details]&.dig(:type) == "PI_FAST"
33
+ end
34
+
35
+ private def sepa_end_to_end_id(attributes)
36
+ doc = attributes[:details].dig(:details, :payload, :docs, :doc)
37
+ return unless doc
38
+
39
+ doc_type = doc.dig(:header, :type)
40
+ key = doc_type.downcase.to_sym
41
+
42
+ case doc_type
43
+ when "IFCCTRNS" # SEPA instant
44
+ doc.dig(key, :document, :fitoFICstmrCdtTrf, :cdtTrfTxInf, :pmtId, :endToEndId)
45
+ when "FFCCTRNS" # SEPA regular
46
+ doc.dig(key, :document, :fitoFICstmrCdtTrf, :cdtTrfTxInf).first&.dig(:pmtId, :endToEndId)
47
+ end
48
+ end
49
+
50
+ private def faster_payments_end_to_end_id(attributes)
51
+ attributes[:details].dig(:details, :fpsTransaction, :paymentInfo, :endToEndId)
19
52
  end
20
53
 
21
54
  private def parse_details(attributes)
22
55
  details = attributes[:details]
23
56
 
24
- case details&.dig(:type)
57
+ case details&.dig(:type) || details&.dig(:destinationType)
25
58
  when "PI_SECT", "PI_SEPA_INST", "PI_FAST", "PI_REV"
26
59
  Details::Incoming::General.new(nil, details)
60
+ when "ACCOUNT"
61
+ Details::Incoming::Internal.new(nil, details)
27
62
  else
28
63
  Details::Outgoing::General.new(nil, details)
29
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modulr
4
- VERSION = "0.0.24"
4
+ VERSION = "0.0.27"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulr-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aitor García Rey
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-05 00:00:00.000000000 Z
11
+ date: 2023-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -226,6 +226,7 @@ files:
226
226
  - lib/modulr/resources/payments/counterparty.rb
227
227
  - lib/modulr/resources/payments/destination.rb
228
228
  - lib/modulr/resources/payments/details/incoming/general.rb
229
+ - lib/modulr/resources/payments/details/incoming/internal.rb
229
230
  - lib/modulr/resources/payments/details/outgoing/general.rb
230
231
  - lib/modulr/resources/payments/payment.rb
231
232
  - lib/modulr/resources/transactions/collection.rb
@@ -241,7 +242,7 @@ metadata:
241
242
  source_code_uri: https://github.com/devengoapp/modulr-ruby
242
243
  changelog_uri: https://github.com/devengoapp/modulr-ruby/blob/master/CHANGELOG.md
243
244
  rubygems_mfa_required: 'true'
244
- post_install_message:
245
+ post_install_message:
245
246
  rdoc_options: []
246
247
  require_paths:
247
248
  - lib
@@ -257,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
258
  version: '0'
258
259
  requirements: []
259
260
  rubygems_version: 3.4.10
260
- signing_key:
261
+ signing_key:
261
262
  specification_version: 4
262
263
  summary: Ruby client for Modulr Finance API.
263
264
  test_files: []