<?php

namespace Sibs\Stargate\Exceptions;

class StgException extends SibsException
{
    public const ERROR_CODE = '999';

    public const ERROR_ALREADY_PAID = 'ERROR_ALREADY_PAID';
    public const ERROR_TRANSACTION_PENDING = 'ERROR_TRANSACTION_PENDING';
    public const ERROR_MULTIBANCO_DATA = 'ERROR_MULTIBANCO_DATA';
    public const ERROR_TRANSACTION_NOT_SAVED = 'ERROR_TRANSACTION_NOT_SAVED';
    public const ERROR_UNKNOWN = 'ERROR_UNKNOWN';

    /**
     * Constructor.
     */
    public function __construct(string $details = '', array $context = [])
    {
        parent::__construct($details, $context);
    }

    /**
     * Get Error Message.
     *
     * @return string
     */
    public function getErrorMessage()
    {
        $message = $this->getMessage();

        switch ($message) {
            case self::ERROR_ALREADY_PAID:
                return __('We are sorry. Your order has a trasaction already paid.', 'sibs-woo-stg');

            case self::ERROR_TRANSACTION_PENDING:
                return __('We are sorry. Your order has a pending trasaction.', 'sibs-woo-stg');

            case self::ERROR_MULTIBANCO_DATA:
                return __('We are sorry. Your multibanco transaction has a missing parameter.', 'sibs-woo-stg');

            case self::ERROR_TRANSACTION_NOT_SAVED:
            case self::ERROR_UNKNOWN:
            default:
                return __('Unfortunately, your transaction has failed. Please try again.', 'sibs-woo-stg');
        }
    }
}
