Programske biblioteke omogućuju pretraživanje podataka o poduzetnicima na temelju unesenog PDV EU broja. Trenutno su API biblioteke dostupne za sljedeće programske jezike:

  • .NET (C#, Visual Basic)
  • Java
  • JavaScript (Node.js)
  • PHP
  • Piton
  • C/C++

API pruža sljedeće značajke:

  • getVIESData – funkciju potvrđivanja aktivnosti EU PDV broja koji je dodijelila bilo koja država članica Europske unije,
  • getAccountStatus – funkcija za dohvaćanje ažuriranih podataka o korisničkom računu.

Integracija

Sve biblioteke s izvornim kodovima dostupne su za preuzimanje na preuzimanje datoteka stranica. Osim toga, izvorni kod za knjižnice također je dostupan u našem službenom repozitoriju na Github.

Način integracije biblioteke ovisi o odabranom programskom jeziku. Za one jezike koji podržavaju upravljanje knjižnicom na temelju središnjeg repozitorija, moguće ga je koristiti.

// NuGet Gallery
// https://www.nuget.org/packages/VIESAPI.VIESAPIClient

PM> Install-Package VIESAPI.VIESAPIClient
// No central repository support
// Maven
// https://viesapi.eu/maven/

<repository>
    <id>viesapi</id>
    <url>https://viesapi.eu/maven/releases</url>
</repository>

<dependency>
    <groupId>eu.viesapi</groupId>
    <artifactId>viesapi-client</artifactId>
    <version>1.2.6</version>
</dependency>
// NPM
// https://www.npmjs.com/package/viesapi-client

npm install viesapi-client
// Packagist (Composer)
// https://packagist.org/packages/viesapi/client

composer require viesapi/client
# No central repository support

pip install viesapi-python-client-1.2.6.zip
' No central repository support

Ovjera

Kako bi se izvršila ispravna autentifikacija, ispravne vrijednosti za id i key parametri se trebaju osigurati tijekom izgradnje klijentovog objekta. The id parametar treba sadržavati važeći identifikator ključa koji se koristi za autorizaciju. The key parametar treba sadržavati valjanu vrijednost ključa koji se koristi za autorizaciju. Identifikator ključa i ključ generira korisnik nakon što se prijavi na svoj račun na viesapi.eu portal. Proces generiranja ključeva i identifikatora detaljno je opisan gore.

Sljedeći primjer ilustrira kako koristiti funkcije knjižnice:

using viesapiLibrary.dll;

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
VIESAPIClient viesapi = new VIESAPIClient("id", "key");
#include "viesapi.h"

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
VIESAPIClient* viesapi = NULL;
viesapi_new_prod(&viesapi, "id", "key");
import pl.viesapi.client.*;

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
VIESAPIClient viesapi = new VIESAPIClient("id", "key");
var VIESAPI = require('viesapiclient');

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
var viesapi = new VIESAPI.VIESAPIClient('id', 'key');
require_once 'VIESAPI/VIESAPIClient.php';

\VIESAPI\VIESAPIClient::registerAutoloader();

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
$viesapi = new \VIESAPI\VIESAPIClient('id', 'key');
from viesapi import *
from pprint import pprint

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
viesapi = VIESAPIClient('id', 'key')
' Create the service client object
' id - a string representing the API key identifier
' key - a string representing the API key
Dim viesapi As New VIESAPIClient
viesapi.URL = "https://www.viesapi.eu/api"
viesapi.Id = "id"
viesapi.Key = "key"

Pažnja! Tijekom procesa autentifikacije koristi se trenutno vrijeme na klijentovom računalu. Stoga u slučaju problema s autentifikacijom prilikom pokušaja spajanja na sustav viesapi.eu prvo provjerite ima li računalo ili poslužitelj s kojeg se uspostavlja veza ispravno trenutno vrijeme i vremensku zonu. Više informacija o metodi koju sustav viesapi.eu koristi za provjeru autentičnosti upita možete pronaći ovdje.

Provjera EU PDV brojeva

EU PDV broj se potvrđuje pozivom na getVIESData() funkciju čiji je parametar EU PDV broj koji želimo provjeriti. Funkcija omogućuje provjeru EU PDV brojeva izdanih od strane svih država članica Europske unije.

Sljedeći primjer ilustrira kako se funkcije koriste u bibliotekama:

// A call to a method that returns data from a VIES system
VIESData vies = viesapi.GetVIESData("PL1234567890");

if (vies != null) {
	Console.WriteLine(vies);
}
else {
	Console.WriteLine("Error: " + viesapi.LastError);
}
// A call to a method that returns data from a VIES system
VIESData* vies = viesapi_get_vies_data(viesapi, "PL1234567890");

if (vies != NULL) {
	printf("Kraj: %s\n", vies->CountryCode);
	printf("VAT ID: %s\n", vies->VATNumber);
	printf("Aktywny: %d\n", vies->Valid);
}
else {
	printf("Error: %s\n", viesapi_get_last_err(viesapi));
}
// A call to a method that returns data from a VIES system
VIESData vies = viesapi.getVIESData("PL1234567890");

if (vies != null) {
	System.out.println(vies);
}
else {
	System.out.println("Error: " + viesapi.getLastError());
}
// A call to a method that returns data from a VIES system
viesapi.getVIESData('PL1234567890').then((vies) => {
	console.log(vies.toString());
}).catch((e) => {
	console.log(e.message);
});
// A call to a method that returns data from a VIES system
$vies = $viesapi->get_vies_data('PL1234567890');

if ($vies) {
	print_r($vies);
}
else {
	echo '<p>Error: ' . $viesapi->get_last_error() . '</p>';
}
# A call to a method that returns data from a VIES system
vies = viesapi.get_vies_data('PL1234567890')

if vies:
    pprint(vars(vies))
else:
    print u'Error: ' + viesapi.get_last_error()
' A call to a method that returns data from a VIES system
Dim vies As VIESData
Set vies = viesapi.GetVIESData("PL1234567890")

If vies Is Nothing Then
	Console.WriteLine("Error: {0}", viesapi.LastError)
Else
	Console.WriteLine(vies.ToString())
End If

Atributi vraćenog objekta

Detaljan opis vraćenih atributa:

  • uid – jedinstveni identifikator upita koji generira viesapi.eu,
  • countryCode – kôd zemlje u kojoj je registrirana tvrtka povezana s EU PDV brojem navedenim u upitu,
  • vatNumber – EU PDV broj provjerene tvrtke naveden u upitu,
  • valid – odgovor VIES servisa s informacijom o trenutnom EU PDV statusu provjeravanog subjekta:
    • true – EU PDV broj naveden u upitu je valjan,
    • false – EU PDV broj naveden u upitu nije valjan,
  • traderName – trgovačko ime društva,
  • traderCompanyType – uvijek vraća niz znakova '-',
  • traderAddress – adresu tvrtke na kojoj je tvrtka registrirana,
  • id – jedinstveni identifikator upita generiran od strane VIES sustava
  • date – datum izvršenja upita
  • source – izvor podataka, uvijek: http://ec.europa.eu

Dohvaćanje informacija o statusu korisničkog računa

Funkcija omogućuje preuzimanje svih osnovnih podataka o korisničkom računu koji se prikazuju nakon prijave na račun na portalu viesapi.eu. Funkcija također vraća podatke o maksimalnom broju dostupnih upita prema odabranom planu (npr. 5.000 za Poslovni plan) i ukupnom broju svih upita postavljenih u tekućem mjesecu na korisničkom računu.

Pažnja! Pozivanje funkcije čini ne povećati broj postavljenih upita.

Sljedeći primjer ilustrira kako koristiti funkcije knjižnice.

// Get current account status
AccountStatus account = viesapi.GetAccountStatus();

if (account != null) {
     Console.WriteLine(account);
}
else {
     Console.WriteLine("Error: " + viesapi.LastError);
}
// Get current account status
AccountStatus* account = viesapi_get_account_status(viesapi);

if (account != NULL) {
	printf("Plan name: %s\n", account->BillingPlanName);
	printf("Price: %.2f\n", account->SubscriptionPrice);
	printf("Number of queries: %d\n", account->TotalCount);
}
else {
	printf("Error: %s\n", viesapi_get_last_err(viesapi));
}
// Get current account status
AccountStatus account = viesapi.getAccountStatus();

if (account != null) {
     System.out.println(account);
}
else {
     System.err.println("Error: " + viesapi.getLastError());
}
// Get current account status
viesapi.getAccountStatus().then((account) => {
	console.log(account.toString());
}).catch((e) => {
	console.log(e.message);
});
// Get current account status
$account = $viesapi->get_account_status();

if ($account) {
     echo '<p>' . print_r($account, true) . '</p>';
}
else {
     echo '<p>Error: ' . $viesapi->get_last_error() . '</p>';
}
# Get current account status
account = viesapi.get_account_status()

if account:
    pprint(vars(account))
else:
    print u'Error: ' + viesapi.get_last_error()
'Get current account status
Dim account As AccountStatus
Set account = viesapi.GetAccountStatus()

If account Is Nothing Then
	Console.WriteLine("Error: {0}", viesapi.LastError)
Else
	Console.WriteLine(account.ToString())
End If

Registriranje .NET knjižnice kao COM objekta

The viesapiLibrary.dll biblioteka se može registrirati u Windows sustavu kao tzv COM objekt. Tada se funkcije biblioteke mogu referencirati iz mnogo različitih programskih jezika i gotovih aplikacija, uklj. Microsoft Excel, Access, SQL Server, Dynamics ili Visual FoxPro.

Da biste registrirali biblioteku kao COM objekt, slijedite ove korake:

  1. Preuzmite .NET biblioteka arhivirati i raspakirati na lokalni disk na bilo koje mjesto.
  2. Idite u direktorij s neraspakiranim datotekama knjižnice i pronađite com-register.bat datoteka.
  3. Odaberite com-register.bat datoteku mišem i odaberite Run as administrator naredba iz kontekstnog izbornika.

Korištenje .NET knjižnice u MS Excelu

Funkcije biblioteke viesapiLibrary.dll mogu se koristiti u aplikaciji MS Excel za pisanje vlastitih funkcija i postupaka u Visual Basic Jezik. Da bi to bilo moguće, potrebno je:

  1. Registar the viesapiLibrary.dll knjižnica kao COM objekt na Windows.
  2. Pokrenite Excel aplikaciju. Odaberite DEVELOPER na vrpci, a zatim kliknite Visual Basic dugme.
  3. u Visual Basic for Application prozor, odaberite Tools i onda References iz izbornika. u Available References popis, pronađite i odaberite VIESAPI Service Client for .NET Framework (C#). Potvrdite svoj odabir pomoću OK dugme.
  4. Od Insert izbornik, odaberite Module i zalijepite funkcijski kod predstavljen u primjerima za Visual Basic u novi prozor.
  5. Konačno, odgovarajuće vrijednosti w za viesapi.ID i viesapi.Key treba postaviti. Način dobivanja ključa i pristupnog ključa opisan je u poglavlju Generiranje identifikatora i pristupnog ključa