<?php
error_reporting(E_ALL); 
error_reporting(-1); 
ini_set('error_reporting', E_ALL);

require_once $_SERVER['DOCUMENT_ROOT'].'/tienda/library/php-jwt/src/JWT.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/tienda/library/php-jwt/src/Key.php';

use Firebase\JWT\JWT;
use Firebase\JWT\Key;

class Environment {
    public static $key = '65m55zi2XJ8WMnBnP4VFvA4DxZ1kqnJeWGnvOVFZMXwiQ6zb0w';
    public static $pak2goKey = 't6hUtktBqksFUY3u9WOrTILCodx1zLrzAJsZCCj7geEt';
    public static function getPrivateKey(){
        return Environment::$key;
    }

    public static function encodeUser($id_usuario){
        $time = time();
        $token = array(
            'iat' => $time,
            'exp' => $time + ((60 * 60)*24)*30,
            'id_usuario' => $id_usuario,
        );
        $jwt = JWT::encode($token, Environment::$key, 'HS256');
        return $jwt;
    }

    public static function decodeUser($jwt){
        $decoded = JWT::decode($jwt, new Key(Environment::$key, 'HS256'));
        return $decoded;
    }

    public static function getUrlServidor(){
        return 'https://mtmsoluciones.com.mx/tienda/';
        // return 'http://localhost:8888/mtm-api/';
    }

    public static function getPak2goKey(){
        return Environment::$pak2goKey;
    }
}
