module TransferToApi
  # This is a wrapper class for TransferTo Error codes.
  class CommandException < StandardError

    attr_reader :code, :raw_response

    # Possible errors
    MSISDN_OUT_OF_RANGE = 101
    MSISDN_IN_BLACKLIST = 104
    NOT_ENOUGH_CREDIT = 105
    TRANSACTION_CANCELLED_BY_CUSTOMER = 200
    TRANSACTION_CANCELED_BY_TRANSFERTO = 202
    TRANSACTION_INCOMPLETE = 203
    NO_VALID_PREPAID_NR = 204
    TRANSACTION_AMOUNT_LIMIT_EXCEEDED = 207
    DUPLICATED_TRANSACTION = 213
    TOPUP_REFUSED = 214
    OPERATOR_UNAVAILABLE = 215
    NUMBER_NOT_ACTIVATED = 216
    NUMBER_EXPIRED = 217
    REQUEST_TIMEOUT = 218
    KEY_DOES_NOT_EXIST = 219
    FRAUD_SUSPICION = 221
    NUMBER_BARRED_FROM_REFILL = 222
    ID_NOT_RESERVED = 223
    INVALID_LENGTH_OF_MSISDN = 224
    MAX_TOPUP_NUMBER_REACHED = 230
    MAX_TOPUP_AMOUNT_REACHED = 231
    ACCOUNT_MAX_TOPUP_NUMBER_REACHED = 232
    ACCOUNT_MAX_TOPUP_AMOUNT_REACHED = 233
    ACCOUNT_MAX_DAILY_TOPUP_AMOUNT_REACHED = 241
    ACCOUNT_MAX_DAILY_TOPUP_NUMBER_REACHED = 242
    ACCOUNT_MAX_WEEKLY_TOPUP_AMOUNT_REACHED = 243
    ACCOUNT_MAX_WEEKLY_TOPUP_NUMBER_REACHED = 244
    ACCOUNT_MAX_MONTHLY_TOPUP_AMOUNT_REACHED = 245
    ACCOUNT_MAX_MONTHLY_TOPUP_NUMBER_REACHED = 246
    SENDER_MAX_DAILY_TOPUP_AMOUNT_REACHED = 251
    SENDER_MAX_DAILY_TOPUP_NUMBER_REACHED = 252
    SENDER_MAX_WEEKLY_TOPUP_AMOUNT_REACHED = 253
    SENDER_MAX_WEEKLY_TOPUP_NUMBER_REACHED = 254
    SENDER_MAX_MONTHLY_TOPUP_AMOUNT_REACHED = 255
    SENDER_MAX_MONTHLY_TOPUP_NUMBER_REACHED = 256
    DENOMINATION_NOT_AVAILABLE = 301
    DENOMINATION_BLOCKED = 310
    AMOUNT_OUT_OF_RANGE = 320
    CURRENCY_NOT_ALLOWED = 321
    SKUID_OPERATOR_MISMATCH = 322
    TRANSACTION_ID_NOT_FOUND = 401
    INSUFFICIENT_BALANCE_IN_ACCOUNT = 777
    INSUFFICIENT_BALANCE_IN_SUBACCOUNT = 888
    NOT_ENOUGH_INFORMATION_FOR_TOPUP = 900
    INVALID_ACTION = 901
    INVALID_INPUT_CURRENCY = 902
    INVALID_OUTPUT_CURRENCY = 903
    INVALID_INPUT_VALUE = 904
    INVALID_START_DATE = 905
    INVALID_STOP_DATE = 906
    INVALID_TRANSACTION_ID = 907
    ACCOUNT_NOT_CONFIGURED = 908
    INVALID_FLAG = 909
    OPERATOR_NOT_FOUND = 915
    ARGUMENT_MISSING = 919
    HASH_INCORRECT = 921
    IP_NOT_ALLOWED = 922
    KEY_INVALID = 923
    ACCOUNT_NOT_ACTIVE = 926
    ACCOUNT_NOT_FOUND = 995
    SYSTEM_NOT_AVAILABLE = 998
    UNKNOWN_ERROR = 999

    # This method is used to instantiate a new Error object with a response code
    # from the API.
    def initialize(raw_response, code, message = nil)
      @raw_response = raw_response
      @code = code.to_i
      super(message)
    end
  end
end

