Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.joaomartins.srodkitrwale
- import android.util.Base64
- import retrofit2.Retrofit
- import retrofit2.converter.gson.GsonConverterFactory
- import okhttp3.OkHttpClient
- import okhttp3.logging.HttpLoggingInterceptor
- import java.util.*
- //val cred = username + ":" + password
- //val AUTH = Base64.encodeToString(cred.getBytes(), Base64.DEFAULT).replace("\n", "")
- class RetrofitClient {
- // Initializing Retrofit
- fun init() : Retrofit{
- // Creating the instance of an Interceptor
- val logging = HttpLoggingInterceptor()
- logging.level = HttpLoggingInterceptor.Level.BODY
- // Creating the OkHttp Builder
- val client = OkHttpClient.Builder()
- .addInterceptor(logging)
- .build()
- // Creating the instance of a Builder
- return Retrofit.Builder()
- .baseUrl("https://srodki.herokuapp.com/") // The API server
- .client(client) // Adding Http Client
- .addConverterFactory(GsonConverterFactory.create()) // Object Converter
- .build()
- }
- fun providesGetLogin(retrofit: Retrofit): GET_LOGIN = retrofit.create(GET_LOGIN::class.java)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement