<?php

namespace kernel\services;

use GuzzleHttp\Exception\GuzzleException;
use kernel\helpers\RESTClient;

class ModuleShopService
{
    protected string $url;
    protected string $token;

    public function __construct()
    {
        $this->url = $_ENV['MODULE_SHOP_URL'];
        $this->token = $_ENV['MODULE_SHOP_TOKEN'];
    }

    /**
     * @throws GuzzleException
     */
    public function email_auth(string $email)
    {
        $request = RESTClient::post($this->url . "/api/secure/email_auth", ['email' => $email], false);

        return json_decode($request->getBody()->getContents(), true);
    }

    public function code_check(string $code)
    {
        $request = RESTClient::post($this->url . "/api/secure/code_check", ['code' => $code], false);

        return json_decode($request->getBody()->getContents(), true);
    }

}