eml 2.0.0 → 2.1.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: e01fb29821c0e3e1bb2b2ba438e5dfc662162a398d187904adf1a52725a11936
4
- data.tar.gz: a7d4d70f1ad4e28f01b60df90fb5937205985f36b32f8c0d7cbf73895d2e306e
3
+ metadata.gz: c43c6dc3d86873574c0c3cf60f887df5770f6a900a1054c585bebe7117eb3592
4
+ data.tar.gz: 27d3f3b09e3fb03d2037f983aef3760b3f41c16a09510ddaad705bc1d922ae9a
5
5
  SHA512:
6
- metadata.gz: edd3ebfb85dd29364c3e1942f49aac8417feb5bb99f4c6e14ece9f014e6d77de656838c9158077cda051f4581cc18c3e47861f334aaf10b3ae6ca8c4dd631338
7
- data.tar.gz: b2f96353fce3d485aa5663ec73fd36d11884e9db5c3848f0c2700dd15a9051f0e4f312a34dc51a46bdf5b2945599134a28b7b72fb760f182567382ad1e2cb5e2
6
+ metadata.gz: 77d7ba1a43c24e0c706dad9e6cffce301a4c56a3e1d8427bb708f7543a024196c9378d2b9992e1753bdc1112b684e1d53a94233bd21b0878b5c2e64c0e060a48
7
+ data.tar.gz: aca4aee2a57275ca8d69c2f8c4391544eb3bcab6770693e0e4ef24d471e97eaea70edc433953b7722ea68e61061ef3458735d67da6080fe1ff87ac09b4360aae
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  .env
2
2
  coverage
3
3
  Gemfile.lock
4
+ pkg
4
5
  spec/examples.txt
5
6
  spec/vcr_cassettes
data/.rubocop.yml CHANGED
@@ -4,6 +4,8 @@ require:
4
4
 
5
5
  AllCops:
6
6
  TargetRubyVersion: 2.6.4
7
+ Exclude:
8
+ - bin/**/*
7
9
 
8
10
  Layout/AlignParameters:
9
11
  EnforcedStyle: with_fixed_indentation
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/eml.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = "https://github.com/MorningCoffeeDev/eml_ruby"
17
17
  spec.license = "MIT"
18
18
 
19
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
20
  `git ls-files -z`.split("\x0").
21
21
  reject { |f| f.match(%r{^(test|spec|features)/}) }
22
22
  end
@@ -16,27 +16,27 @@ module EML
16
16
  def initialize(message = nil, response = nil)
17
17
  super(message)
18
18
 
19
- @response = T.let(response, EML::Response)
19
+ @response = T.let(response, T.nilable(EML::Response))
20
20
  end
21
21
 
22
- sig { returns(String) }
22
+ sig { returns(T.nilable(String)) }
23
23
  def http_body
24
- @response.error || @response.body.to_s
24
+ @response&.error || @response&.body&.to_s
25
25
  end
26
26
 
27
- sig { returns(T::Hash[Symbol, String]) }
27
+ sig { returns(T.nilable(T::Hash[Symbol, String])) }
28
28
  def http_headers
29
- @response.headers
29
+ @response&.headers
30
30
  end
31
31
 
32
- sig { returns(Integer) }
32
+ sig { returns(T.nilable(Integer)) }
33
33
  def http_status
34
- @response.status
34
+ @response&.http_status
35
35
  end
36
36
 
37
- sig { returns(String) }
37
+ sig { returns(T.nilable(String)) }
38
38
  def url
39
- @response.url.to_s
39
+ @response&.url&.to_s
40
40
  end
41
41
  end
42
42
  end
@@ -16,7 +16,7 @@ module EML
16
16
  ).returns(String)
17
17
  end
18
18
  def self.call(username, password, prefix: "")
19
- new(username, password, prefix).call
19
+ new(username, password, prefix: prefix).call
20
20
  end
21
21
 
22
22
  sig do
@@ -26,10 +26,10 @@ module EML
26
26
  prefix: String
27
27
  ).void
28
28
  end
29
- def initialize(username, password, prefix)
30
- @username = username
31
- @password = password
32
- @prefix = prefix
29
+ def initialize(username, password, prefix: "")
30
+ @username = T.let(username, String)
31
+ @password = T.let(password, String)
32
+ @prefix = T.let(prefix, String)
33
33
  end
34
34
 
35
35
  sig { returns(String) }
