com.pepaproch.gtswsdlclient.impl.AddresCheckImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.pepaproch.gtswsdlclient.impl.AddresCheckImpl.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pepaproch.gtswsdlclient.impl;

import com.pepaproch.gtswsdl.client.RestContext;
import com.pepaproch.gtswsdlclient.model.gts.AddressResponse;
import com.pepaproch.gtswsdlclient.model.gts.AddressQuery;
import java.net.URI;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;

/**
 *
 * @author pepa Class responsible for checking address existence in GTS web
 * service
 */
public class AddresCheckImpl {

    /**
     *
     */
    public static final String ADDR_CHECK_PATH = "v1/uiradr";
    private final RestContext restContext;

    /**
     *
     * @param restContext
     */
    public AddresCheckImpl(RestContext restContext) {
        this.restContext = restContext;

    }

    /**
     *
     * @param addrQuery {@link AddressQuery}
     * @return <tt> {@link AddressResponse}</tt>
     */
    public AddressResponse checkAddres(AddressQuery addrQuery) {
        URI toUri = new AddrCheckQueryBuilderImpl(restContext.getBASE_URL() + ADDR_CHECK_PATH).buildQuery(addrQuery)
                .encode().toUri();
        ResponseEntity<AddressResponse> response = restContext.getRestTemplate().exchange(toUri, HttpMethod.GET,
                null, AddressResponse.class);
        return response.getBody();
    }

}