/*
 * Copyright (c) 2015 Mike Putnam <mike@theputnams.net>
 * Copyright (c) 2015 Jake Kiser <jacobvkiser@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

package theputnams.net.isitrecyclingweek.restclients.service;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import retrofit.RestAdapter;
import retrofit.converter.GsonConverter;

/**
 * Getting around the fact that we are dealing with 2 different API's
 */
public class ApiService {

    private static RestAdapter mContractRestAdapter;

    private static RestAdapter mCollectionRestAdapter;

    private static Gson gson = new GsonBuilder()
            .setDateFormat("yyyy-MM-dd")
            .create();

    public static ContractApi getContractApi() {
        String url = "http://civic-hack-api-locator.azurewebsites.net";

        if (mContractRestAdapter == null) {
            mContractRestAdapter = new RestAdapter.Builder()
                    .setEndpoint(url)
                    .setConverter(new GsonConverter(gson))
                    .build();
        }

        return mContractRestAdapter.create(ContractApi.class);
    }

    public static CollectionApi getCollectionApi(String api_url) {

        if (mCollectionRestAdapter == null) {
            mCollectionRestAdapter = new RestAdapter.Builder()
                    .setEndpoint(api_url)
                    .setConverter(new GsonConverter(gson))
                    .build();
        }

        return mCollectionRestAdapter.create(CollectionApi.class);
    }
}

@@ -1870,67 +1870,16 @@
  api
-_u
+U
 rl) %7B%0A%0A
-        if (mCollectionRestAdapter == null) %7B%0A    
     
@@ -1941,36 +1941,32 @@
                 
-    
 .setEndpoint(api
@@ -1969,18 +1969,13 @@
 (api
-_u
+U
 rl)%0A
-    
     
@@ -2033,36 +2033,32 @@
                 
-    
 .build();%0A      
@@ -2046,34 +2046,24 @@
    .build();
-%0A        %7D
 %0A%0A        re

Change single adapter to one per Api provider