Skip to content

Commit

Permalink
Merge pull request #11 from imsweb/cache-services
Browse files Browse the repository at this point in the history
Cache services
  • Loading branch information
ctmay4 authored Oct 11, 2016
2 parents 31cb404 + 2737463 commit f7ab8c2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = 'com.imsweb'
version = '3.2'
version = '3.3'
description = 'Java client library for SEER*API'

println "Starting build using ${Jvm.current()}"
Expand Down
37 changes: 27 additions & 10 deletions src/main/java/com/imsweb/seerapi/client/SeerApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@
*/
public final class SeerApi {

private Retrofit _retrofit;
private DiseaseService _diseaseService;
private GlossaryService _glossaryService;
private NaaccrService _naaccrService;
private NdcService _ndcService;
private RxService _rxService;
private SiteRecodeService _siteRecodeService;
private StagingService _stagingService;
private SurgeryService _surgeryService;

/**
* Creates a client API root object
Expand All @@ -62,11 +69,21 @@ private SeerApi(String baseUrl, final String apiKey) {
.addInterceptor(new ErrorInterceptor())
.build();

_retrofit = new Retrofit.Builder()
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(JacksonConverterFactory.create(getMapper()))
.client(client)
.build();

// create cached service entities
_diseaseService = retrofit.create(DiseaseService.class);
_glossaryService = retrofit.create(GlossaryService.class);
_naaccrService = retrofit.create(NaaccrService.class);
_ndcService = retrofit.create(NdcService.class);
_rxService = retrofit.create(RxService.class);
_siteRecodeService = retrofit.create(SiteRecodeService.class);
_stagingService = retrofit.create(StagingService.class);
_surgeryService = retrofit.create(SurgeryService.class);
}

/**
Expand Down Expand Up @@ -97,63 +114,63 @@ static ObjectMapper getMapper() {
* @return an interface to all the disease APIs
*/
public DiseaseService disease() {
return _retrofit.create(DiseaseService.class);
return _diseaseService;
}

/**
* Return the glossary service
* @return an interface to all the glossary APIs
*/
public GlossaryService glossary() {
return _retrofit.create(GlossaryService.class);
return _glossaryService;
}

/**
* Return the NAACCR service
* @return an inteface to all the NAACCR APIs
*/
public NaaccrService naaccr() {
return _retrofit.create(NaaccrService.class);
return _naaccrService;
}

/**
* Return the NDC service
* @return an inteface to all the NDC APIs
*/
public NdcService ndc() {
return _retrofit.create(NdcService.class);
return _ndcService;
}

/**
* Return the Rx service
* @return an inteface to all the Rx APIs
*/
public RxService rx() {
return _retrofit.create(RxService.class);
return _rxService;
}

/**
* Return the site recode service
* @return an interface to all the site recode APIs
*/
public SiteRecodeService siteRecode() {
return _retrofit.create(SiteRecodeService.class);
return _siteRecodeService;
}

/**
* Return the staging service
* @return an interface to all the staging APIs
*/
public StagingService staging() {
return _retrofit.create(StagingService.class);
return _stagingService;
}

/**
* Return the surgery service
* @return an interface to all the surgery APIs
*/
public SurgeryService surgery() {
return _retrofit.create(SurgeryService.class);
return _surgeryService;
}

/**
Expand Down

0 comments on commit f7ab8c2

Please sign in to comment.