<?php
/**
 * Calculation service for Nova Post shipping costs.
 *
 * @package   NovaPostForWoocommerce
 */

namespace NovaPostForWoocommerce\Services;

use NovaDigital\NovaPost\NovaPostApi;
use NovaPostForWoocommerce\Factories\NovaPost;

/**
 * Handles shipment cost calculations and request building.
 */
class CalculationService {
    /**
     * NovaPosApi client.
     *
     * @var NovaPostApi
     */
    private NovaPostApi $nova_post_client;

    /**
     * Construct.
     */
    public function __construct() {
        $this->nova_post_client = NovaPost::get_client();
    }

    /**
     * Calculate delivery cost.
     *
     * @param array $calculation_params to recalculate cost.
     */
    public function calculate( array $calculation_params ): ?array {
        return $this->nova_post_client->shipments()->calculate( $calculation_params );
    }
}
