<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/../../vendor/autoload.php';

class WordPressUserRoleAPI{
	
	//CONST apiURL = "https://orders.gsscctv.com/wp-rolesAPI/apiHandler.php?apiKey=".$gssConsumerKey."&action=";

	public static function getRoleData(){
		$apiURL = "https://orders.gsscctv.com/wp-rolesAPI/apiHandler.php?apiKey=ck_9528df947614a332dce1a4d2cdac3750c743db96&action=";
		$client = curl_init($apiURL.'select');
		curl_setopt($client, CURLOPT_RETURNTRANSFER, 1);
		$response = curl_exec($client);
		//Dev::pvx($response);
		return $response;
	}

	public static function insertNewRole($wpRole){
		$apiURL = "https://orders.gsscctv.com/wp-rolesAPI/apiHandler.php?apiKey=ck_9528df947614a332dce1a4d2cdac3750c743db96&action=";
		$data = array(
			'roleKey' => $wpRole['wpRoleKey'],
			'roleLabel' => $wpRole['wpRoleLabel']
		);
		//connect to api
		$client = curl_init($apiURL.'insert');
		curl_setopt($client, CURLOPT_POST, true);
		curl_setopt($client, CURLOPT_POSTFIELDS, $data);
		curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
		$response = curl_exec($client);
		curl_close($client);
		return $response ;
		//return (curl_errno($client) ? false : true);
	}
}