https://github.com/ktor/osgi-vat-checker
OSGi bundles that provide api and implementation of EU VIES VAT number checking service
https://github.com/ktor/osgi-vat-checker
ds eu osgi osgi-bundle osgi-declarative-services osgi-ds osgi-services vat vat-number vat-validation vies vies-soap-service
Last synced: about 2 months ago
JSON representation
OSGi bundles that provide api and implementation of EU VIES VAT number checking service
- Host: GitHub
- URL: https://github.com/ktor/osgi-vat-checker
- Owner: ktor
- License: apache-2.0
- Created: 2019-03-30T12:06:05.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-19T08:22:28.000Z (about 5 years ago)
- Last Synced: 2025-01-28T10:45:59.741Z (4 months ago)
- Topics: ds, eu, osgi, osgi-bundle, osgi-declarative-services, osgi-ds, osgi-services, vat, vat-number, vat-validation, vies, vies-soap-service
- Language: Java
- Homepage:
- Size: 111 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://opensource.org/licenses/Apache-2.0) [](https://travis-ci.org/synus-org/osgi-vat-checker)
[](https://codecov.io/gh/synus-org/osgi-vat-checker)
[](https://sonarcloud.io/dashboard?id=osgi-vat-checker)
# OSGi VIES VAT number validation
## About
The project contains two OSGi bundles that provide online EU VAT number validation with VAT Information Exchange System ([VIES][1]).1. `vat-checker-api.jar` - Java model for VIES API
1. `vat-checker-service.jar` - service client that uses classes generated from [WSDL published][2] by VIES## API
Bundle offers simple Java service interface:
```java
package org.synus.vies.api;
public interface VatChecker {
VatCheckerResult checkVat(Country country, String vatNumber);
```
The implementation catches all exceptions (logs them with slf4j) and always returns a result instance of type:
```java
// ...
public class VatCheckerResult {private final Country country;
private final String vatNumber;
private final Optional requestDate;
private final boolean valid;
private final Optional name;
private final Optional address;
private final Optional error;
// ...
```## Result and error handling
Returned `VatCheckerResult` instance can be in following states:
1. VAT valid: `valid=true`
1. VAT invalid: `valid=false` and `error` is empty
1. VAT checker error: `valid=false` and `error` has enum value
```java
public enum VatCheckerError {
INVALID_INPUT,
INVALID_REQUESTER_INFO,
SERVICE_UNAVAILABLE,
MS_UNAVAILABLE,
TIMEOUT,
VAT_BLOCKED,
IP_BLOCKED,
GLOBAL_MAX_CONCURRENT_REQ,
GLOBAL_MAX_CONCURRENT_REQ_TIME,
MS_MAX_CONCURRENT_REQ,
MS_MAX_CONCURRENT_REQ_TIME,
UNEXPECTED,
}
```# Installation
Build and install both api and implementation jars on your osgi container.```bash
$ ./gradlew build # to build both jars jar
$ cp vat-checker-api/build/libs/vat-checker-api-1.0.0.jar $MY_OSGI_CONTAINER
$ cp vat-checker-service/build/libs/vat-checker-service-1.0.0.jar $MY_OSGI_CONTAINER
```
## Usage
### Gradle project
`build.gradle`:
```gradle
dependencies {
compileOnly 'org.synus.vies:vat-checker-api:1.0.0'
}
```
### Example: Liferay's gogo shell command
```java
@Component(
property = {"osgi.command.function=checkvat", "osgi.command.scope=blade"},
service = Object.class
)
public class ExampleCommand {@Reference
private volatile VatChecker vatChecker;public void checkvat(String country, String vatNumber) {
System.out.println(vatChecker.checkVat(Country.valueOf(country), vatNumber).isValid());
}}
``````bash
$ telnet localhost 11311
Welcome to Apache Felix Gogog! checkvat "SK" "2020216748"
true
```## Contributing
Want to hack on vat-checker? See [CONTRIBUTING.md](CONTRIBUTING.md) for information on building, testing and contributing changes.
They are probably not perfect, please let me know if anything feels wrong or incomplete.
## License
The contents of this repository are made available to the public under the terms of the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
Bundles may depend on non Apache Licensed code.---
[1]:http://ec.europa.eu/taxation_customs/vies/
[2]:http://ec.europa.eu/taxation_customs/vies/technicalInformation.html