0
      Login

    getSession

    “;

    $args = array();
    $args[“strUserName”] = “TES114”;
    $args[“strPassword”] = “test”;

    $result = CurlFunction($args, “getSession”);
    var_dump($result);

    /**
    * checkSession
    */
    echo “

    checkSession

    “;

    $args = array();
    $args[“strSessionId”] = $result->object->strSessionId;

    $result = CurlFunction($args, “checkSession”);
    var_dump($result);

    $session = $result->object->strSessionId;

    /**
    * getProvinces
    */
    echo “

    getProvinces

    “;

    $args = array();
    $args[“strSessionId”] = $session;

    $result = CurlFunction($args, “getProvinces”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * getAllClients
    */
    echo “

    getAllClients

    “;

    $args = array();
    $args[“strSessionId”] = $session;

    $result = CurlFunction($args, “getAllClients”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * getClientById
    */
    echo “

    getClientById

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidClientId”] = ‘3c8d4c6a-be9a-11e4-bb6a-28d244200550’;

    $result = CurlFunction($args, “getClientById”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * createClient
    */
    /*
    echo “

    createClient

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“strName”] = “rs_api_TestUser TestMiddleName”;
    $args[“strLastName”] = “TestLastName”;
    $args[“strCell”] = “083 264 4665”;

    $id = “”;
    for ($i = 0; $i < 13; $i++) { $id .= rand(0, 9); } $args["strIdNumber"] = $id; $args["strCompanyName"] = "Microsoft"; $args["strAddress"] = "5 Some Street"; $args["strSuburb"] = "Some Area"; $args["strCity"] = "Some City"; $args["strEmail"] = "someemail@somedomain.co.za"; $args["strHomeTel"] = "041 3661546"; $args["strWorkTel"] = "041 3115486"; $args["intProvinceId"] = 1; $args["intPostalCode"] = 6070; $result = CurlFunction($args, "createClient"); var_dump($result); */ /** * getProducts */ echo "

    getProducts

    “;

    $args = array();
    $args[“strSessionId”] = $session;

    $result = CurlFunction($args, “getProducts”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * getServicesByClient
    */
    echo “

    getServicesByClient

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidClientId”] = ‘3c8d4c6a-be9a-11e4-bb6a-28d244200550’;

    $result = CurlFunction($args, “getServicesByClient”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * getAllUnassignedSimServices
    */
    echo “

    getAllUnassignedSimServices

    “;

    $args = array();
    $args[“strSessionId”] = $session;

    $result = CurlFunction($args, “getAllUnassignedSimServices”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * getServiceById
    */
    echo “

    getServiceById

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ’38d66070-c0ed-11e4-bfb7-28d244200550′;

    $result = CurlFunction($args, “getServiceById”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * getServiceSessionDetailsById
    */
    echo “

    getServiceSessionDetailsById

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ’38d66070-c0ed-11e4-bfb7-28d244200550′;

    $result = CurlFunction($args, “getServiceSessionDetailsById”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * getServiceUsageDetailsById
    */
    echo “

    getServiceUsageDetailsById

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ’38d66070-c0ed-11e4-bfb7-28d244200550′;

    $result = CurlFunction($args, “getServiceUsageDetailsById”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * createService
    *
    * ADSL
    */
    /*
    echo “

    createService ADSL

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidClientId”] = ‘3c8d4c6a-be9a-11e4-bb6a-28d244200550’;
    $args[“guidProductId”] = ‘752b5310-be97-11e4-bb6a-28d244200550’;
    $args[“intQuantity”] = ‘2’;
    $args[“strUsername”] = ‘MyUsername’;
    $args[“strDateStart”] = date(“Y:m:d H:i:s”);

    $result = CurlFunction($args, “createService”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;
    */
    /**
    * createService
    *
    * LINE
    */
    /*
    echo “

    createService LINE

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidClientId”] = ‘3c8d4c6a-be9a-11e4-bb6a-28d244200550’;
    $args[“guidProductId”] = ‘752c2c44-be97-11e4-bb6a-28d244200550’;
    $args[“strLineNumber”] = ‘041 354 1564’;
    $args[“strOwnerName”] = ‘Francis Drake’;
    $args[“strAddress”] = ‘5 Sale Street’;
    $args[“strSuburb”] = ‘Newton Park’;
    $args[“strCity”] = ‘Port Elizabeth’;
    $args[“intPostalCode”] = ‘6070’;
    $args[“intIsTransfer”] = ‘0’;

    $result = CurlFunction($args, “createService”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;
    */

    /**
    * createService
    *
    * MOBILE
    */
    /*
    echo “

    createService MOBILE

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidClientId”] = ‘3c8d4c6a-be9a-11e4-bb6a-28d244200550’;
    $args[“guidProductId”] = ‘752ce60f-be97-11e4-bb6a-28d244200550′;
    $args[“guidMobileServiceId”] = ’36d12e33-c7ec-11e4-8385-28d244200550’;
    $args[“strDateStart”] = date(“Y:m:d H:i:s”);

    $result = CurlFunction($args, “createService”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;
    */

    /**
    * funcServiceChanges
    */
    echo “

    funcServiceChanges

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ‘3f5e43f9-c644-11e4-bf06-68f72804dc1e’;
    $args[“guidProductId”] = ‘3ea95a50-c644-11e4-bf06-68f72804dc1e’;
    $args[“intQuantity”] = ‘5’;
    $args[“strDateStart”] = ‘2015-03-13’;

    $result = CurlFunction($args, “funcServiceChanges”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * funcTopups
    */
    echo “

    funcTopups

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ‘3f5e3339-c644-11e4-bf06-68f72804dc1e’;
    $args[“guidProductId”] = ‘3ea95a50-c644-11e4-bf06-68f72804dc1e’;
    $args[“intQuantity”] = ‘5’;

    $result = CurlFunction($args, “funcTopups”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * funcCheckLine
    */
    echo “

    funcCheckLine

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ‘ea0485ca-c259-11e4-9319-002590383a96’;

    $result = CurlFunction($args, “funcCheckLine”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * funcFixLine
    */
    echo “

    funcFixLine

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ‘ea0485ca-c259-11e4-9319-002590383a96’;

    $result = CurlFunction($args, “funcFixLine”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * funcPod
    */
    echo “

    funcPod

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ‘3f5e42ce-c644-11e4-bf06-68f72804dc1e’;

    $result = CurlFunction($args, “funcPod”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * funcSuspend
    */
    echo “

    funcSuspend

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ‘3f5e42ce-c644-11e4-bf06-68f72804dc1e’;

    $result = CurlFunction($args, “funcSuspend”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * funcPasswordReset
    */
    echo “

    funcPasswordReset

    “;

    $args = array();
    $args[“strSessionId”] = $session;
    $args[“guidServiceId”] = ‘3f5e65b9-c644-11e4-bf06-68f72804dc1e’;

    $result = CurlFunction($args, “funcPasswordReset”);
    echo ‘

    ';
    var_dump($result);
    echo '

    ‘;

    /**
    * Curl wrapper function for accessing and testing all of the reseller API methods
    *
    * @param $d
    * @param $curlcall
    * @param string $verb
    * @return Response
    */
    function CurlFunction($d, $curlcall, $verb = “”)
    {
    $Username = “ResellerAdmin”;
    $Password = “jFbd5lg7Djfbn48idmlf4Kd”;

    $curl = new Curl();
    $response = new Response();

    /*
    $cookieFile = “cookies.txt”;
    if(!file_exists($cookieFile)) {
    $fh = fopen($cookieFile, “w”);
    fwrite($fh, “”);
    fclose($fh);
    }

    $curl->setOpt(CURLOPT_COOKIEFILE, “cookies.txt”);
    $curl->setOpt(CURLOPT_COOKIEJAR, “cookies.txt”);
    $curl->setOpt(CURLOPT_COOKIESESSION, true);
    $curl->setOpt(CURLOPT_HEADER, true);
    */

    /**
    * All objects returned with:
    *
    * intCode ( HTTP Status code )
    * strStatus ( HTTP Status )
    * strMessage ( Extra information; Can be null )
    */
    switch ($curlcall)
    {
    /**
    * Authenticate and get a GUID for remainder of API session
    *
    * @param array $d array(“strUserName”, “strPassword”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[4]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘strSessionId’ => string ’27F11AE2-BCC0-EA8C-0F7E-6D6332017955′ (length=36)
    *
    */
    case “getSession”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getSession.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Check if GUID still valid
    *
    * @param array $d array(“strSessionId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[7]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘strSessionId’ => string ‘1C4BBAEF-024C-8FC4-DE28-9693A8965902’ (length=36)
    *
    */
    case “checkSession”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/checkSession.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Get list of provinces we have on our system and their ids
    *
    * @param array $d array(“strSessionId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[6]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrProvinces’ =>
    object(stdClass)[8]
    public ‘0’ =>
    object(stdClass)[9]
    public ‘intProvinceId’ => string ‘1’ (length=1)
    public ‘strName’ => string ‘Eastern Cape’ (length=12)
    public ‘1’ =>
    object(stdClass)[10]
    public ‘intProvinceId’ => string ‘2’ (length=1)
    public ‘strName’ => string ‘Free State’ (length=10)

    * etc.
    *
    */
    case “getProvinces”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getProvinces.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Get details of all clients
    *
    * @param array $d array(“strSessionId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[4]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrClients’ =>
    object(stdClass)[18]
    public ‘0’ =>
    object(stdClass)[19]
    public ‘guidClientId’ => string ‘3d384623-be9a-11e4-bb6a-28d244200550’ (length=36)
    public ‘strName’ => string ‘First’ (length=5)
    public ‘strLastName’ => string ‘Client’ (length=6)
    public ‘strCell’ => string ‘083 267 2584’ (length=12)
    public ‘strIdNumber’ => string ‘8110225012087’ (length=13)
    public ‘strAddress’ => string ’16 SomeStreet’ (length=12)
    public ‘strSuburb’ => string ‘Some Suburb’ (length=14)
    public ‘strCity’ => string ‘Port Elizabeth’ (length=14)
    public ‘strEmail’ => string ‘someonone@somewhere.co.za’ (length=16)
    public ‘strHomeTel’ => null
    public ‘strWorkTel’ => null
    public ‘intProvinceId’ => string ‘1’ (length=1)
    public ‘intPostalCode’ => string ‘6070’ (length=4)
    public ‘1’ =>
    object(stdClass)[20]
    * etc.
    *
    */
    case “getAllClients”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getAllClients.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Get details of specific client
    *
    * @param array $d array(“strSessionId”, “guidClientId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[4]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrClients’ =>
    object(stdClass)[18]
    public ‘0’ =>
    object(stdClass)[19]
    public ‘guidClientId’ => string ‘3d384623-be9a-11e4-bb6a-28d244200550’ (length=36)
    public ‘strName’ => string ‘First’ (length=5)
    public ‘strLastName’ => string ‘Client’ (length=6)
    public ‘strCell’ => string ‘083 267 2584’ (length=12)
    public ‘strIdNumber’ => string ‘8110225012087’ (length=13)
    public ‘strAddress’ => string ’16 SomeStreet’ (length=12)
    public ‘strSuburb’ => string ‘Some Suburb’ (length=14)
    public ‘strCity’ => string ‘Port Elizabeth’ (length=14)
    public ‘strEmail’ => string ‘someonone@somewhere.co.za’ (length=16)
    public ‘strHomeTel’ => null
    public ‘strWorkTel’ => null
    public ‘intProvinceId’ => string ‘1’ (length=1)
    public ‘intPostalCode’ => string ‘6070’ (length=4)
    *
    */
    case “getClientById”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getClientById.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Create new client
    *
    * @param array $d array(“strSessionId”,
    “strName”,
    “strLastName”,
    “strCell”,
    “strIdNumber”,
    “strCompanyName”,
    “strAddress”,
    “strSuburb”,
    “strCity”,
    “strEmail”,
    “strHomeTel”,
    “strWorkTel”,
    “intProvinceId”,
    “intPostalCode”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[143]
    public ‘intCode’ => int 201
    public ‘strStatus’ => string ‘Created’ (length=7)
    public ‘strMessage’ => null
    public ‘guidClientId’ => string ‘c92278f2-cd5e-11e4-b090-28d244200550’ (length=36)
    public ‘strUsername’ => string ‘TJS319’ (length=6)
    public ‘strPassword’ => string ‘d9cljbUA’ (length=8)
    *
    */
    case “createClient”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/createClient.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->put($Url, $d);

    break;
    }
    /**
    * Get all available reseller products
    *
    * @param array $d array(“strSessionId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[8]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrProducts’ =>
    object(stdClass)[17]
    public ‘0’ =>
    object(stdClass)[16]
    public ‘guidProductId’ => string ‘752b51a5-be97-11e4-bb6a-28d244200550’ (length=4)
    public ‘strName’ => string ‘ADSL SAIX’ (length=9)
    public ‘1’ =>
    object(stdClass)[15]
    public ‘guidProductId’ => string ‘752b5258-be97-11e4-bb6a-28d244200550’ (length=4)
    public ‘strName’ => string ‘ADSL SAIX Unshaped’ (length=18)
    public ‘2’ =>
    * etc.
    *
    */
    case “getProducts”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getProducts.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Get all services for specified client
    *
    * @param array $d array(“strSessionId”, “guidClientId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[17]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrServices’ =>
    object(stdClass)[16]
    public ‘0’ =>
    object(stdClass)[4]
    public ‘guidServiceId’ => string ‘56352fea-bf96-11e4-9b72-28d244200550’ (length=36)
    public ‘strDescription’ => string ‘27514793245@yourmobile’ (length=22)
    public ‘guidProductId’ => string ‘752ce7fb-be97-11e4-bb6a-28d244200550’ (length=36)
    public ‘intSuspendReasonId’ => string ‘1’ (length=1)
    public ‘intCurrentQuantity’ => string ‘1’ (length=1)
    public ‘intQuantity’ => string ‘1’ (length=1)
    public ‘strDateEnd’ => null
    public ‘1’ =>
    object(stdClass)[46]
    public ‘guidServiceId’ => string ‘56353072-bf96-11e4-9b72-28d244200550’ (length=36)
    public ‘strDescription’ => string ‘27514793245@yourmobile’ (length=22)
    public ‘guidProductId’ => string ‘752ce7fb-be97-11e4-bb6a-28d244200550’ (length=36)
    public ‘intSuspendReasonId’ => string ‘1’ (length=1)
    public ‘intCurrentQuantity’ => string ‘1’ (length=1)
    * etc.
    *
    */
    case “getServicesByClient”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getServicesByClient.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Get all unassigned SIM services
    *
    * @param array $d array(“strSessionId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[43]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrServices’ =>
    object(stdClass)[45]
    public ‘0’ =>
    object(stdClass)[44]
    public ‘guidServiceId’ => string ‘3a4870d4-c0ed-11e4-bfb7-28d244200550’ (length=36)
    public ‘strDescription’ => string ‘2551884322 / 27514793245’ (length=24)
    public ‘guidProductId’ => string ‘752caba0-be97-11e4-bb6a-28d244200550’ (length=36)
    public ‘strDateEnd’ => null
    public ‘1’ =>
    object(stdClass)[7]
    public ‘guidServiceId’ => string ‘3a486ff6-c0ed-11e4-bfb7-28d244200550’ (length=36)
    * etc.
    *
    */
    case “getAllUnassignedSimServices”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getAllUnassignedSimServices.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Get service details by id
    *
    * @param array $d array(“strSessionId”, “guidServiceId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[16]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrServices’ =>
    object(stdClass)[59]
    public ‘0’ =>
    object(stdClass)[58]
    public ‘guidServiceId’ => string ‘3a487248-c0ed-11e4-bfb7-28d244200550’ (length=36)
    public ‘strDescription’ => string ‘27514793245’ (length=11)
    public ‘guidProductId’ => string ‘752caba0-be97-11e4-bb6a-28d244200550’ (length=36)
    public ‘intSuspendReasonId’ => null
    public ‘intCurrentQuantity’ => string ‘1’ (length=1)
    public ‘intQuantity’ => string ‘1’ (length=1)
    public ‘strDateEnd’ => null
    *
    */
    case “getServiceById”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getServiceById.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Get the session details of a connection/data related service. i.e. ADSL and mobile connections
    *
    * @param array $d array(“strSessionId”, “guidServiceId”)
    *
    * @return object json encoded with:
    *
    *object(stdClass)[109]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrSessions’ =>
    object(stdClass)[17]
    public ‘0’ =>
    object(stdClass)[110]
    public ‘strUsername’ => string ‘SYS74838@zxcvz’ (length=16)
    public ‘strNasPort’ => string ‘2015826083’ (length=10)
    public ‘strNASIPAddress’ => string ‘196.43.47.14’ (length=12)
    public ‘strPhoneNumber’ => string ‘0411548969’ (length=10)
    public ‘strStartTime’ => string ‘2015-02-26 16:56:50’ (length=19)
    public ‘strStopTime’ => string ‘2015-03-01 14:22:57’ (length=19)
    public ‘strDuration’ => string ’69h 26m’ (length=7)
    public ‘strTerminateCause’ => string ‘Session-Timeout’ (length=15)
    public ‘strFramedIP’ => string ‘105.518.7.518’ (length=13)
    public ‘intUploadMB’ => string ‘102.366’ (length=7)
    public ‘intDownloadMB’ => string ‘1421.199’ (length=8)
    public ‘intTotalMB’ => string ‘1523.565’ (length=8)
    public ‘1’ =>
    object(stdClass)[111]
    public ‘strUsername’ => string ‘SYS74838@zxcvz’ (length=16)
    public ‘strNasPort’ => string ‘2015826083’ (length=10)
    public ‘strNASIPAddress’ => string ‘184.43.57.14’ (length=12)
    * etc.
    *
    */
    case “getServiceSessionDetailsById”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getServiceSessionDetailsById.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Get the daily usage details breakdown for the current month of a connection/data related service. i.e. ADSL and mobile connections
    *
    * @param array $d array(“strSessionId”, “guidServiceId”)
    *
    * @return object json encoded with:
    *
    *object(stdClass)[4]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘strAccountStartDate’ => string ‘2014-11-01’ (length=10)
    public ‘strDate’ => string ‘Mar 2015’ (length=8)
    public ‘intTotal’ => float 2099.74453258
    public ‘intTotalUp’ => float 338.34212875
    public ‘intTotalDown’ => float 1761.40240384
    public ‘arrUsage’ =>
    object(stdClass)[18]
    public ‘1’ =>
    object(stdClass)[144]
    public ‘intTotal’ => int 343
    public ‘intUp’ => int 77
    public ‘intDown’ => int 266
    public ‘2’ =>
    object(stdClass)[116]
    public ‘intTotal’ => int 674
    public ‘intUp’ => int 87
    * etc.
    *
    */
    case “getServiceUsageDetailsById”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/getServiceUsageDetailsById.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    * Create a new ADSL, Mobile, or DSL Line service
    *
    * @param array $d array(“strSessionId”, “guidClientId”, “guidProductId”) etc etc
    *
    * @return object json encoded with:
    *
    * object(stdClass)[17]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘arrServices’ =>
    object(stdClass)[109]
    public ‘0’ =>
    object(stdClass)[108]
    public ‘guidServiceId’ => string ‘1bbe29b6-c743-11e4-95d8-28d244200550’ (length=36)
    *
    * etc.
    *
    public ‘decBalance’ => float 1056.28
    *
    */
    case “createService”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/createService.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->put($Url, $d);

    break;
    }
    /**
    *
    *
    * @param array $d array(“strSessionId”, “guidServiceId”, “guidProductId”, “intQuantity”, “strDateStart”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[106]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    *
    */
    case “funcServiceChanges”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/funcServiceChanges.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->put($Url, $d);

    break;
    }
    /**
    *
    *
    * @param array $d array(“strSessionId”, “guidServiceId”, “guidProductId”, “intQuantity”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[146]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    *
    *
    */
    case “funcTopups”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/funcTopups.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->put($Url, $d);

    break;
    }
    /**
    *
    *
    * @param array $d array(“strSessionId”, “guidServiceId”)
    *
    * @return object json encoded with:
    * object(stdClass)[146]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘Accepted’ (length=8)
    public ‘strMessage’ => string ‘Successful POD’s:1 Failed POD’s:0 OK’ (length=34)
    *
    */
    case “funcPod”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/funcPod.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    *
    *
    * @param array $d array(“strSessionId”, “guidServiceId”)
    *
    * @return object json encoded with:
    * object(stdClass)[146]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    *
    */
    case “funcSuspend”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/funcSuspend.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    *
    *
    * @param array $d array(“strSessionId”, “guidServiceId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)#146 (3) {
    [“intCode”]=>
    int(200)
    [“strStatus”]=>
    string(2) “OK”
    [“strMessage”]=>
    NULL
    *
    */
    case “funcFixLine”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/funcFixLine.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    /**
    *
    *
    * @param array $d array(“strSessionId”, “guidServiceId”)
    *
    * @return object json encoded with:
    * public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘strDownloadCurrentSpeed’ => string ‘10239 kbps’
    public ‘strDownloadInterference’ => string ‘12.2 dB’
    public ‘strDownloadNoiseRatio’ => string ‘12.7 dB’
    public ‘strUploadCurrentSpeed’ => string ‘1021 kbps’
    public ‘strUploadInterference’ => string ‘16.9 dB’
    public ‘strUploadNoiseRatio’ => string ‘12.3 dB’

    *
    */
    case “funcCheckLine”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/funcCheckLine.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }

    /**
    *
    *
    * @param array $d array(“strSessionId”, “guidServiceId”)
    *
    * @return object json encoded with:
    *
    * object(stdClass)[104]
    public ‘intCode’ => int 200
    public ‘strStatus’ => string ‘OK’ (length=2)
    public ‘strMessage’ => null
    public ‘strPassword’ => string ‘gsd5d1UsHCq’ (length=10)
    *
    */
    case “funcPasswordReset”:
    {
    $Url = “https://apitest.axxess.co.za/” . “calls/rsapi/funcPasswordReset.json”;
    $curl->setBasicAuthentication($Username, $Password);
    $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
    $curl->setOpt(CURLOPT_SSL_VERIFYHOST,2);
    $curl->get($Url, $d);

    break;
    }
    default:
    {
    $response->intCode = 500;
    $response->message = “NADA Requested, missing required data or REST Call is not valid!”;
    }
    }

    $response->curl = $curl;

    if ($curl->error)
    {
    $response->intCode = $curl->error_code;
    }
    else
    {
    $response->json = $curl->response;
    $result = json_decode($curl->response);

    if (null === $result)
    {
    $response->intCode = 500;
    $response->message = “Too many nested arrays or error decoding.”;
    }
    else
    {
    $response->intCode = $result->intCode;
    $response->message = isset($result->message) ? $result->message : null;
    $response->object = $result;
    }
    }

    if ($response->intCode != 200)
    {
    $response->hasError = true;
    }

    $curl->close();
    return $response;
    }

    class Response
    {
    public $intCode;

    public $hasError = false;

    public $message;

    public $curl;

    public $json;

    public $object;
    }

    /**
    * Class Curl
    *
    * A handle for curl calls and some helper functions
    */
    class Curl
    {
    // TODO: set this.
    const USER_AGENT = ‘YOUR COMPANY NAME OR SOMETHING PERSONALLY IDENTIFIABLE’;

    private $_cookies = array();
    private $_headers = array();
    private $_options = array();

    private $_multi_parent = false;
    private $_multi_child = false;
    private $_before_send = null;
    private $_success = null;
    private $_error = null;
    private $_complete = null;

    public $curl;
    public $curls;

    public $error = false;
    public $error_code = 0;
    public $error_message = null;

    public $curl_error = false;
    public $curl_error_code = 0;
    public $curl_error_message = null;

    public $http_error = false;
    public $http_status_code = 0;
    public $http_error_message = null;

    public $request_headers = null;
    public $response_headers = null;
    public $response = null;

    /**
    * @throws \ErrorException
    */
    public function __construct()
    {
    if (!extension_loaded(‘curl’)) {
    throw new \ErrorException(‘cURL library is has not been loaded’);
    }

    $this->curl = curl_init();
    $this->setUserAgent(self::USER_AGENT);
    $this->setOpt(CURLINFO_HEADER_OUT, true);
    $this->setOpt(CURLOPT_HEADER, true);
    $this->setOpt(CURLOPT_RETURNTRANSFER, true);
    }

    /**
    * @param $url_mixed
    * @param array $data
    * @return int|mixed
    * @throws \ErrorException
    */
    public function get($url_mixed, $data = array())
    {
    if (is_array($url_mixed)) {
    $curl_multi = curl_multi_init();
    $this->_multi_parent = true;

    $this->curls = array();

    foreach ($url_mixed as $url) {
    $curl = new Curl();
    $curl->_multi_child = true;
    $curl->setOpt(CURLOPT_URL, $this->_buildURL($url, $data), $curl->curl);
    $curl->setOpt(CURLOPT_HTTPGET, true);
    $this->_call($this->_before_send, $curl);
    $this->curls[] = $curl;

    $curlm_error_code = curl_multi_add_handle($curl_multi, $curl->curl);
    if (!($curlm_error_code === CURLM_OK)) {
    throw new \ErrorException(‘cURL multi add handle error: ‘ .
    curl_multi_strerror($curlm_error_code));
    }
    }

    foreach ($this->curls as $ch) {
    foreach ($this->_options as $key => $value) {
    $ch->setOpt($key, $value);
    }
    }

    do {
    $status = curl_multi_exec($curl_multi, $active);
    } while ($status === CURLM_CALL_MULTI_PERFORM || $active);

    foreach ($this->curls as $ch) {
    $this->exec($ch);
    }
    } else {
    $this->setopt(CURLOPT_URL, $this->_buildURL($url_mixed, $data));
    $this->setopt(CURLOPT_HTTPGET, true);
    return $this->exec();
    }
    }

    /**
    * @param $url
    * @param array $data
    * @return int|mixed
    */
    public function post($url, $data = array())
    {
    $this->setOpt(CURLOPT_URL, $this->_buildURL($url));
    $this->setOpt(CURLOPT_POST, true);
    $this->setOpt(CURLOPT_POSTFIELDS, $this->_postfields($data));
    return $this->exec();
    }

    /**
    * @param $url
    * @param array $data
    * @return int|mixed
    */
    public function put($url, $data = array())
    {
    $this->setOpt(CURLOPT_URL, $url);
    $this->setOpt(CURLOPT_CUSTOMREQUEST, ‘PUT’);
    $this->setOpt(CURLOPT_POSTFIELDS, http_build_query($data));
    return $this->exec();
    }

    /**
    * @param $url
    * @param array $data
    * @return int|mixed
    */
    public function patch($url, $data = array())
    {
    $this->setOpt(CURLOPT_URL, $this->_buildURL($url));
    $this->setOpt(CURLOPT_CUSTOMREQUEST, ‘PATCH’);
    $this->setOpt(CURLOPT_POSTFIELDS, $data);
    return $this->exec();
    }

    /**
    * @param $url
    * @param array $data
    * @return int|mixed
    */
    public function delete($url, $data = array())
    {
    $this->setOpt(CURLOPT_URL, $this->_buildURL($url, $data));
    $this->setOpt(CURLOPT_CUSTOMREQUEST, ‘DELETE’);
    return $this->exec();
    }

    /**
    * @param $username
    * @param $password
    */
    public function setBasicAuthentication($username, $password)
    {
    $this->setOpt(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    $this->setOpt(CURLOPT_USERPWD, $username . ‘:’ . $password);
    }

    /**
    * @param $key
    * @param $value
    */
    public function setHeader($key, $value)
    {
    $this->_headers[$key] = $key . ‘: ‘ . $value;
    $this->setOpt(CURLOPT_HTTPHEADER, array_values($this->_headers));
    }

    /**
    * @param $user_agent
    */
    public function setUserAgent($user_agent)
    {
    $this->setOpt(CURLOPT_USERAGENT, $user_agent);
    }

    /**
    * @param $referrer
    */
    public function setReferrer($referrer)
    {
    $this->setOpt(CURLOPT_REFERER, $referrer);
    }

    /**
    * @param $key
    * @param $value
    */
    public function setCookie($key, $value)
    {
    $this->_cookies[$key] = $value;
    $this->setOpt(CURLOPT_COOKIE, http_build_query($this->_cookies, ”, ‘; ‘));
    }

    /**
    * @param $cookie_file
    */
    public function setCookieFile($cookie_file)
    {
    $this->setOpt(CURLOPT_COOKIEFILE, $cookie_file);
    }

    /**
    * @param $cookie_jar
    */
    public function setCookieJar($cookie_jar)
    {
    $this->setOpt(CURLOPT_COOKIEJAR, $cookie_jar);
    }

    /**
    * @param $option
    * @param $value
    * @param null $_ch
    * @return bool
    */
    public function setOpt($option, $value, $_ch = null)
    {
    $ch = is_null($_ch) ? $this->curl : $_ch;

    $required_options = array(
    CURLINFO_HEADER_OUT => ‘CURLINFO_HEADER_OUT’,
    CURLOPT_HEADER => ‘CURLOPT_HEADER’,
    CURLOPT_RETURNTRANSFER => ‘CURLOPT_RETURNTRANSFER’,
    );

    if (in_array($option, array_keys($required_options), true) && !($value === true)) {
    trigger_error($required_options[$option] . ‘ is a required option’, E_USER_WARNING);
    }

    $this->_options[$option] = $value;
    return curl_setopt($ch, $option, $value);
    }

    /**
    * @param bool $on
    */
    public function verbose($on = true)
    {
    $this->setOpt(CURLOPT_VERBOSE, $on);
    }

    /**
    *
    */
    public function close()
    {
    if ($this->_multi_parent) {
    foreach ($this->curls as $curl) {
    curl_close($curl->curl);
    }
    }

    if (is_resource($this->curl)) {
    curl_close($this->curl);
    }
    }

    /**
    * @param $function
    */
    public function beforeSend($function)
    {
    $this->_before_send = $function;
    }

    /**
    * @param $callback
    */
    public function success($callback)
    {
    $this->_success = $callback;
    }

    /**
    * @param $callback
    */
    public function error($callback)
    {
    $this->_error = $callback;
    }

    /**
    * @param $callback
    */
    public function complete($callback)
    {
    $this->_complete = $callback;
    }

    /**
    * @param $url
    * @param array $data
    * @return string
    */
    private function _buildURL($url, $data = array())
    {
    return $url . (empty($data) ? ” : ‘?’ . http_build_query($data));
    }

    /**
    * @param $data
    * @return array|string
    */
    private function _postfields($data)
    {
    if (is_array($data)) {
    if (is_array_multidim($data)) {
    $data = http_build_multi_query($data);
    } else {
    foreach ($data as $key => $value) {
    if (is_array($value) && empty($value)) {
    $data[$key] = ”;
    }
    }
    }
    }

    return $data;
    }

    /**
    * @param null $_ch
    * @return int|mixed
    */
    protected function exec($_ch = null)
    {
    $ch = is_null($_ch) ? $this : $_ch;

    if ($ch->_multi_child) {
    $ch->response = curl_multi_getcontent($ch->curl);
    } else {
    $ch->response = curl_exec($ch->curl);
    }

    $ch->curl_error_code = curl_errno($ch->curl);
    $ch->curl_error_message = curl_error($ch->curl);
    $ch->curl_error = !($ch->curl_error_code === 0);
    $ch->http_status_code = curl_getinfo($ch->curl, CURLINFO_HTTP_CODE);
    $ch->http_error = in_array(floor($ch->http_status_code / 100), array(4, 5));
    $ch->error = $ch->curl_error || $ch->http_error;
    $ch->error_code = $ch->error ? ($ch->curl_error ? $ch->curl_error_code : $ch->http_status_code) : 0;

    $ch->request_headers = preg_split(‘/\r\n/’, curl_getinfo($ch->curl, CURLINFO_HEADER_OUT), null, PREG_SPLIT_NO_EMPTY);
    $ch->response_headers = ”;
    if (!(strpos($ch->response, “\r\n\r\n”) === false)) {
    list($response_header, $ch->response) = explode(“\r\n\r\n”, $ch->response, 2);
    if ($response_header === ‘HTTP/1.1 100 Continue’) {
    list($response_header, $ch->response) = explode(“\r\n\r\n”, $ch->response, 2);
    }
    $ch->response_headers = preg_split(‘/\r\n/’, $response_header, null, PREG_SPLIT_NO_EMPTY);
    }

    $ch->http_error_message = $ch->error ? (isset($ch->response_headers[‘0’]) ? $ch->response_headers[‘0’] : ”) : ”;
    $ch->error_message = $ch->curl_error ? $ch->curl_error_message : $ch->http_error_message;

    if (!$ch->error) {
    $ch->_call($this->_success, $ch);
    } else {
    $ch->_call($this->_error, $ch);
    }

    $ch->_call($this->_complete, $ch);

    return $ch->error_code;
    }

    /**
    * @param $function
    */
    private function _call($function)
    {
    if (is_callable($function)) {
    $args = func_get_args();
    array_shift($args);
    call_user_func_array($function, $args);
    }
    }

    /**
    *
    */
    public function __destruct()
    {
    $this->close();
    }
    }

    /**
    * @param $array
    * @return bool
    */
    function is_array_assoc($array)
    {
    return (bool)count(array_filter(array_keys($array), ‘is_string’));
    }

    /**
    * @param $array
    * @return bool
    */
    function is_array_multidim($array)
    {
    if (!is_array($array)) {
    return false;
    }

    return !(count($array) === count($array, COUNT_RECURSIVE));
    }

    /**
    * @param $data
    * @param null $key
    * @return string
    */
    function http_build_multi_query($data, $key = null)
    {
    $query = array();

    if (empty($data)) {
    return $key . ‘=’;
    }

    $is_array_assoc = is_array_assoc($data);

    foreach ($data as $k => $value) {
    if (is_string($value) || is_numeric($value)) {
    $brackets = $is_array_assoc ? ‘[‘ . $k . ‘]’ : ‘[]’;
    $query[] = urlencode(is_null($key) ? $k : $key . $brackets) . ‘=’ . rawurlencode($value);
    } else if (is_array($value)) {
    $nested = is_null($key) ? $k : $key . ‘[‘ . $k . ‘]’;
    $query[] = http_build_multi_query($value, $nested);
    }
    }

    return implode(‘&’, $query);
    }