<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Api
 *
 * @author abrah_000
 */
class Api {

    //put your code here
    //static $url = "http://tpc.interface.local:8081/api/index.php";
   static $url = PS_SHOP_PATH . "interface_frio/api/index.php";
    static $token = "ab493ef8-eb6d-a81d-65c2-52ea560984c1";

    static function MakeCall($method, $params = NULL) {
        // Get cURL resource
        $curl = curl_init();
// Set some options - we are passing in a useragent too here
        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => self::$url . '?token=' . self::$token . '&action=' . $method,
            CURLOPT_USERAGENT => 'TuPanaCharcutero Interface'
        ));
       //Debug::pr($params);
        if (is_array($params)) {
            curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
        }
        //Debug::pr(self::$url);
// Send the request & save response to $resp
        $resp = curl_exec($curl);

        if (!$resp) {
            //$resp = null;
            //print_r($curl);
			//phpinfo();
            //die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
            return NULL;
        }
// Close request to clear up some resources
        curl_close($curl);
        return $resp;
    }

}
