package com.jarvislin.isitrainingnow.network;

import android.content.Context;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by JarvisLin on 2017/1/7.
 */

public class NetworkService {
    private static final String RAINING_OPEN_DATA_API_URL = "http://opendata.epa.gov.tw/ws/Data/RainTenMin/";

    private Retrofit retrofit;

    public NetworkService(Context context) {
        init();
    }

    private void init() {
        retrofit = new Retrofit.Builder()
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .addConverterFactory(new ToStringConverterFactory())
                .baseUrl(RAINING_OPEN_DATA_API_URL)
                .client(new OkHttpClient.Builder().build())
                .build();
    }

    public OpenDataApi getOpenDataApi() {
        return retrofit.create(OpenDataApi.class);
    }
}

@@ -84,28 +84,114 @@
 ort 
-okhttp3.OkHttpClient
+java.util.concurrent.TimeUnit;%0A%0Aimport okhttp3.OkHttpClient;%0Aimport okhttp3.logging.HttpLoggingInterceptor
 ;%0Aim
@@ -328,16 +328,66 @@
 ctory;%0A%0A
+import com.jarvislin.isitrainingnow.BuildConfig;%0A%0A
 /**%0A * C
@@ -627,23 +627,8 @@
 ice(
-Context context
 ) %7B%0A
@@ -981,16 +981,16 @@
 PI_URL)%0A
-
         
@@ -1031,16 +1031,396 @@
 uilder()
+%0A                        .readTimeout(15, TimeUnit.SECONDS)%0A                        .connectTimeout(15, TimeUnit.SECONDS)%0A                        .addInterceptor(new HttpLoggingInterceptor().setLevel(BuildConfig.DEBUG%0A                                ? HttpLoggingInterceptor.Level.BODY%0A                                : HttpLoggingInterceptor.Level.NONE))%0A                        
 .build()

set timeout