All Downloads are FREE. Search and download functionalities are using the official Maven repository.

in.wavelabs.idn.APIClient Maven / Gradle / Ivy

The newest version!
package in.wavelabs.idn;

import com.nbos.capi.modules.identity.v0.TokenApiModel;
import in.wavelabs.idn.ConnectionAPI.NBOSCallback;
import in.wavelabs.idn.ConnectionAPI.service.StarterClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import java.util.List;

/**
 * Created by vivekkiran on 6/20/16.
 */
public class APIClient {
    public static String clientId;
    public static String clientSecret;
    private List hostsArray;

    public APIClient(String clientId, String clientSecret){
        APIClient.clientId = clientId;
        APIClient.clientSecret = clientSecret;
    }
    public APIClient(String clientId, String clientSecret, List hostsArray) {
        APIClient.clientId = clientId;
        APIClient.clientSecret = clientSecret;
        this.hostsArray = hostsArray;

    }

    public static void getToken(final NBOSCallback nbosCallback){
        Call call = StarterClient.getStarterAPI().getToken(clientId, clientSecret, "client_credentials");
        call.enqueue(new Callback() {

            @Override
            public void onResponse(Call call, Response response) {
                nbosCallback.onResponse(response);
            }

            @Override
            public void onFailure(Call call, Throwable t) {
                nbosCallback.onFailure(t);

            }


        });

    }
    public static void refreshToken(String clientId, String clientSecret, String refreshToken, final NBOSCallback nbosCallback){
        Call call = StarterClient.getStarterAPI().refreshToken(clientId, clientSecret, "refresh_token",refreshToken);
        call.enqueue(new Callback() {


            @Override
            public void onResponse(Call call, Response response) {
                nbosCallback.onResponse(response);
            }


            @Override
            public void onFailure(Call call, Throwable t) {
                nbosCallback.onFailure(t);


            }


        });

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy