Java tutorial
/* * 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.AvailabilityResponse; import java.net.URI; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; /** * * @author pepa Class responsible for retriving and caching auth token for gts * web service */ public class AvailabilityCheckImpl { /** * */ public static final String AVAILABILITY_CHECK_PATH = "/v1/ullcheck"; private final RestContext restContext; /** * * @param baseUrl * @param restTemplate */ public AvailabilityCheckImpl(RestContext restContext) { this.restContext = restContext; } /** * * @param addrId * @return */ public AvailabilityResponse checkAvailability(String addrId) { URI toUri = new AvailabilityCheckQueryBuilderImpl(restContext.getBASE_URL() + AVAILABILITY_CHECK_PATH) .buildQuery(addrId).encode().toUri(); ResponseEntity<AvailabilityResponse> response = restContext.getRestTemplate().exchange(toUri, HttpMethod.GET, null, AvailabilityResponse.class); return response.getBody(); } public AvailabilityResponse checkAvailabilityByPhone(String phoneNumber) { URI toUri = new AvailabilityCheckByPhoneQueryBuilderImpl( restContext.getBASE_URL() + AVAILABILITY_CHECK_PATH).buildQuery(phoneNumber).encode().toUri(); ResponseEntity<AvailabilityResponse> response = restContext.getRestTemplate().exchange(toUri, HttpMethod.GET, null, AvailabilityResponse.class); return response.getBody(); } }