Refactoring Service classes

Introduced ServiceHelper class and ApiDefintion class to provide helper
methods for submitting  API requests.
1. ApiDefinition class provides the means to specify the API request parameters using typical for Mambu request types (get entity details, get list of entities, post an operation for an entity, etc.)
2. ServiceHelper class uses provided ApiDefinition to build the url, execute request and parse the response.
3. Service classes (e.g., LoansServices, ClientService, etc.) can now specify the ApiDefinitions for their APIs and use ServiceHelper to execute the request instead of building each request from scratch.

**  For now only LoansService and ClientService were modified to demonstrate this approach. Once everything is confirmed and finalized - other Services can be updated accordingly.

Other changes:
ClientService: removed obsolete, non json methods to create basic client with just first/last name and some personal details. New Json create can be used instead.
It's a good suggestion.  I created constructors for ApiType to specify request attributes specific to each enum there (and removed the corresponding attribute members from the ApiDefinition).  These constructors now are also serving as an easier to understand documentation/description of the kind api requests each enum covers.  

I also removed  the ApiDefinition constructor which was taking individual attributes (instead of the ApiType). It wasn't used anyway and it's better to enforce consistently using ApiTypes and define the new enums if needed.

On Jun 20, 2014, at 2:17 AM, thobach <notifications@github.com> wrote:

> In src/com/mambu/apisdk/util/ApiDefinition.java:
> 
> > +	}
> > +
> > +	/**
> > +	 * Initialise all API definition parameters for the specified ApiType
> > +	 * 
> > +	 * @param apiType
> > +	 *            api type
> > +	 * @param entityClass
> > +	 *            entity class which identifies the api's end point
> > +	 * @param resultClass
> > +	 *            the class for the objects returned by the api. Needed only for ApiType.GetOwnedEntities. For all other
> > +	 *            api types entity class determines the result class
> > +	 * 
> > +	 */
> > +
> > +	private void initDefintion(ApiType apiType, Class<?> entityClass, Class<?> resultClass) {
> As these are fairly static assignments (except for isLoan) in this method, you could also add an enum constructor for ApiType(Method method, String dependendResource, boolean needObjectId, ApiReturnFormat returnFormat, Class<?> returnClass).
> 
> —
> Reply to this email directly or view it on GitHub.
>