alphaolomi/simplify-vfd

Simplify VFD

v0.1.0 2024-06-13 09:41 UTC

This package is auto-updated.

Last update: 2024-07-08 03:22:44 UTC


README

Simplify VFD for PHP

Latest Version on Packagist Tests Total Downloads codecov

Simplify VFD is a PHP library to interact with the Simplify VFD API. This library provides a simple and easy-to-use interface to integrate VFD services into your PHP applications.

Features

  • User Authentication: Authenticate users and obtain access tokens.
  • Invoice Management: Create, retrieve, and manage invoices.
  • Environment Configuration: Switch between live and stage environments.
  • HTTP Client Integration: Uses Guzzle HTTP client for making API requests.
  • Custom GUID Generation: Utility function for generating unique identifiers.

Installation

You can install the package via Composer:

composer require alphaolomi/simplify-vfd

Configuration

The SimplifyVfd class requires a configuration array with the following keys:

  • environment: The environment to use (live or stage).
  • username: Your Simplify VFD username.
  • password: Your Simplify VFD password.

Usage

Initializing the Service

use Alphaolomi\SimplifyVfd\SimplifyVfd;

$config = [
    'environment' => 'stage', // or 'live'
    'username' => 'your_username',
    'password' => 'your_password',
];
$service = new SimplifyVfd($config, $client);

User Login

$data = [
    'username' => 'your_username',
    'password' => 'your_password'
];

$response = $service->userLogin($data);
print_r($response);

Create Issued Invoice

$data = [
    'dateTime' => date('Y-m-d'),
    'customer' => [
        'identificationType' => 'ID',
        'identificationNumber' => '1234567890',
        'vatRegistrationNumber' => '123456789',
        'name' => 'Customer Name',
        'mobileNumber' => '255123456789',
        'email' => 'customer@example.com',
    ],
    'invoiceAmountType' => 'GROSS',
    'items' => [
        [
            'itemName' => 'Product 1',
            'quantity' => 1,
            'price' => 100.00
        ]
    ],
    'payments' => [
        [
            'paymentType' => 'CASH',
            'amount' => 100.00
        ]
    ],
    'partnerInvoiceId' => 'unique-invoice-id'
];

$response = $service->createIssuedInvoice($data);
print_r($response);

Get Invoice by Partner Invoice ID

$partnerInvoiceId = 'unique-invoice-id';

$response = $service->getInvoiceByPartnerInvoiceId($partnerInvoiceId);
print_r($response);

Testing

Using PestPHP for testing, Code coverage is generated by PHPUnit. Codecov is used to generate code coverage reports and badges.

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.