<?php
namespace Svea_Webpay_For_Woocommerce\Service_Providers;

use Svea\WebPay\Config\ConfigurationProvider;
use Svea\WebPay\Config\ConfigurationService;
use Svea_Webpay_For_Woocommerce\Plugin;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class Config_Production implements ConfigurationProvider {
	/**
	 * Merchant ID
	 *
	 * @var string
	 */
	private $merchant_id;

	/**
	 * Secret word
	 *
	 * @var string
	 */
	private $secret_word;

	/**
	 * Client number
	 *
	 * @var string
	 */
	private $client_nr;

	/**
	 * Username
	 *
	 * @var string
	 */
	private $username;

	/**
	 * Password
	 *
	 * @var string
	 */
	private $password;

	/**
	 * Constructor
	 *
	 * @param string $merchant_id
	 * @param string $secret_word
	 * @param string $client_nr
	 * @param string $password
	 * @param string $username
	 */
	public function __construct( $merchant_id, $secret_word, $client_nr, $password, $username ) {
		$this->merchant_id = $merchant_id;
		$this->secret_word = $secret_word;
		$this->client_nr = $client_nr;
		$this->password = $password;
		$this->username = $username;
	}

	/**
	 * Get the endpoint to use
	 *
	 * @param string $type
	 * @return string
	 */
	public function getEndPoint( $type ) {
		if ( $type === ConfigurationProvider::HOSTED_TYPE ) {
			return ConfigurationService::SWP_PROD_URL;
		} else if ( $type === ConfigurationProvider::INVOICE_TYPE || $type === ConfigurationProvider::PAYMENTPLAN_TYPE ) {
			return ConfigurationService::SWP_PROD_WS_URL;
		} else if ( $type === ConfigurationProvider::HOSTED_ADMIN_TYPE ) {
			return ConfigurationService::SWP_PROD_HOSTED_ADMIN_URL;
		} else if ( $type === ConfigurationProvider::ADMIN_TYPE ) {
			return ConfigurationService::SWP_PROD_ADMIN_URL;
		} else if ( $type === ConfigurationProvider::PREPARED_URL ) {
			return ConfigurationService::SWP_PROD_PREPARED_URL;
		} else {
			throw new \Exception( 'Error Processing Request! The request did not match any request type. Accepted values: INVOICE, PAYMENTPLAN, HOSTED_ADMIN or HOSTED' );
		}
	}

	/**
	 * Get username
	 *
	 * @param string $type
	 * @param string $country
	 * @return string
	 */
	public function getUsername( $type, $country ) {
		return $this->username;
	}

	/**
	 * Get password
	 *
	 * @param string $type
	 * @param string $country
	 * @return string
	 */
	public function getPassword( $type, $country ) {
		return $this->password;
	}

	/**
	 * Get client number
	 *
	 * @param string $type
	 * @param string $country
	 * @return string
	 */
	public function getClientNumber( $type, $country ) {
		return $this->client_nr;
	}

	/**
	 * Get merchant ID
	 *
	 * @param string $type
	 * @param string $country
	 * @return string
	 */
	public function getMerchantId( $type, $country ) {
		return $this->merchant_id;
	}

	/**
	 * Get secret
	 *
	 * @param string $type
	 * @param string $country
	 * @return string
	 */
	public function getSecret( $type, $country ) {
		return $this->secret_word;
	}

	/**
	 * Get integration platform
	 *
	 * @param string $type
	 * @param string $country
	 * @return string
	 */
	public function getIntegrationPlatform() {
		return 'WooCommerce';
	}

	/**
	 * Get integration company
	 *
	 * @param string $type
	 * @param string $country
	 * @return string
	 */
	public function getIntegrationCompany() {
		return 'The Generation';
	}

	/**
	 * Get integration version
	 *
	 * @param string $type
	 * @param string $country
	 * @return string
	 */
	public function getIntegrationVersion() {
		if ( class_exists( 'Plugin' ) ) {
			return Plugin::VERSION;
		}

		return '';
	}

	/**
	 * Get checkout merchant ID
	 *
	 * @param string $country
	 * @return string
	 */
	public function getCheckoutMerchantId( $country = null ) {
		return false;
	}

	/**
	 * Get checkout secret
	 *
	 * @param string $country
	 * @return string
	 */
	public function getCheckoutSecret( $country = null ) {
		return false;
	}
}