@@ -8,7 +8,7 @@ module EML
8
8
 
9
9
  sig do
10
10
  params(
11
- auth_token: String,
11
+ auth_token: T.nilable(String),
12
12
  username: String,
13
13
  password: String
14
14
  ).returns(T::Boolean)
@@ -19,15 +19,15 @@ module EML
19
19
 
20
20
  sig do
21
21
  params(
22
- auth_token: String,
22
+ auth_token: T.nilable(String),
23
23
  username: String,
24
24
  password: String
25
25
  ).void
26
26
  end
27
27
  def initialize(auth_token, username, password)
28
- @auth_token = auth_token
29
- @username = username
30
- @password = password
28
+ @auth_token = T.let(auth_token || "", String)
29
+ @username = T.let(username, String)
30
+ @password = T.let(password, String)
31
31
  end
32
32
 
33
33
  sig { returns(T::Boolean) }
@@ -40,6 +40,7 @@ module EML
40
40
 
41
41
  private
42
42
 
43
+ sig { returns(String) }
43
44
  def parse_auth_token
44
45
  @auth_token.sub(/^[^\s]+\s/, "")
45
46
  end
@@ -12,8 +12,8 @@ module EML
12
12
 
13
13
  sig { params(comparison: String, expected: String).void }
14
14
  def initialize(comparison, expected)
15
- @comparison = comparison
16
- @expected = expected
15
+ @comparison = T.let(comparison, String)
16
+ @expected = T.let(expected, String)
17
17
  end
18
18
 
19
19
  sig { returns(T::Boolean) }
@@ -22,8 +22,8 @@ module EML
22
22
 
23
23
  result = 0
24
24
 
25
- Hash[[@comparison.bytes, @expected.bytes].transpose].
26
- each { |x, y| result |= x ^ y }
25
+ transposed = [@comparison.bytes, @expected.bytes].transpose
26
+ Hash[transposed].each { |x, y| result |= x ^ y }
27
27
 
28
28
  result.zero?
29
29
  end
@@ -5,6 +5,10 @@ module EML
5
5
  class EndpointClass
6
6
  extend T::Sig
7
7
 
8
+ sig do
9
+ params(class_type: String, resource_class: T.untyped, endpoint: String).
10
+ returns(T.untyped)
11
+ end
8
12
  def self.call(class_type:, resource_class:, endpoint:)
9
13
  new(
10
14
  class_type: class_type,
@@ -13,18 +17,25 @@ module EML
13
17
  ).call
14
18
  end
15
19
 
20
+ sig do
21
+ params(class_type: String, resource_class: T.untyped, endpoint: String).
22
+ void
23
+ end
16
24
  def initialize(class_type:, resource_class:, endpoint:)
17
- @class_type = class_type
18
- @resource_class = resource_class
19
- @endpoint = endpoint
25
+ @class_type = T.let(class_type, String)
26
+ @resource_class = T.let(resource_class, T.untyped)
27
+ @endpoint = T.let(endpoint, String)
28
+ @class_name = T.let(nil, T.nilable(String))
20
29
  end
21
30
 
31
+ sig { returns(T.untyped) }
22
32
  def call
23
33
  Object.const_get(class_name) if Object.const_defined?(class_name)
24
34
  end
25
35
 
26
36
  private
27
37
 
38
+ sig { returns(String) }
28
39
  def class_name
29
40
  @class_name ||= begin
30
41
  name_parts = @resource_class.name.split("::")
@@ -35,6 +46,7 @@ module EML
35
46
  end
36
47
  end
37
48
 
49
+ sig { returns(String) }
38
50
  def action_class_name
39
51
  @endpoint.capitalize.sub(/s$/, "")
40
52
  end
