1. Go to this page and download the library: Download rpsimao/invoicexpress-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$client = new InvoiceXpressAPI();
$api_key = $client->getAPIKey('my-username', 'my-password');
....
//later in the query
....
$client->setQuery(['api_key' => $api_key]);
....
//Accepts a flag (true or false[default])
InvoiceXpressClients::getAllClientsFromAPI(true);
class User extends Model
{
.......
//Get the InvoiceXpress Client record associated with the user.
public function invoicexpress()
{
return $this->hasOne('InvoiceXpressClients');
}
use rpsimao\InvoiceXpressAPI\Service\InvoiceXpressAPI;
//Making a GET REQUEST
$client = new InvoiceXpressAPI();
$client->setMethod('GET');
$client->setUrl(config('invoicexpress.my_url'));
$client->setEndpoint(config('invoicexpress.endpoints.clients.list_all'));
$client->setQuery(['api_key' => config('invoicexpress.api_key')]);
$response = $client->talkToAPI();
.....
// Another GET Request to generate a PDF for an invoice
$client = new InvoiceXpressAPI();
$client->setMethod('get');
$client->setUrl(config('invoicexpress.my_url'));
$client->setEndpoint(
endpoint_replace(['12759480'], config('invoicexpress.endpoints.invoices.generate_pdf'))
);
$client->setQuery([
'api_key' => config('invoicexpress.api_key'),
'invoice-id' => '12759480',
'second_copy' => true
]);
$response = $client->talkToAPI();
//Making a POST REQUEST
// Creating a new Client
client = new InvoiceXpressAPI();
$client->setMethod('post');
$client->setUrl(config('invoicexpress.my_url'));
$client->setEndpoint( config('invoicexpress.endpoints.clients.create'));
$client->setQuery([
'api_key' => config('invoicexpress.api_key'),
'client' => [
'name' => 'My name',
'code' => 'My Client Code',
'email' => '[email protected]'
//.... insert more values ....
]
]);
$response = $client->talkToAPI();
//Do whatever you need with the response
//Making a PUT REQUEST
$client = new InvoiceXpressAPI();
$client->setMethod('put');
$client->setUrl(config('invoicexpress.my_url'));
$client->setEndpoint(endpoint_replace(['123456789'], config('invoicexpress.endpoints.clients.update')));
$client->setQuery([
'api_key' => config('invoicexpress.api_key'),
'client-id' => '123456789',
'client' => [
'name' => 'My awesome Client',
'code' => '123',
'phone' => 999888777
//.... insert more values ....
]
]);
$response = $client->talkToAPI();
//Do whatever you need with the response
class GetTest extends TestCase {
// Use your own credentials|data to run the tests
protected $url = '';
protected $api_key = '';
protected $username = '';
protected $password = '';
protected $client_id = '';
protected $client_name = '';
protected $client_code = '';
protected $client_phone = '';
protected $invoice = '';
.......
.....
$client = new InvoiceXpressAPI();
$client->setMsgFormat('json');
......