srdorado/siigo-client-php

Consumer client of the siigo api (https://siigoapi.docs.apiary.io/#)


Keywords
php, api, siigo, coverage, packaging, test
License
MIT

Documentation

Siigo client API

By srdorado

License Packagist PHP Version Support Packagist Version Packagist Downloads Composer dependencies Test workflow Codecov composer.lock

This library consumes the Siigo API enabling:

  • Create, update and consult Sales Invoices.

  • Sending sales invoices to the Dian and customers.

  • Create, consult, update and delete Clients (Third Parties) and Products/Services.

  • Create and consult Accounting Receipts, Credit Notes and Cash Receipts.

  • Consult Inventory of a product in Siigo Cloud.

Installation

composer require srdorado/siigo-client-php

How to use it?

  • Get token
    function getToken()
    {
        // Create client token
        $clientFactory = new \Srdorado\SiigoClient\Factory\ClientFactory();
        $clientTokenFactory = $clientFactory->create(\Srdorado\SiigoClient\Enum\ClientType::TOKEN);
        $clientToken = $clientTokenFactory->create();
        $clientToken->setBaseUrl('https://api.siigo.com/');

        // Create entity token
        $entity = new \Srdorado\SiigoClient\Model\Entity(\Srdorado\SiigoClient\Enum\ClientType::TOKEN);
        $entity->setData(
            [
                'username' => '',
                'access_key' => ''
            ]
        );

        // Request token
        return $clientToken->getToken($entity);
    }
  • Create product
    function getCustomClient()
    {
        // generate token
        $token = $this->getToken();

        // Create client
        $clientFactory = new \Srdorado\SiigoClient\Factory\ClientFactory();
        $clientProductFactory = $clientFactory->create(\Srdorado\SiigoClient\Enum\ClientType::PRODUCT);
        $clientProduct = $clientProductFactory->create();
        $clientProduct->setBaseUrl('https://api.siigo.com/');
        $clientProduct->setAccessKey($token);


        return $clientProduct;
    }



    function create()
    {
        $clientProduct = $this->getCustomClient();

        $entity = new \Srdorado\SiigoClient\Model\Entity(\Srdorado\SiigoClient\Enum\ClientType::PRODUCT);

        $dataEntity = $this->getExampleCompleteProduct();

        $entity->setData($dataEntity);

        $productId = $clientProduct->create($entity);

        $this->assertTrue(true);
    }

Versioning

Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.

License

This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.

Donations

paypal