@@ -0,0 +1,54 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module EML
5
+ class ModelHash
6
+ extend T::Sig
7
+
8
+ sig { params(model: EML::Model).returns(T::Hash[Symbol, T.untyped]) }
9
+ def self.call(model)
10
+ new(model).call
11
+ end
12
+
13
+ sig { params(model: EML::Model).void }
14
+ def initialize(model)
15
+ @model = T.let(model, EML::Model)
16
+ @hash = T.let({}, T::Hash[Symbol, T.untyped])
17
+ end
18
+
19
+ sig { returns(T::Hash[Symbol, T.untyped]) }
20
+ def call
21
+ @model.class.enumerate_fields do |_, local_name|
22
+ value = @model.public_send(local_name)
23
+ add_value(local_name, value)
24
+ end
25
+
26
+ @hash
27
+ end
28
+
29
+ private
30
+
31
+ sig { params(name: Symbol, value: T.untyped).void }
32
+ def add_value(name, value)
33
+ @hash[name] = stored_value(value)
34
+ end
35
+
36
+ sig { params(value: T.untyped).returns(T.untyped) }
37
+ def stored_value(value)
38
+ if value.is_a?(Array)
39
+ array_value(value)
40
+ elsif value.respond_to?(:to_h)
41
+ value.to_h
42
+ else
43
+ value
44
+ end
45
+ end
46
+
47
+ sig { params(value: T::Array[T.untyped]).returns(T::Array[T.untyped]) }
48
+ def array_value(value)
49
+ value.each_with_object([]) do |item, array|
50
+ array << stored_value(item)
51
+ end
52
+ end
53
+ end
54
+ end
data/lib/eml/model.rb CHANGED
@@ -1,27 +1,52 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "json"
5
+
4
6
  module EML
5
7
  class Model
6
8
  extend T::Sig
9
+ extend T::Helpers
10
+ abstract!
7
11
 
12
+ sig do
13
+ params(
14
+ fields: T.any(T::Hash[String, T.untyped], T::Array[String])
15
+ ).void
16
+ end
8
17
  def self.fields(fields)
9
18
  const_set(:FIELDS, fields.freeze)
10
- fields.each do |response_name, local_name|
11
- local_name ||= response_name
19
+ enumerate_fields do |_, local_name|
12
20
  __send__(:attr_reader, :"#{local_name}")
13
21
  end
14
22
  end
15
23
 
24
+ sig { void }
25
+ def self.enumerate_fields
26
+ const_get(:FIELDS).each do |response_name, local_name|
27
+ local_name ||= response_name.to_sym
28
+ yield(response_name, local_name)
29
+ end
30
+ end
31
+
16
32
  sig { params(raw_values: T::Hash[String, T.untyped]).void }
17
33
  def initialize(raw_values)
18
- self.class::FIELDS.each do |response_name, local_name|
19
- local_name ||= response_name
34
+ self.class.enumerate_fields do |response_name, local_name|
20
35
  value = field_value(response_name, raw_values[response_name])
21
36
  instance_variable_set(:"@#{local_name}", value)
22
37
  end
23
38
  end
24
39
 
40
+ sig { returns(T::Hash[Symbol, T.untyped]) }
41
+ def to_h
42
+ ModelHash.(self)
43
+ end
44
+
45
+ sig { params(_args: T.nilable(Array)).returns(String) }
46
+ def to_json(*_args)
47
+ to_h.to_json
48
+ end
49
+
25
50
  protected
26
51
 
27
52
  sig { params(name: String, raw_value: T.untyped).returns(T.untyped) }
@@ -24,7 +24,7 @@ module EML
24
24
  params: T::Hash[Symbol, T.untyped]
25
25
  ).returns(T.untyped)
26
26
  end
