modulr-api 0.0.25 → 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: 23c622f4bb224ae3aa56fcf4bdb541c7685647652c839fb3dbfac5de5cb0cbb2
4
- data.tar.gz: 0b400b25d04689905dcbbbf0794008c5d592739d729eae06e28e7fbd07693004
3
+ metadata.gz: 3a8dc5b6d30c7a03695474663299d7144939699e1c02a95d2a7cf99137142912
4
+ data.tar.gz: 92f676165aff5e801db76c001da6373a56454a97dbd18901dd53a07ac0656ef3
5
5
  SHA512:
6
- metadata.gz: 99a99459d32a6574236d7e2382060ae22b7619b0a665a88aef30a7d223afc7102d3fa6d8e82251cbb0e40e9a7a56fb3d037b7cdecba5f8d69af3009209fad92e
7
- data.tar.gz: c5c58c43b9be20d922dbcd43baa41056d4760756e268f486822e8f29eaf7d9fa4126eaf59e6e0aaf10dcbaeb3c2993b811d5791f291074abee055ff5136d2807
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.25)
4
+ modulr-api (0.0.27)
5
5
  faraday (~> 1.0)
6
6
  faraday_middleware (~> 1.0)
7
7
 
@@ -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,10 +12,43 @@ 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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modulr
4
- VERSION = "0.0.25"
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.25
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-17 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
@@ -242,7 +242,7 @@ metadata:
242
242
  source_code_uri: https://github.com/devengoapp/modulr-ruby
243
243
  changelog_uri: https://github.com/devengoapp/modulr-ruby/blob/master/CHANGELOG.md
244
244
  rubygems_mfa_required: 'true'
245
- post_install_message:
245
+ post_install_message:
246
246
  rdoc_options: []
247
247
  require_paths:
248
248
  - lib
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
258
  version: '0'
259
259
  requirements: []
260
260
  rubygems_version: 3.4.10
261
- signing_key:
261
+ signing_key:
262
262
  specification_version: 4
263
263
  summary: Ruby client for Modulr Finance API.
264
264
  test_files: []