<?php

class FinancingController{
    private $model;

    function __construct(){
        $this->model = new FinancingModel();
    }

    /**
     * get interest rate
     * @return json value for intereset rate
     */
    public function getInterestRate(){
        echo json_encode($this->model->getInterestRate(), JSON_NUMERIC_CHECK);
    }

    /**
     * get interest rate for customers
     * @return json values for interest rate for each customer
     */
    public function getInterestRateForCustomers(){
        echo json_encode($this->model->getInterestRateForCustomers(), JSON_NUMERIC_CHECK);
    }

    /**
     * save interest rate
     * @return json update message
     */
    public function saveInterestRate(){
        $interestRate = isset($_REQUEST['interestRate']) ? $_REQUEST['interestRate'] : 0;
        echo json_encode($this->model->saveInterestRate($interestRate));
    }

}