27
- def self.convert(resource_class, endpoint, params)
27
+ def convert(resource_class, endpoint, params)
28
28
  endpoint_class = EML::EndpointClass.(
29
29
  class_type: ENDPOINT_CLASS_TYPE, resource_class: resource_class,
30
30
  endpoint: endpoint
@@ -112,6 +112,7 @@ module EML
112
112
 
113
113
  private
114
114
 
115
+ sig { params(array: T::Array[String]).returns(String) }
115
116
  def array_as_string(array)
116
117
  array.dup.tap { |vals| vals[-1] = "or #{vals.last}" }.join(", ")
117
118
  end
data/lib/eml/response.rb CHANGED
@@ -84,7 +84,7 @@ module EML
84
84
 
85
85
  sig { returns(T.nilable(EML::RESTError)) }
86
86
  def check_for_incorrectly_categorised_errors
87
- if error.match?(/is not in (the proper|a valid) status/)
87
+ if error&.match?(/is not in (the proper|a valid) status/)
88
88
  raise T.unsafe(EML::REST::UnprocessableEntityError).new(error, self)
89
89
  end
90
90
  end
@@ -15,6 +15,7 @@ module EML
15
15
  def initialize(id: nil)
16
16
  @id = T.let(id, T.nilable(String))
17
17
  @headers = T.let(nil, T.nilable(T::Hash[String, String]))
18
+ @credentials = T.let(nil, T.nilable(T::Hash[Symbol, String]))
18
19
  end
19
20
 
20
21
  sig do
@@ -50,13 +51,13 @@ module EML
50
51
 
51
52
  private
52
53
 
53
- sig { returns(T::Hash[Symbol, T.nilable(String)]) }
54
+ sig { returns(T::Hash[Symbol, String]) }
54
55
  def credentials
55
56
  @credentials ||= begin
56
57
  config = EML::UK.config
57
58
  {
58
- username: config.rest_username,
59
- password: config.rest_password,
59
+ username: config.rest_username || "",
60
+ password: config.rest_password || "",
60
61
  }
61
62
  end
62
63
  end
@@ -74,8 +75,8 @@ module EML
74
75
  def headers
75
76
  @headers ||= {
76
77
  "Authorization" => ::EML::BasicAuth::Generate.(
77
- credentials[:username],
78
- credentials[:password],
78
+ T.must(credentials[:username]),
79
+ T.must(credentials[:password]),
79
80
  prefix: "Basic "
80
81
  ),
81
82
  }
@@ -0,0 +1,22 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module EML
5
+ module UK
6
+ module Models
7
+ module TNS
8
+ class Card < ::EML::Model
9
+ fields(
10
+ "AvailableBalance" => :availableBalance,
11
+ "CarrierNumber" => :carrierNumber,
12
+ "ClientTrackingId" => :clientTrackingId,
13
+ "Currency" => :currency,
14
+ "ExternalId" => :externalId,
15
+ "Program" => :program,
16
+ "MerchantGroup" => :merchantGroup
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module EML
5
+ module UK
6
+ module Models
7
+ module TNS
8
+ class Message < ::EML::Model
9
+ extend T::Sig
10
+
11
+ fields("Transactions" => :transactions)
12
+
13
+ sig { params(raw_values: T::Hash[Symbol, T.untyped]).void }
14
+ def initialize(raw_values)
15
+ @transactions = raw_values[:Transactions].
16
+ each_with_object([]) do |raw_transaction, transactions|
17
+ transactions << EML::UK::Models::TNS::Transaction.
18
+ new(raw_transaction)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,51 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module EML
5
+ module UK
6
+ module Models
7
+ module TNS
8
+ class Transaction < ::EML::Model
9
+ extend T::Sig
10
+
11
+ fields(
12
+ "AuthorizationRequestId" => :authorizationRequestId,
13
+ "Card" => :card,
14
+ "Cards" => :cards,
15
+ "EmlId" => :emlId,
16
+ "MerchantCategoryCode" => :merchantCategoryCode,
17
+ "MerchantCountry" => :merchantCountry,
18
+ "Note" => :note,
19
+ "OriginalTransactionDate" => :originalDate,
20
+ "PosTransactionTime" => :posTime,
21
+ "Reason" => :reason,
22
+ "Result" => :result,
23
+ "RetrievalReferenceNumber" => :retrievalReferenceNumber,
24
+ "TransactionAmount" => :amount,
25
+ "TransactionCurrency" => :currency,
26
+ "TransactionDescription" => :description,
27
+ "TransactionId" => :transactionId,
28
+ "TransactionLocation" => :location,
29
+ "TransactionTime" => :time
30
+ )
31
+
32
+ sig { params(raw_values: T::Hash[String, T.untyped]).void }
33
+ def initialize(raw_values)
34
+ super
35
+ initialize_cards
36
+ end
37
+
38
+ private
39
+
40
+ sig { void }
41
+ def initialize_cards
42
+ @card = Card.new(@card) unless @card.nil?
43
+ @cards = (@cards || []).each_with_object([]) do |card, cards|
44
+ cards << Card.new(card)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -38,7 +38,7 @@ module EML
38
38
  sig { params(field: String, raw_value: T.untyped).returns(T.untyped) }
39
39
  def field_value(field, raw_value)
40
40
  if field.match?(/date|time/)
41
- EML::UK::ParseDate.(raw_value)
41
+ ::EML::UK::ParseDate.(raw_value)
42
42
  else
43
43
  raw_value
44
44
  end
@@ -27,7 +27,7 @@ module EML
27
27
  end
28
28
  def convert(resource_class, endpoint, params)
29
29
  endpoint_class = EML::UK::EndpointClass.(
30
- class_type: self::ENDPOINT_CLASS_TYPE,
30
+ class_type: const_get(:ENDPOINT_CLASS_TYPE),
31
31
  resource_class: resource_class, endpoint: endpoint
32
32
  )
33
33
 
@@ -40,10 +40,13 @@ module EML
40
40
 
41
41
  protected
42
42
 
43
- SEARCH_PARAMETER_OPTIONS = %w[
44
- ActualCardNumber CarrierNumber ClientTrackingId ExternalId
45
- PaymentTrackingID PrintText
46
- ].freeze
43
+ SEARCH_PARAMETER_OPTIONS = T.let(
44
+ %w[
45
+ ActualCardNumber CarrierNumber ClientTrackingId ExternalId
46
+ PaymentTrackingID PrintText
47
+ ].freeze,
48
+ T::Array[String]
49
+ )
47
50
 
48
51
  sig { params(value: String).void }
49
52
  def validate_search_parameter(value)
@@ -26,7 +26,7 @@ module EML
26
26
  end
27
27
  def convert(resource_class, endpoint, payload)
28
28
  endpoint_class = EML::UK::EndpointClass.(
29
- class_type: self::ENDPOINT_CLASS_TYPE,
29
+ class_type: const_get(:ENDPOINT_CLASS_TYPE),
30
30
  resource_class: resource_class,
31
31
  endpoint: endpoint
32
32
  )
@@ -10,6 +10,16 @@ module EML
10
10
 
11
11
  field :count
12
12
 
13
+ sig { params(response: HTTP::Response, id: T.nilable(String)).void }
14
+ def initialize(response, id: nil)
15
+ super
16
+
17
+ @transactions = T.let(
18
+ nil,
19
+ T.nilable(T::Array[::EML::UK::Models::Transaction])
20
+ )
21
+ end
22
+
13
23
  sig { returns(T::Array[::EML::UK::Models::Transaction]) }
14
24
  def transactions
15
25
  @transactions ||= body["transactions"].
@@ -11,7 +11,7 @@ module EML
11
11
  params(
12
12
  auth_token: String,
13
13
  parameters: T::Hash[Symbol, T.untyped]
14
- ).returns(EML::UK::TNS::Response)
14
+ ).returns(EML::UK::Models::TNS::Message)
15
15
  end
16
16
  def self.call(auth_token, parameters)
17
17
  new(auth_token, parameters).call
@@ -24,14 +24,15 @@ module EML
24
24
  ).void
