<?php

namespace App\Helpers;

class WebhookSignature
{
    public $orderId, $storeId, $orderAmount;

    public function __construct(array $orderArray)
    {
        if (isset($orderArray[Strings::$orderId]))
            $this->orderId = $orderArray[Strings::$orderId];
        $this->storeId = $orderArray[Strings::$storeId];
        if (isset($orderArray[Strings::$orderAmount]))
            $this->orderAmount = $orderArray[Strings::$orderAmount];
    }

    public function generateSignature(string $secret_key): string
    {
        return hash('sha256', $secret_key . $this->storeId . $this->orderId . $this->orderAmount . $secret_key);
    }

    public function generateCategoriesSignature(string $secret_key, string $categories): string
    {
        return hash('sha256', $secret_key . $this->storeId . $categories . $secret_key);
    }
}
