issuer_response_codes 0.3.7 → 0.3.9
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 +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.rubocop.yml +30 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +11 -1
- data/Gemfile +9 -6
- data/Gemfile.lock +67 -34
- data/README.md +5 -0
- data/bin/tapioca +27 -0
- data/bin/test +7 -0
- data/issuer_response_codes.gemspec +3 -1
- data/lib/issuer_response_codes/code/behaviour/dsl.rb +45 -0
- data/lib/issuer_response_codes/code/behaviour.rb +25 -0
- data/lib/issuer_response_codes/code.rb +40 -21
- data/lib/issuer_response_codes/context.rb +11 -15
- data/lib/issuer_response_codes/locale_library.rb +12 -29
- data/lib/issuer_response_codes/tds_code.rb +10 -7
- data/lib/issuer_response_codes/version.rb +2 -2
- data/lib/issuer_response_codes.rb +7 -6
- data/lib/locale/cs.yml +300 -0
- data/lib/locale/da.yml +0 -12
- data/lib/locale/de.yml +0 -25
- data/lib/locale/ee.yml +0 -12
- data/lib/locale/en.yml +0 -25
- data/lib/locale/es.yml +1 -28
- data/lib/locale/fi.yml +1 -28
- data/lib/locale/fr.yml +1 -28
- data/lib/locale/hr.yml +1 -28
- data/lib/locale/hu.yml +300 -0
- data/lib/locale/it.yml +1 -30
- data/lib/locale/ja.yml +0 -25
- data/lib/locale/lt.yml +0 -12
- data/lib/locale/lv.yml +0 -12
- data/lib/locale/nl.yml +1 -28
- data/lib/locale/pl.yml +2 -34
- data/lib/locale/pt.yml +1 -28
- data/lib/locale/ru.yml +0 -25
- data/lib/locale/sk.yml +300 -0
- data/lib/locale/sv.yml +0 -12
- data/lib/locale/uk.yml +0 -25
- data/sorbet/config +7 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/minitest.rbi +119 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/ast@2.4.3.rbi +585 -0
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +86 -0
- data/sorbet/rbi/gems/minitest@5.25.5.rbi +1547 -0
- data/sorbet/rbi/gems/parallel@1.27.0.rbi +291 -0
- data/sorbet/rbi/gems/racc@1.8.1.rbi +160 -0
- data/sorbet/rbi/gems/rake@12.3.3.rbi +3020 -0
- data/sorbet/rbi/gems/rubocop-espago@1.1.8.rbi +9 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
- data/sorbet/rbi/gems/unicode-display_width@3.1.4.rbi +132 -0
- data/sorbet/rbi/gems/unicode-emoji@4.0.4.rbi +251 -0
- data/sorbet/rbi/todo.rbi +7 -0
- data/sorbet/tapioca/config.yml +30 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +42 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57404d70d3b177d54e041082138e0f1da68ece526c641996261937c29eb3b963
|
4
|
+
data.tar.gz: 347d34412b0c749eeea51a2d9024ccd2a6136fa98e8b74803113e7a9c45ebc65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaf9ece885f836b2bf9966273ac29f0eec1627f2d0f553e71208bc8867c9dcfae18576035618cafb3e7142940faf5e090376a6df1bec8b1a30fb0db4a9c3f825
|
7
|
+
data.tar.gz: 2dc3085345ebd7b9643171c92924607d1666c490fea2396b3381a709390b1714b7e41705eac30021c988eaac57613981c1207894d0aa1ed77a24c7ed0c71e63f
|
data/.github/workflows/ci.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
inherit_gem:
|
2
|
-
rubocop-espago:
|
2
|
+
rubocop-espago: sorbet.yml
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
TargetRubyVersion: 3.
|
5
|
+
TargetRubyVersion: 3.2
|
6
|
+
|
7
|
+
Sorbet/EnforceSignatures:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Layout/LeadingCommentSpace:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Sorbet/HasSigil:
|
14
|
+
AutoCorrect: false
|
15
|
+
|
16
|
+
Style/NumericPredicate:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Lint/EmptyWhen:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/ArrayFirstLast:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/FetchEnvVar:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Sorbet/ForbidSig:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/ImplicitRuntimeError:
|
32
|
+
Enabled: false
|
33
|
+
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.4.
|
1
|
+
3.4.4
|
data/CHANGELOG.md
CHANGED
@@ -5,9 +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
|
+
## [0.3.9] - 2025.06.25
|
9
|
+
|
10
|
+
- Add sorbet
|
11
|
+
- Remove support for Ruby 3.1 and 3.2
|
12
|
+
- Add `IssuerResponseCodes::Code#behaviour_code`
|
13
|
+
|
14
|
+
## [0.3.8] - 2025.05.05
|
15
|
+
|
16
|
+
Add `cs`, `sk`, `hu` translations.
|
17
|
+
|
8
18
|
## [0.3.7] - 2025.04.28
|
9
19
|
|
10
|
-
Update the 82 issuer response code to be suitable for Mastercard.
|
20
|
+
Update the `82` issuer response code to be suitable for Mastercard.
|
11
21
|
|
12
22
|
[Diff](https://github.com/espago/issuer_response_codes/compare/v0.3.6...espago:issuer_response_codes:v0.3.7)
|
13
23
|
|
data/Gemfile
CHANGED
@@ -5,9 +5,12 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in issuer_response_codes.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem 'bundler', '~> 2.
|
9
|
-
gem '
|
10
|
-
gem 'minitest', '~> 5.
|
11
|
-
gem 'rake', '~> 12.
|
12
|
-
gem 'rubocop', '~> 1.
|
13
|
-
gem 'rubocop-espago', '~> 1.
|
8
|
+
gem 'bundler', '~> 2.6' # library manager
|
9
|
+
gem 'byebug', '~> 12.0' # debugger
|
10
|
+
gem 'minitest', '~> 5.25' # test framework
|
11
|
+
gem 'rake', '~> 12.3' # automation
|
12
|
+
gem 'rubocop', '~> 1.77' # linter
|
13
|
+
gem 'rubocop-espago', '~> 1.1' # linter config
|
14
|
+
gem 'rubocop-sorbet', '~> 0.10' # linter config for sorbet
|
15
|
+
gem 'sorbet', '~> 0.5' # static typechecker
|
16
|
+
gem 'tapioca', '~> 0.17', require: false # RBI generator
|
data/Gemfile.lock
CHANGED
@@ -1,45 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
issuer_response_codes (0.3.
|
4
|
+
issuer_response_codes (0.3.9)
|
5
|
+
sorbet-runtime (~> 0.5)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
ast (2.4.3)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
irb (1.15.2)
|
16
|
-
pp (>= 0.6.0)
|
17
|
-
rdoc (>= 4.0.0)
|
18
|
-
reline (>= 0.4.2)
|
19
|
-
json (2.11.3)
|
20
|
-
language_server-protocol (3.17.0.4)
|
11
|
+
benchmark (0.4.1)
|
12
|
+
byebug (12.0.0)
|
13
|
+
erubi (1.13.1)
|
14
|
+
json (2.12.2)
|
15
|
+
language_server-protocol (3.17.0.5)
|
21
16
|
lint_roller (1.1.0)
|
17
|
+
logger (1.7.0)
|
22
18
|
minitest (5.25.5)
|
19
|
+
netrc (0.11.0)
|
23
20
|
parallel (1.27.0)
|
24
21
|
parser (3.3.8.0)
|
25
22
|
ast (~> 2.4.1)
|
26
23
|
racc
|
27
|
-
pp (0.6.2)
|
28
|
-
prettyprint
|
29
|
-
prettyprint (0.2.0)
|
30
24
|
prism (1.4.0)
|
31
|
-
psych (5.2.3)
|
32
|
-
date
|
33
|
-
stringio
|
34
25
|
racc (1.8.1)
|
35
26
|
rainbow (3.1.1)
|
36
27
|
rake (12.3.3)
|
37
|
-
|
38
|
-
|
28
|
+
rbi (0.3.6)
|
29
|
+
prism (~> 1.0)
|
30
|
+
rbs (>= 3.4.4)
|
31
|
+
rbs (4.0.0.dev.4)
|
32
|
+
logger
|
33
|
+
prism (>= 1.3.0)
|
39
34
|
regexp_parser (2.10.0)
|
40
|
-
|
41
|
-
|
42
|
-
rubocop (1.
|
35
|
+
require-hooks (0.2.2)
|
36
|
+
rexml (3.4.1)
|
37
|
+
rubocop (1.77.0)
|
43
38
|
json (~> 2.3)
|
44
39
|
language_server-protocol (~> 3.17.0.2)
|
45
40
|
lint_roller (~> 1.1.0)
|
@@ -47,31 +42,69 @@ GEM
|
|
47
42
|
parser (>= 3.3.0.2)
|
48
43
|
rainbow (>= 2.2.2, < 4.0)
|
49
44
|
regexp_parser (>= 2.9.3, < 3.0)
|
50
|
-
rubocop-ast (>= 1.
|
45
|
+
rubocop-ast (>= 1.45.1, < 2.0)
|
51
46
|
ruby-progressbar (~> 1.7)
|
52
47
|
unicode-display_width (>= 2.4.0, < 4.0)
|
53
|
-
rubocop-ast (1.
|
48
|
+
rubocop-ast (1.45.1)
|
54
49
|
parser (>= 3.3.7.2)
|
55
50
|
prism (~> 1.4)
|
56
51
|
rubocop-espago (1.1.8)
|
57
52
|
rubocop
|
53
|
+
rubocop-sorbet (0.10.5)
|
54
|
+
lint_roller
|
55
|
+
rubocop (>= 1.75.2)
|
58
56
|
ruby-progressbar (1.13.0)
|
59
|
-
|
57
|
+
sorbet (0.5.12201)
|
58
|
+
sorbet-static (= 0.5.12201)
|
59
|
+
sorbet-runtime (0.5.12201)
|
60
|
+
sorbet-static (0.5.12201-universal-darwin)
|
61
|
+
sorbet-static (0.5.12201-x86_64-linux)
|
62
|
+
sorbet-static-and-runtime (0.5.12201)
|
63
|
+
sorbet (= 0.5.12201)
|
64
|
+
sorbet-runtime (= 0.5.12201)
|
65
|
+
spoom (1.7.4)
|
66
|
+
erubi (>= 1.10.0)
|
67
|
+
prism (>= 0.28.0)
|
68
|
+
rbi (>= 0.3.3)
|
69
|
+
rbs (>= 4.0.0.dev.4)
|
70
|
+
rexml (>= 3.2.6)
|
71
|
+
sorbet-static-and-runtime (>= 0.5.10187)
|
72
|
+
thor (>= 0.19.2)
|
73
|
+
tapioca (0.17.4)
|
74
|
+
benchmark
|
75
|
+
bundler (>= 2.2.25)
|
76
|
+
netrc (>= 0.11.0)
|
77
|
+
parallel (>= 1.21.0)
|
78
|
+
rbi (>= 0.3.1)
|
79
|
+
require-hooks (>= 0.2.2)
|
80
|
+
sorbet-static-and-runtime (>= 0.5.11087)
|
81
|
+
spoom (>= 1.7.0)
|
82
|
+
thor (>= 1.2.0)
|
83
|
+
yard-sorbet
|
84
|
+
thor (1.3.2)
|
60
85
|
unicode-display_width (3.1.4)
|
61
86
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
62
87
|
unicode-emoji (4.0.4)
|
88
|
+
yard (0.9.37)
|
89
|
+
yard-sorbet (0.9.0)
|
90
|
+
sorbet-runtime
|
91
|
+
yard
|
63
92
|
|
64
93
|
PLATFORMS
|
65
|
-
|
94
|
+
arm64-darwin-24
|
95
|
+
x86_64-linux
|
66
96
|
|
67
97
|
DEPENDENCIES
|
68
|
-
bundler (~> 2.
|
69
|
-
|
98
|
+
bundler (~> 2.6)
|
99
|
+
byebug (~> 12.0)
|
70
100
|
issuer_response_codes!
|
71
|
-
minitest (~> 5.
|
72
|
-
rake (~> 12.
|
73
|
-
rubocop (~> 1.
|
74
|
-
rubocop-espago (~> 1.
|
101
|
+
minitest (~> 5.25)
|
102
|
+
rake (~> 12.3)
|
103
|
+
rubocop (~> 1.77)
|
104
|
+
rubocop-espago (~> 1.1)
|
105
|
+
rubocop-sorbet (~> 0.10)
|
106
|
+
sorbet (~> 0.5)
|
107
|
+
tapioca (~> 0.17)
|
75
108
|
|
76
109
|
BUNDLED WITH
|
77
|
-
2.6.
|
110
|
+
2.6.9
|
data/README.md
CHANGED
data/bin/tapioca
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'tapioca' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("tapioca", "tapioca")
|
data/bin/test
ADDED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
'A simple Ruby gem which provides Issuer Response Code descriptions and suggestions for cardholders and merchants'
|
14
14
|
spec.homepage = 'https://github.com/espago/issuer_response_codes'
|
15
15
|
spec.license = 'MIT'
|
16
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 3.
|
16
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.2')
|
17
17
|
|
18
18
|
spec.metadata['homepage_uri'] = spec.homepage
|
19
19
|
spec.metadata['source_code_uri'] = 'https://github.com/espago/issuer_response_codes'
|
@@ -27,4 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
30
|
+
|
31
|
+
spec.add_dependency 'sorbet-runtime', '~> 0.5'
|
30
32
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module IssuerResponseCodes
|
5
|
+
class Code
|
6
|
+
class Behaviour # rubocop:disable Style/StaticClass,Style/Documentation
|
7
|
+
@map = {} #: Hash[String, Symbol]
|
8
|
+
|
9
|
+
class << self
|
10
|
+
#: (Array[String]) -> void
|
11
|
+
def abort_behaviour(codes)
|
12
|
+
behaviour(:abort, codes)
|
13
|
+
end
|
14
|
+
|
15
|
+
#: (Array[String]) -> void
|
16
|
+
def retry_later_behaviour(codes)
|
17
|
+
behaviour(:retry_later, codes)
|
18
|
+
end
|
19
|
+
|
20
|
+
#: (Array[String]) -> void
|
21
|
+
def sca_required_behaviour(codes)
|
22
|
+
behaviour(:sca_required, codes)
|
23
|
+
end
|
24
|
+
|
25
|
+
#: (Array[String]) -> void
|
26
|
+
def invalid_card_behaviour(codes)
|
27
|
+
behaviour(:invalid_card, codes)
|
28
|
+
end
|
29
|
+
|
30
|
+
#: (Array[String]) -> void
|
31
|
+
def invalid_amount_behaviour(codes)
|
32
|
+
behaviour(:invalid_amount, codes)
|
33
|
+
end
|
34
|
+
|
35
|
+
#: (Symbol, Array[String]) -> void
|
36
|
+
def behaviour(type, codes)
|
37
|
+
codes.each do |code|
|
38
|
+
@map[code] = type
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'behaviour/dsl'
|
5
|
+
|
6
|
+
module IssuerResponseCodes
|
7
|
+
class Code
|
8
|
+
# Defines behaviour codes for issuer response codes
|
9
|
+
class Behaviour
|
10
|
+
class << self
|
11
|
+
#: (String) -> Symbol
|
12
|
+
def [](code)
|
13
|
+
@map.fetch(code, :retry)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
abort_behaviour %w[46 R0 R1 R3 B1A B04 B14 B15 B41 B43 B54 B65]
|
19
|
+
retry_later_behaviour %w[22 24 25 26 81 84 00 E3 E4 E5 Q2 91]
|
20
|
+
sca_required_behaviour %w[1A 65 O5]
|
21
|
+
invalid_card_behaviour %w[04 07 12 14 15 41 43 57]
|
22
|
+
invalid_amount_behaviour %w[61 13]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,18 +1,27 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
4
|
+
require_relative 'code/behaviour'
|
5
|
+
|
3
6
|
module IssuerResponseCodes
|
4
7
|
# ISO-8583 Response code.
|
5
8
|
class Code
|
6
|
-
|
9
|
+
#: String
|
10
|
+
attr_reader :id
|
11
|
+
#: Symbol
|
12
|
+
attr_reader :target
|
13
|
+
#: Symbol
|
14
|
+
attr_reader :locale
|
15
|
+
#: bool
|
16
|
+
attr_reader :fraud_notice
|
17
|
+
|
18
|
+
FRAUDULENT_IDS = %w[04 B04 07 12 14 B14 15 B15 41 B41 43 B43 54 B54 57 59 63 R0 R1 R3].to_set #: Set[String]
|
7
19
|
|
8
|
-
NOT_PROVIDED = ::Object.new
|
20
|
+
NOT_PROVIDED = ::Object.new #: as untyped
|
9
21
|
|
10
|
-
|
11
|
-
# @param target [Symbol]
|
12
|
-
# @param locale [Symbol]
|
13
|
-
# @param fraud_notice [Boolean, Object]
|
22
|
+
#: (id: String | Symbol, ?target: Symbol, ?locale: Symbol, ?fraud_notice: bool) -> void
|
14
23
|
def initialize(id:, target: :merchant, locale: :en, fraud_notice: NOT_PROVIDED)
|
15
|
-
@id = id
|
24
|
+
@id = id.to_s
|
16
25
|
@target = target
|
17
26
|
@locale = locale
|
18
27
|
|
@@ -24,37 +33,47 @@ module IssuerResponseCodes
|
|
24
33
|
return
|
25
34
|
end
|
26
35
|
|
27
|
-
@fraud_notice = target == :merchant
|
36
|
+
@fraud_notice = target == :merchant #: bool
|
28
37
|
end
|
29
38
|
|
30
|
-
|
39
|
+
#: -> String
|
31
40
|
def humanize
|
32
41
|
"#{reason} #{behaviour}"
|
33
42
|
end
|
34
43
|
alias description humanize
|
35
44
|
|
36
|
-
|
45
|
+
#: -> String
|
37
46
|
def reason
|
38
|
-
LOCALE_LIBRARY[
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
LOCALE_LIBRARY[
|
48
|
+
path: id,
|
49
|
+
scope: "issuer_response_codes.targeted.#{target}",
|
50
|
+
locale: locale,
|
51
|
+
default: :unknown,
|
52
|
+
]
|
42
53
|
end
|
43
54
|
|
44
|
-
|
55
|
+
#: -> String
|
45
56
|
def behaviour
|
46
|
-
behaviour_str = LOCALE_LIBRARY[
|
47
|
-
|
48
|
-
|
49
|
-
|
57
|
+
behaviour_str = LOCALE_LIBRARY[
|
58
|
+
path: id,
|
59
|
+
scope: 'issuer_response_codes.behaviour',
|
60
|
+
locale: locale,
|
61
|
+
default: :unknown,
|
62
|
+
]
|
63
|
+
|
50
64
|
return behaviour_str unless fraud_notice && fraudulent_code?
|
51
65
|
|
52
66
|
"#{behaviour_str} #{LOCALE_LIBRARY[path: 'issuer_response_codes.fraud_notice']}"
|
53
67
|
end
|
54
68
|
|
55
|
-
|
69
|
+
#: -> Symbol
|
70
|
+
def behaviour_code
|
71
|
+
Behaviour[id]
|
72
|
+
end
|
73
|
+
|
74
|
+
#: -> bool
|
56
75
|
def fraudulent_code?
|
57
|
-
|
76
|
+
FRAUDULENT_IDS.include?(id)
|
58
77
|
end
|
59
78
|
|
60
79
|
end
|
@@ -1,17 +1,21 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module IssuerResponseCodes
|
4
5
|
# Context stores default settings for retrieving codes.
|
5
6
|
class Context
|
6
|
-
|
7
|
+
#: Symbol
|
8
|
+
attr_reader :default_target
|
9
|
+
#: Symbol
|
10
|
+
attr_reader :default_locale
|
11
|
+
#: bool
|
12
|
+
attr_reader :fraud_notice_by_default
|
7
13
|
|
8
|
-
NOT_PROVIDED = ::Object.new
|
14
|
+
NOT_PROVIDED = ::Object.new #: as untyped
|
9
15
|
|
10
|
-
# @param default_target [Symbol]
|
11
|
-
# @param default_locale [Symbol]
|
12
|
-
# @param fraud_notice_by_default [Boolean, Object]
|
13
16
|
# @raise [IllegalLocale]
|
14
17
|
# @raise [IllegalTarget]
|
18
|
+
#: (?default_target: Symbol, ?default_locale: Symbol, ?fraud_notice_by_default: bool) -> void
|
15
19
|
def initialize(default_target: :merchant, default_locale: :en, fraud_notice_by_default: NOT_PROVIDED)
|
16
20
|
@default_target = default_target
|
17
21
|
@default_locale = default_locale
|
@@ -27,20 +31,12 @@ module IssuerResponseCodes
|
|
27
31
|
@fraud_notice_by_default = default_target == :merchant
|
28
32
|
end
|
29
33
|
|
30
|
-
|
31
|
-
# @param target [Symbol]
|
32
|
-
# @param locale [Symbol]
|
33
|
-
# @param fraud_notice [Boolean, Object]
|
34
|
-
# @return [Code]
|
34
|
+
#: (id: String | Symbol, ?target: Symbol, ?locale: Symbol, ?fraud_notice: bool) -> Code
|
35
35
|
def code(id:, target: default_target, locale: default_locale, fraud_notice: fraud_notice_by_default)
|
36
36
|
Code.new(id: id, target: target, locale: locale, fraud_notice: fraud_notice)
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
# @param target [Symbol]
|
41
|
-
# @param locale [Symbol]
|
42
|
-
# @param fraud_notice [Boolean, Object]
|
43
|
-
# @return [TdsCode]
|
39
|
+
#: (id: String | Symbol, ?target: Symbol, ?locale: Symbol, ?fraud_notice: bool) -> TdsCode
|
44
40
|
def tds_code(id:, target: default_target, locale: default_locale, fraud_notice: fraud_notice_by_default)
|
45
41
|
TdsCode.new(id: id, target: target, locale: locale, fraud_notice: fraud_notice)
|
46
42
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'yaml'
|
@@ -7,6 +8,7 @@ module IssuerResponseCodes
|
|
7
8
|
class LocaleLibrary
|
8
9
|
attr_reader :locale_hash
|
9
10
|
|
11
|
+
#: -> void
|
10
12
|
def initialize
|
11
13
|
@locale_hash = {}
|
12
14
|
|
@@ -15,20 +17,14 @@ module IssuerResponseCodes
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
|
19
|
-
# @param locale [Symbol]
|
20
|
-
# @param scope [String]
|
21
|
-
# @param default [Symbol, String, nil]
|
22
|
-
# @return [String, Hash, nil]
|
20
|
+
#: (path: String | Symbol, ?locale: Symbol, ?scope: String, ?default: Symbol | String?) -> untyped
|
23
21
|
def dig(path:, locale: :en, scope: '', default: nil)
|
24
22
|
__dig__(path: path, locale: locale, scope: scope, default: default)
|
25
23
|
end
|
26
24
|
alias [] dig
|
27
25
|
|
28
|
-
|
29
|
-
# @return [Hash{SYmbol => Hash{Symbol => Object}}]
|
26
|
+
#: (?locale: Symbol) -> Hash[Symbol, Hash[Symbol, untyped]]
|
30
27
|
def issuer_response_codes(locale: :en)
|
31
|
-
fraudulent_codes = locale_hash.dig(locale, :issuer_response_codes, :fraudulent_codes)
|
32
28
|
behaviours = locale_hash.dig(locale, :issuer_response_codes, :behaviour)
|
33
29
|
cardholder_reasons = locale_hash.dig(locale, :issuer_response_codes, :targeted, :cardholder)
|
34
30
|
merchant_reasons = locale_hash.dig(locale, :issuer_response_codes, :targeted, :merchant)
|
@@ -40,16 +36,14 @@ module IssuerResponseCodes
|
|
40
36
|
merchant_reason: merchant_reason,
|
41
37
|
cardholder_reason: cardholder_reasons[code],
|
42
38
|
behaviour: behaviours[code],
|
43
|
-
fraudulent:
|
39
|
+
fraudulent: Code::FRAUDULENT_IDS.include?(code.to_s),
|
44
40
|
},
|
45
41
|
]
|
46
42
|
end
|
47
43
|
end
|
48
44
|
|
49
|
-
|
50
|
-
# @return [Hash{Symbol => Hash{Symbol => Object}}]
|
45
|
+
#: (?locale: Symbol) -> Hash[Symbol, Hash[Symbol, untyped]]
|
51
46
|
def tds_codes(locale: :en)
|
52
|
-
fraudulent_codes = locale_hash.dig(locale, :tds_status_codes, :fraudulent_codes)
|
53
47
|
behaviours = locale_hash.dig(locale, :tds_status_codes, :behaviour)
|
54
48
|
cardholder_reasons = locale_hash.dig(locale, :tds_status_codes, :targeted, :cardholder)
|
55
49
|
merchant_reasons = locale_hash.dig(locale, :tds_status_codes, :targeted, :merchant)
|
@@ -61,7 +55,7 @@ module IssuerResponseCodes
|
|
61
55
|
merchant_reason: merchant_reason,
|
62
56
|
cardholder_reason: cardholder_reasons[code],
|
63
57
|
behaviour: behaviours[code],
|
64
|
-
fraudulent:
|
58
|
+
fraudulent: TdsCode::FRAUDULENT_IDS.include?(code.to_s),
|
65
59
|
},
|
66
60
|
]
|
67
61
|
end
|
@@ -69,11 +63,7 @@ module IssuerResponseCodes
|
|
69
63
|
|
70
64
|
private
|
71
65
|
|
72
|
-
|
73
|
-
# @param locale [Symbol]
|
74
|
-
# @param scope [String]
|
75
|
-
# @param default [Symbol, String, nil]
|
76
|
-
# @return [String, Hash, nil]
|
66
|
+
#: (path: String | Symbol, ?locale: Symbol, ?scope: String, ?default: Symbol | String?) -> untyped
|
77
67
|
def __dig__(path:, locale: :en, scope: '', default: nil)
|
78
68
|
result = dig_provided_path(path, scope, locale)
|
79
69
|
return result if result || !default
|
@@ -83,10 +73,6 @@ module IssuerResponseCodes
|
|
83
73
|
dig_provided_path(default.to_s, scope, locale)
|
84
74
|
end
|
85
75
|
|
86
|
-
# @param path [String]
|
87
|
-
# @param locale [Symbol]
|
88
|
-
# @param scope [String]
|
89
|
-
# @return [String, Hash, nil]
|
90
76
|
def dig_provided_path(path, scope, locale)
|
91
77
|
return if path.nil? || path.empty?
|
92
78
|
|
@@ -97,8 +83,7 @@ module IssuerResponseCodes
|
|
97
83
|
locale_hash.dig(*full_path_array)
|
98
84
|
end
|
99
85
|
|
100
|
-
|
101
|
-
# @return [void]
|
86
|
+
#: (Symbol | String) -> void
|
102
87
|
def load_locale(name)
|
103
88
|
raw_hash = load_yaml(::File.join(::File.dirname(::File.expand_path(__FILE__)), "../locale/#{name}.yml"))
|
104
89
|
name = name.to_sym
|
@@ -106,9 +91,8 @@ module IssuerResponseCodes
|
|
106
91
|
@locale_hash[name] = raw_hash[name]
|
107
92
|
end
|
108
93
|
|
109
|
-
if ::Psych::VERSION > '4'
|
110
|
-
|
111
|
-
# @return [Hash{Symbol => Object}]
|
94
|
+
if ::Psych::VERSION > T.unsafe('4') # rubocop:disable Sorbet/ForbidTUnsafe,Style/YodaCondition
|
95
|
+
#: (String) -> Hash[Symbol, untyped]
|
112
96
|
def load_yaml(file_path)
|
113
97
|
::YAML.load_file(
|
114
98
|
file_path,
|
@@ -117,8 +101,7 @@ module IssuerResponseCodes
|
|
117
101
|
)
|
118
102
|
end
|
119
103
|
else
|
120
|
-
|
121
|
-
# @return [Hash{Symbol => Object}]
|
104
|
+
#: (String) -> Hash[Symbol, untyped]
|
122
105
|
def load_yaml(file_path)
|
123
106
|
::YAML.load_file(
|
124
107
|
file_path,
|