<?php
/**
 * File: GetInstallmentInfoRequest.php
 * Year: 2023
 */

namespace Tami\WooCommerce;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( '\Tami\WooCommerce\GetInstallmentInfoRequest' ) ) {
	class GetInstallmentInfoRequest {
		public $binNumber;
		public $securityHash;

		public function setBinNumber( $binNumber ) {
			$this->binNumber = $binNumber;
			return $this;
		}

		public function generateSecurityHash($merchantId,$terminalId,$secretKey, $fixedKidValue, $fixedKValue) {
			$requestBody  = [
				'binNumber' => $this->binNumber,
			];

			if(!class_exists('Tami\WooCommerce\HashGenerator'))
				include TAMI_PLUGIN_PATH . '/lib/HashGenerator.php';

            $HashGenerator = new HashGenerator($merchantId,$terminalId,$secretKey, $fixedKidValue, $fixedKValue);
            $hash = $HashGenerator->generateJWKSignature($requestBody);

            $this->setSecurityHash($hash);
		}

		public function setSecurityHash(  $securityHash ) {
			$this->securityHash = $securityHash;
			return $this;
		}

		public function getBinNumber() {
			return $this->binNumber;
		}

		public function get() {
			return (object) [
				'binNumber' => $this->binNumber,
				'securityHash' => $this->securityHash,
			];
		}
	}
}
