Skip to content

Instantly share code, notes, and snippets.

@fabito
Created November 11, 2012 01:28
Show Gist options
  • Save fabito/4053299 to your computer and use it in GitHub Desktop.
Save fabito/4053299 to your computer and use it in GitHub Desktop.
package org.talesolutions.cep.appengine;
import java.util.List;
import javax.inject.Named;
import org.talesolutions.cep.CEP;
import org.talesolutions.cep.CEPService;
import org.talesolutions.cep.CEPServiceFactory;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
/**
* Expoe os serviços de busca de CEPs
*
* @author fuechi
*/
@Api(name = "buscacep", description = "Conjunto de serviços para consulta de CEP")
public class CepEndpoint {
private CEPService cepService = new MemcacheCepServiceDecorator(CEPServiceFactory.getCEPService());
/**
* Obtem um CEP pelo numero do CEP
*
* @param numeroCep
* formatado com hifem ou não
* @return CEP
*/
@ApiMethod(httpMethod = "GET", name = "cep.get")
public CEP getCep(@Named("numeroCep") String numeroCep) {
return cepService.obtemPorNumeroCEP(numeroCep);
}
/**
* @param query
* @return
*/
@ApiMethod(httpMethod = "GET", name = "cep.search")
public List<CEP> searchCep(@Named("term") String query) {
return cepService.obtemPorEndereco(query);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment