Class: ShellSmartPayApi::CancelFuelingErrorResponseErrorException

Inherits:
APIException
  • Object
show all
Defined in:
lib/shell_smart_pay_api/exceptions/cancel_fueling_error_response_error_exception.rb

Overview

# Digital Payments – Errors This section details the structure of the response Body vs. the different types of errors that could be returned when Digital Payments system responds with a 400 Response Code. | Error Code | Error Description | Suggested message to end user | |- |- |- | | 9342 | Transaction not cancelled, Txn number unknown | Oops sorry! We are unable to cancel the transaction. Please wait for the site to cancel the transaction before you retry | | 50004 | Transaction not cancelled, dispensing is already in progress | Transaction cannot be cancelled, fueling already in progress | | 50059 | Transaction not cancelable (not in a ‘Processing state’) | Transaction cannot be cancelled, fuel has already been dispensed |

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ CancelFuelingErrorResponseErrorException

The constructor.

Parameters:

  • reason for raising an exception.

  • HttpReponse of the API call.



39
40
41
42
43
# File 'lib/shell_smart_pay_api/exceptions/cancel_fueling_error_response_error_exception.rb', line 39

def initialize(reason, response)
  super(reason, response)
  hash = APIHelper.json_deserialize(@response.raw_body)
  unbox(hash)
end

Instance Attribute Details

#error_codeString

The high level error code (e.g. missing data)

Returns:



24
25
26
# File 'lib/shell_smart_pay_api/exceptions/cancel_fueling_error_response_error_exception.rb', line 24

def error_code
  @error_code
end

#error_descriptionString

The high level error message (e.g. mandatory fields have not been specified.

Returns:



29
30
31
# File 'lib/shell_smart_pay_api/exceptions/cancel_fueling_error_response_error_exception.rb', line 29

def error_description
  @error_description
end

#errorsArray[MppError]

Array of error objects. Majority of the time the errorCode and errorDescription will suffice

Returns:



34
35
36
# File 'lib/shell_smart_pay_api/exceptions/cancel_fueling_error_response_error_exception.rb', line 34

def errors
  @errors
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



72
73
74
75
76
# File 'lib/shell_smart_pay_api/exceptions/cancel_fueling_error_response_error_exception.rb', line 72

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} error_code: #{@error_code.inspect}, error_description:"\
  " #{@error_description.inspect}, errors: #{@errors.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



65
66
67
68
69
# File 'lib/shell_smart_pay_api/exceptions/cancel_fueling_error_response_error_exception.rb', line 65

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} error_code: #{@error_code}, error_description: #{@error_description},"\
  " errors: #{@errors}>"
end

#unbox(hash) ⇒ Object

Populates this object by extracting properties from a hash. response body.

Parameters:

  • deserialized response sent by the server in the



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/shell_smart_pay_api/exceptions/cancel_fueling_error_response_error_exception.rb', line 48

def unbox(hash)
  @error_code = hash.key?('errorCode') ? hash['errorCode'] : SKIP
  @error_description =
    hash.key?('errorDescription') ? hash['errorDescription'] : SKIP
  # Parameter is an array, so we need to iterate through it

  @errors = nil
  unless hash['errors'].nil?
    @errors = []
    hash['errors'].each do |structure|
      @errors << (MppError.from_hash(structure) if structure)
    end
  end

  @errors = SKIP unless hash.key?('errors')
end