New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

vdhicts/wefact-api-client

A client for the API of WeFact
4,318 4
Install
composer require vdhicts/wefact-api-client
Latest Version:v7.0.0
PHP:>=8.2
Laravel:11 · 12 · 13
Older releases:8 · 9 · 10
License:MIT
Last Updated:Mar 18, 2026
Links: GitHub  ·  Packagist
Maintainer: vdhicts

wefact-api-client

Easy WeFact API client

Requirements

This package requires at least PHP 8.2.

Installation

This package can be used in any PHP project or with any framework.

You can install the package via composer:

composer require vdhicts/wefact-api-client

Usage

This package is just an easy client for using the WeFact API. Please refer to the API documentation for more information about the requests.

Getting started

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');
}

Or if you need to provide extra parameters (i.e. for a 'add' request):

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

Extending the client

You can extend the client and implement your own endpoints:

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);
    }    
}

Handling errors

A Response object will always be returned. See Error handling of the Http Client.

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

Laravel

This package can be easily used in any Laravel application. I would suggest adding your credentials to the .env file of the project:

WEFACT_API_KEY=apikey

Next create a config file wefact.php in /config:

<?php

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

Then initialize the client with the API key:

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

In the future I might make a Laravel specific package which uses this package.

Contribution

Any contribution is welcome, but it should meet the PSR-12 standard and please create one pull request per feature/bug. In exchange, you will be credited as contributor on this page.

Security

If you discover any security related issues in this or other packages of Vdhicts, please email security@vdhicts.nl instead of using the issue tracker.

Support

This package isn't an official package from WeFact, so they probably won't offer support for it. If you encounter a problem with this client or has a question about it, feel free to open an issue on GitHub.

License

This package is open-sourced software licensed under the MIT license.

Related Packages

vdhicts/hihaho-api-client

A client for the API of HiHaHo

18,372 0
devio/pipedrive

Complete Pipedrive API client for PHP and/or Laravel

1,926,938 172
timkley/weaviate-php

A PHP HTTP Client for the Weaviate REST API

88,751 36
iivannov/larasquare

Simple and extensible Foursquare API PHP Client with Laravel Support based on Gu...

5,067 8

Version History

Version Released PHP Laravel License
v7.0.0 >=8.2 ^11.0|^12.0|^13.0 MIT
v6.0.0 >=8.2 ^11.0|^12.0 MIT
v5.0.0 ^8.1 ^8.0|^9.0|^10.0|^11.0 MIT
v4.0.0 ^7.4|^8.0 ^8.0|^9.0|^10.0 MIT
v3.0.0 ^7.4|^8.0 ^8.22|^9.0 MIT