Exception: SixSaferpay::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/six_saferpay/errors/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_header:, behavior:, error_name:, error_message:, transaction_id: nil, error_detail: nil, processor_name: nil, processor_result: nil, processor_message: nil) ⇒ Error

Returns a new instance of Error.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/six_saferpay/errors/error.rb', line 15

def initialize(response_header: ,
               behavior: ,
               error_name: ,
               error_message: ,
               transaction_id: nil,
               error_detail: nil,
               processor_name: nil,
               processor_result: nil,
               processor_message: nil
              )
  @response_header = SixSaferpay::ResponseHeader.new(**response_header.to_h) if response_header
  @behavior = behavior
  @error_name = error_name
  @error_message = error_message
  @transaction_id = transaction_id
  @error_detail = error_detail
  @processor_name = processor_name
  @processor_result = processor_result
  @processor_message = processor_message
end

Instance Attribute Details

#behaviorObject

Returns the value of attribute behavior.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def behavior
  @behavior
end

#error_detailObject

Returns the value of attribute error_detail.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def error_detail
  @error_detail
end

#error_messageObject

Returns the value of attribute error_message.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def error_message
  @error_message
end

#error_nameObject

Returns the value of attribute error_name.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def error_name
  @error_name
end

#processor_messageObject

Returns the value of attribute processor_message.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def processor_message
  @processor_message
end

#processor_nameObject

Returns the value of attribute processor_name.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def processor_name
  @processor_name
end

#processor_resultObject

Returns the value of attribute processor_result.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def processor_result
  @processor_result
end

#response_headerObject

Returns the value of attribute response_header.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def response_header
  @response_header
end

#transaction_idObject

Returns the value of attribute transaction_id.



4
5
6
# File 'lib/six_saferpay/errors/error.rb', line 4

def transaction_id
  @transaction_id
end

Instance Method Details

#full_messageObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/six_saferpay/errors/error.rb', line 51

def full_message
  error = "#{@behavior}: #{@error_name} - #{@error_message}"
  if @error_detail
    @error_detail.each do |detail|
      error << "\n"
      error << detail
    end
  end
  error
end

#messageObject



66
67
68
# File 'lib/six_saferpay/errors/error.rb', line 66

def message
  full_message
end

#to_hashObject Also known as: to_h



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/six_saferpay/errors/error.rb', line 36

def to_hash
  hash = Hash.new
  hash.merge!(response_header: @response_header.to_h) if @response_header
  hash.merge!(behavior: @behavior) if @behavior
  hash.merge!(error_name: @error_name) if @error_name
  hash.merge!(error_message: @error_message) if @error_message
  hash.merge!(transaction_id: @transaction_id) if @transaction_id
  hash.merge!(error_detail: @error_detail) if @error_detail
  hash.merge!(processor_name: @processor_name) if @processor_name
  hash.merge!(processor_result: @processor_result) if @processor_result
  hash.merge!(processor_message: @processor_message) if @processor_message
  hash
end

#to_sObject



62
63
64
# File 'lib/six_saferpay/errors/error.rb', line 62

def to_s
  full_message
end