<?php
/**
 * Webkul Software
 *
 * @category  Webkul
 * @package   Webkul_MpPayPal
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */
namespace Webkul\MpPayPal\Gateway\Config;

class Config extends \Magento\Payment\Gateway\Config\Config
{
    const KEY_ENVIRONMENT = 'environment';
    const KEY_ACTIVE = 'active';
    const TITLE = 'title';
    const KEY_THRESHOLD_AMOUNT = 'min_order_total';
    const KEY_MAX_ORDER_TOTAL = 'max_order_total';
    const KEY_VERIFY_ALLOW_SPECIFIC = 'allowspecific';
    const KEY_VERIFY_SPECIFIC = 'specificcountry';
    const KEY_SPECIFIC_COUNTRIES = 'specificcountry';
    const CLIENT_ID = 'client_id';
    const SECRET = 'secret';
    const MODE = 'disbursement_mode';
    const PARTNER_EMAIL = 'partner_email';
    const PARTNER_MERCHANT_ID = 'partner_merchant_id';
    const ENABLE_DEFAULT = 'enable_default';
    const UNBRANDED = 'unbranded';
    const ACCESS_TOKEN = 'access_token';
    const EXPIRES_IN = 'expires_in';
    const BN_CODE = 'production_bn_code';
    const BN_CODE_SB = 'sandbox_bn_code';

    /**
     * get client id
     *
     * @return string
     */
    public function getAccessToken()
    {
        return $this->getValue(Config::ACCESS_TOKEN);
    }

    /**
     * get client id
     *
     * @return string
     */
    public function getExpiresIn()
    {
        return $this->getValue(Config::EXPIRES_IN);
    }

    /**
     * get client id
     *
     * @return string
     */
    public function getClientId()
    {
        return $this->getValue(Config::CLIENT_ID);
    }

    /**
     * get client secret
     *
     * @return string
     */
    public function getClientSecret()
    {
        return $this->getValue(Config::SECRET);
    }

    /**
     * get application id
     *
     * @return string
     */
    public function getApplication()
    {
        if ($this->getEnvironment() == 'sandbox') {
            return $this->getValue(Config::BN_CODE_SB);
        }
        return $this->getValue(Config::BN_CODE);
    }

    /**
     * Get threshold amount for 3d secure
     * @return float
     */
    public function getThresholdAmount()
    {
        return (double) $this->getValue(self::KEY_THRESHOLD_AMOUNT);
    }

    /**
     * get maximum order total to allow payment method
     *
     * @return void
     */
    public function getMaxOrderTotalAmount()
    {
        return (double) $this->getValue(self::KEY_MAX_ORDER_TOTAL);
    }

    /**
     * Get list of specific countries for 3d secure
     * @return array
     */
    public function getSpecificCountries()
    {
        return explode(',', $this->getValue(self::KEY_SPECIFIC_COUNTRIES));
    }

    /**
     * @return string
     */
    public function getEnvironment()
    {
        return $this->getValue(Config::KEY_ENVIRONMENT);
    }

    /**
     * Get Payment configuration status
     * @return bool
     */
    public function isActive($storeId = null)
    {
        return (bool) $this->getValue(self::KEY_ACTIVE, $storeId);
    }

    /**
     * @return string
     */
    public function getPaymentMode()
    {
        return $this->getValue(Config::MODE);
    }

    /**
     * @return string
     */
    public function getPartnerEmail()
    {
        return $this->getValue(Config::PARTNER_EMAIL);
    }

    /**
     * @return string
     */
    public function getPartnerMerchantId()
    {
        return $this->getValue(Config::PARTNER_MERCHANT_ID);
    }

    /**
     * @return string
     */
    public function getEnableDefault()
    {
        return $this->getValue(Config::ENABLE_DEFAULT);
    }

    /**
     * @return string
     */
    public function getUnbrandedEnable()
    {
        return $this->getValue(Config::UNBRANDED);
    }
}
