Expenses API

Hi Hillel,

is there any REST API for expenses or am I trying something that will never work?

$expense = new stdClass;
$expense->vendor_id=21; // Stripe
$expense->amount=number_format((float)($fee / 100),2);
$expense->public_notes="Frais de transaction du payment processor pour le transfert : $transfert_id";
$response = sendRequestInvoiceNinja(INVOICE_NINJA_TOKEN,'expenses', $expense, "POST");

if (!function_exists("sendRequestInvoiceNinja")) {
    function sendRequestInvoiceNinja($token, $url, $data, $type = 'POST')
    {
        $url = "https://facturation.xxxxxxxxx.com/api/v1/" . $url;
        $data = json_encode($data);
        $curl = curl_init();
        $opts = [ CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST => $type,
        CURLOPT_POST => $type === 'POST' ? 1 : 0,
        CURLOPT_POSTFIELDS => $data,
        CURLOPT_HTTPHEADER  => [
        'Content-Type: application/json',
        'Content-Length: ' . strlen($data),
        'X-Ninja-Token: '.$token,
        ],
        ];
        curl_setopt_array($curl, $opts);
        $response = curl_exec($curl);
        //die($response);
        curl_close($curl);
        return json_decode($response);
    }
}

I have added the sendRequestInvoiceNinja function but the problem is not there, it’s working fine with all the other API.

Am I missing an essential parameter?

Best regards,

Expenses aren’t yet supported in our API, it will be added in a future release.

Oh, I thought the way it was built the REST API was built automatically with the objects. Didn’t check under the hood :wink:

I’ll simply add the record to the database then.

Best regards.