PHP code example of tsukiro / openfactura-api-sdk

1. Go to this page and download the library: Download tsukiro/openfactura-api-sdk 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/ */

    

tsukiro / openfactura-api-sdk example snippets


    


Instance = new Tsukiro\Client\Api\OpenFacturaApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$body = new \Tsukiro\Client\Model\DTERequest(); // \Tsukiro\Client\Model\DTERequest | 
$apikey = "apikey_example"; // string | openfactura apikey

try {
    $result = $apiInstance->DocumentEmit($body, $apikey);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->v2DteDocumentPost: ', $e->getMessage(), PHP_EOL;
}

$apiInstance = new Tsukiro\Client\Api\OpenFacturaApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$body = new \Tsukiro\Client\Model\DocumentReceivedFilter(); // \Tsukiro\Client\Model\DocumentReceivedFilter | 
$apikey = "apikey_example"; // string | openfactura apikey

try {
    $result = $apiInstance->getReceivedDTE($body, $apikey);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->v2DteDocumentReceivedPost: ', $e->getMessage(), PHP_EOL;
}

$apiInstance = new Tsukiro\Client\Api\OpenFacturaApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$body = new \Tsukiro\Client\Model\DocumentIssuedFilter(); // \Tsukiro\Client\Model\DocumentIssuedFilter | 
$apikey = "apikey_example"; // string | openfactura apikey

try {
    $result = $apiInstance->getIssuedDTE($body, $apikey);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->v2DteDocumentReceivedPost: ', $e->getMessage(), PHP_EOL;
}

$apiInstance = new Tsukiro\Client\Api\OpenFacturaApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$rut = "rut_example"; // string | 
$type = "type_example"; // string | 
$document_number = "document_number_example"; // string | 
$value = "value_example"; // string | 
$apikey = "apikey_example"; // string | openfactura apikey

try {
    $result = $apiInstance->getDTEDocument($rut, $type, $document_number, $value, $apikey);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->v2DteDocumentRutTypeDocumentNumberValueGet: ', $e->getMessage(), PHP_EOL;
}