GithubHelp home page GithubHelp logo

joverheid's Introduction

CI Status

Build Status SonarCube

joverheid

Java implementation of Overheid.io API

How to use

Installation

First of all, you need any implementation of javax.ws.rs.client.Client For example you can use jersey client

Add the following dependency to your maven pom.xml file

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>${jersey.client.version}</version>
</dependency>

Then you need pass client implementation to OverheidClient as constructor param.

Example to construct client implementation in spring framework.

In application context XML add the following XML definition

<bean id="overheidJerseyClientBuilder"
          class="org.biacode.joverheid.api.configuration.impl.OverheidJerseyClientBuilderImpl"/>

<bean id="overheidJerseyClient" factory-bean="overheidJerseyClientBuilder" factory-method="build"/>

<bean id="overheidClient" class="org.biacode.joverheid.api.client.impl.OverheidClientImpl">
    <constructor-arg name="client" ref="overheidJerseyClient"/>
</bean>

If you simply need to test overheid API.

Then construct jersey client as follows

package my.application;

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import org.biacode.joverheid.api.client.OverheidClient;
import org.biacode.joverheid.api.client.impl.OverheidClientImpl;
import org.biacode.joverheid.api.model.common.OverheidResult;
import org.biacode.joverheid.api.model.request.GetCorporationsRequest;
import org.biacode.joverheid.api.model.response.GetCorporationsResponse;

import javax.ws.rs.client.ClientBuilder;
import java.util.HashMap;
import java.util.Map;

public class MainApplication {
    public static void main(String[] args) {
        // construct overheid java client
        final OverheidClient overheidClient = new OverheidClientImpl(
                ClientBuilder.newBuilder().register(JacksonJsonProvider.class).build(),
                "Your API key here"
        );
        // you can build filters and pass them to the request constructor as follows
        final Map<String, String> filters = new HashMap<>();
        filters.put("size", "10");
        filters.put("filters[postcode]", "3083cz");
        final GetCorporationsRequest getCorporationsRequest = new GetCorporationsRequest(filters);
        final OverheidResult<GetCorporationsResponse> corporations = overheidClient
                .getCorporations(getCorporationsRequest);
        // check if there is any error
        if (corporations.hasError()) {
            System.out.println(corporations.getError());
        } else {
            // the getResponse() will return the response models E.g. embedded and links
            System.out.println(corporations.getResponse());
            System.out.println(corporations.getResponse().getEmbedded());
            System.out.println(corporations.getResponse().getLinks());
        }
    }
}

Available API calls

Get single corporation

overheidClient.getCorporation(new GetCorporationRequest(12345, "subdossier nummer here"));

Get corporations

overheidClient.getCorporations(new GetCorporationsRequest(filters));

Get dossier corporation

overheidClient.getDossierCorporation(new GetDossierCorporationRequest(12345));

Get suggestions

overheidClient.getSuggestion(new SuggestionRequest("oudet", filters));

Best practices

Make singleton of the OverheidClient so you do not need to construct the client for every API call

The official Overheid documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.