PHP code example of vdhicts / wefact-api-client

1. Go to this page and download the library: Download vdhicts/wefact-api-client 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/ */

    

vdhicts / wefact-api-client example snippets


use Vdhicts\WeFact\WeFact;
use Vdhicts\WeFact\WeFactRequest;
use Vdhicts\WeFact\Enums\WeFactController;

// Initialize the client
$client = new WeFact($apiKey);

// Perform the request
$request = new WeFactRequest(WeFactController::CREDITOR, 'list');
$response = $client->request($request);

if ($response->ok()) {
    $response->json('creditors');
}

$request = new WeFactRequest(WeFactController::CREDITOR, 'add', [
    'CompanyName' => 'Vdhicts',
]);
$response = $client->request($request);

use Vdhicts\WeFact\Enums\WeFactController;
use Vdhicts\WeFact\WeFact;
use Vdhicts\WeFact\WeFactRequest;

class Debtor extends WeFact 
{
    public function show(string $debtorCode): Response
    {
        $request = new WeFactRequest(WeFactController::DEBTOR, 'show', [
            'DebtorCode' => $debtorCode,
        ]);
    
        return $this->$request($request);
    }    
}

if ($response->failed()) {
    var_dump($response->serverError());
}



return [
    'api_key' => env('WEFACT_API_KEY'),
];

$client = new \Vdhicts\WeFact\WeFact(config('wefact.api_key'));