25
25
  end
26
26
  def initialize(auth_token, parameters)
27
- @auth_token = auth_token
28
- @parameters = parameters
27
+ @auth_token = T.let(auth_token, String)
28
+ @parameters = T.let(parameters, T::Hash[Symbol, T.untyped])
29
+ @credentials = T.let(nil, T.nilable(T::Hash[Symbol, T.untyped]))
29
30
  end
30
31
 
31
- sig { returns(EML::UK::TNS::Response) }
32
+ sig { returns(EML::UK::Models::TNS::Message) }
32
33
  def call
33
34
  verify_auth_token
34
- EML::UK::TNS::Response.new(@parameters)
35
+ EML::UK::Models::TNS::Message.new(@parameters)
35
36
  end
36
37
 
37
38
  private
@@ -7,13 +7,27 @@ module EML
7
7
  class Response
8
8
  extend T::Sig
9
9
 
10
+ sig { returns(T::Array[EML::UK::Models::TNS::Transaction]) }
10
11
  attr_reader :transactions
11
12
 
12
13
  sig { params(response: T::Hash[Symbol, T.untyped]).void }
13
14
  def initialize(response)
14
- @transactions = response[:Transactions].
15
+ @transactions = T.let(
16
+ model_transactions(response),
17
+ T::Array[EML::UK::Models::TNS::Transaction]
18
+ )
19
+ end
20
+
21
+ private
22
+
23
+ sig do
24
+ params(response: T::Hash[Symbol, T.untyped]).
25
+ returns(T::Array[EML::UK::Models::TNS::Transaction])
26
+ end
27
+ def model_transactions(response)
28
+ response[:Transactions].
15
29
  each_with_object([]) do |raw_transaction, transactions|
16
- transactions << EML::UK::Models::TNSTransaction.
30
+ transactions << EML::UK::Models::TNS::Transaction.
17
31
  new(raw_transaction)
18
32
  end
19
33
  end
