Php rest api

I wrote a small framework for epicor rest in php just a helper library based off our .net one. It’s not super rounded out only built what I needed as it’s a middle ground solution, but still might help you get started.
EpicorRESTLib.php.txt (8.7 KB)

usage would be similar to below

protected function InvoiceLookup($message = "")
    {
        //Instanciate
        $epicorREST = new EpicorRESTLib(WEI_Options::getOption("HostUrl"), WEI_Options::getOption("EpicorInstance"), WEI_Options::getOption("EpicorUsername"), WEI_Options::getOption("EpicorPassword"));
        //Call Settings allow Plant, Company and such this can be passed to any call as an optoinal param
        $callSettings = new CallSettings(WEI_Options::getOption("EpicorCompany"),"","",WEI_Options::getOption("EpicorPlant"));
        
        $baqParams['pCustID'] = $_POST['epicor_custid'];
        $baqParams['pInvoiceNum'] = $_POST['epicor_invoicenum'];

        $aged = json_decode($epicorREST->GetBAQResults("WP-PLUGIN-ARAging", $baqParams, $callSettings))->value;
        
        $baqParams['$top'] = 25;
        $baqParams['$skip'] = 0;
        $data = json_decode($epicorREST->GetBAQResults("WP-PLUGIN-InvoiceStatus", $baqParams, $callSettings))->value;

        if(count($aged) > 0 || count($data) > 0)
        {
            include_once WEI_ABSPATH . "includes/templates/wei-template-shortcode-invoice-status.php";
        }
        else
        {
            return $this->LookupForm("Unable to obtain invoice status.<br />".json_decode($epicorREST->ErrorMessage())->ErrorMessage);
        }
    }
6 Likes