data/lib/eml/uk.rb CHANGED
@@ -12,8 +12,9 @@ require "eml/uk/config"
12
12
  require "eml/uk/lib/endpoint_class"
13
13
  require "eml/uk/lib/parse_date"
14
14
 
15
- require "eml/uk/models/tns_card"
16
- require "eml/uk/models/tns_transaction"
15
+ require "eml/uk/models/tns/card"
16
+ require "eml/uk/models/tns/message"
17
+ require "eml/uk/models/tns/transaction"
17
18
  require "eml/uk/models/transaction"
18
19
 
19
20
  require "eml/uk/parameters"
data/lib/eml/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module EML
5
- VERSION = "2.0.0"
5
+ VERSION = "2.1.0"
6
6
  end
data/lib/eml.rb CHANGED
@@ -30,6 +30,7 @@ require "eml/lib/basic_auth/generate"
30
30
  require "eml/lib/basic_auth/verify"
31
31
  require "eml/lib/constant_time_compare"
32
32
  require "eml/lib/endpoint_class"
33
+ require "eml/lib/model_hash"
33
34
 
34
35
  require "eml/model"
35
36
  require "eml/parameters"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eml
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morning Coffee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-18 00:00:00.000000000 Z
11
+ date: 2019-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -260,6 +260,7 @@ files:
260
260
  - lib/eml/lib/basic_auth/verify.rb
261
261
  - lib/eml/lib/constant_time_compare.rb
262
262
  - lib/eml/lib/endpoint_class.rb
263
+ - lib/eml/lib/model_hash.rb
263
264
  - lib/eml/model.rb
264
265
  - lib/eml/parameters.rb
265
266
  - lib/eml/payload.rb
@@ -269,8 +270,9 @@ files:
269
270
  - lib/eml/uk/config.rb
270
271
  - lib/eml/uk/lib/endpoint_class.rb
271
272
  - lib/eml/uk/lib/parse_date.rb
272
- - lib/eml/uk/models/tns_card.rb
273
- - lib/eml/uk/models/tns_transaction.rb
273
+ - lib/eml/uk/models/tns/card.rb
274
+ - lib/eml/uk/models/tns/message.rb
275
+ - lib/eml/uk/models/tns/transaction.rb
274
276
  - lib/eml/uk/models/transaction.rb
275
277
  - lib/eml/uk/parameters.rb
276
278
  - lib/eml/uk/parameters/agreement/show.rb
@@ -1,20 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- module EML
5
- module UK
6
- module Models
7
- class TNSCard < ::EML::Model
8
- fields(
9
- "AvailableBalance" => :availableBalance,
10
- "CarrierNumber" => :carrierNumber,
11
- "ClientTrackingId" => :clientTrackingId,
12
- "Currency" => :currency,
13
- "ExternalId" => :externalId,
14
- "Program" => :program,
15
- "MerchantGroup" => :merchantGroup,
16
- )
17
- end
18
- end
19
- end
20
- end
@@ -1,49 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- module EML
5
- module UK
6
- module Models
7
- class TNSTransaction < ::EML::Model
8
- extend T::Sig
9
-
10
- fields(
11
- "AuthorizationRequestId" => :authorizationRequestId,
12
- "Card" => :card,
13
- "Cards" => :cards,
14
- "EmlId" => :emlId,
15
- "MerchantCategoryCode" => :merchantCategoryCode,
16
- "MerchantCountry" => :merchantCountry,
17
- "Note" => :note,
18
- "OriginalTransactionDate" => :originalDate,
19
- "PosTransactionTime" => :posTime,
20
- "Reason" => :reason,
21
- "Result" => :result,
22
- "RetrievalReferenceNumber" => :retrievalReferenceNumber,
23
- "TransactionAmount" => :amount,
24
- "TransactionCurrency" => :currency,
25
- "TransactionDescription" => :description,
26
- "TransactionId" => :transactionId,
27
- "TransactionLocation" => :location,
28
- "TransactionTime" => :time
29
- )
30
-
31
- sig { params(raw_values: T::Hash[String, T.untyped]).void }
32
- def initialize(raw_values)
33
- super
34
- initialize_cards
35
- end
36
-
37
- private
38
-
39
- sig { void }
40
- def initialize_cards
41
- @card = TNSCard.new(@card) unless @card.nil?
42
- @cards = (@cards || []).each_with_object([]) do |card, cards|
43
- cards << TNSCard.new(card)
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end