Search in sources :

Example 1 with ConsumerResponse

use of com.zype.fire.api.Model.ConsumerResponse in project zype-firebuilder by zype.

the class ZypeApi method getConsumer.

public ConsumerResponse getConsumer(String consumerId, String accessToken) {
    try {
        HashMap<String, String> params = new HashMap<>();
        params.put(ACCESS_TOKEN, accessToken);
        Response response = apiImpl.getConsumer(consumerId, params).execute();
        if (response.isSuccessful()) {
            return (ConsumerResponse) response.body();
        } else {
            return null;
        }
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : Response(retrofit2.Response) VideoFavoritesResponse(com.zype.fire.api.Model.VideoFavoritesResponse) ChannelResponse(com.zype.fire.api.Model.ChannelResponse) DevicePinResponse(com.zype.fire.api.Model.DevicePinResponse) VideosResponse(com.zype.fire.api.Model.VideosResponse) AppResponse(com.zype.fire.api.Model.AppResponse) VideoResponse(com.zype.fire.api.Model.VideoResponse) VideoEntitlementsResponse(com.zype.fire.api.Model.VideoEntitlementsResponse) PlaylistsResponse(com.zype.fire.api.Model.PlaylistsResponse) ProgramResponse(com.zype.fire.api.Model.ProgramResponse) AccessTokenResponse(com.zype.fire.api.Model.AccessTokenResponse) ZobjectContentResponse(com.zype.fire.api.Model.ZobjectContentResponse) PlanResponse(com.zype.fire.api.Model.PlanResponse) PlaylistResponse(com.zype.fire.api.Model.PlaylistResponse) AccessTokenInfoResponse(com.zype.fire.api.Model.AccessTokenInfoResponse) ZobjectTopPlaylistResponse(com.zype.fire.api.Model.ZobjectTopPlaylistResponse) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) HashMap(java.util.HashMap) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) IOException(java.io.IOException)

Example 2 with ConsumerResponse

use of com.zype.fire.api.Model.ConsumerResponse in project zype-firebuilder by zype.

the class ZypeAuthentication method getAccessTokenWithPin.

public static Map<String, Object> getAccessTokenWithPin(String deviceId, String pin) {
    AccessTokenResponse responseAccessToken = ZypeApi.getInstance().retrieveAccessTokenWithPin(deviceId, pin);
    AccessTokenInfoResponse responseAccessTokenInfo = null;
    ConsumerResponse responseConsumer = null;
    if (responseAccessToken != null) {
        responseAccessTokenInfo = ZypeApi.getInstance().getAccessTokenInfo(responseAccessToken.getAccessToken());
        if (responseAccessTokenInfo != null) {
            responseConsumer = ZypeApi.getInstance().getConsumer(responseAccessTokenInfo.resourceOwnerId, responseAccessToken.getAccessToken());
        }
    } else {
        return null;
    }
    Map<String, Object> result = new HashMap<>();
    result.put(RESPONSE_ACCESS_TOKEN, responseAccessToken);
    result.put(RESPONSE_ACCESS_TOKEN_INFO, responseAccessTokenInfo);
    result.put(RESPONSE_CONSUMER, responseConsumer);
    result.put(RESPONSE_IS_DEVICE_LINKED, true);
    return result;
}
Also used : HashMap(java.util.HashMap) AccessTokenInfoResponse(com.zype.fire.api.Model.AccessTokenInfoResponse) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) AccessTokenResponse(com.zype.fire.api.Model.AccessTokenResponse)

Example 3 with ConsumerResponse

use of com.zype.fire.api.Model.ConsumerResponse in project zype-firebuilder by zype.

the class ZypeApi method unlinkDevicePin.

public ConsumerResponse unlinkDevicePin(String consumerId, String pin) {
    try {
        HashMap<String, String> params = new HashMap<>();
        params.put(APP_KEY, ZypeSettings.APP_KEY);
        params.put(CONSUMER_ID, consumerId);
        params.put(PIN, pin);
        Response response = apiImpl.unlinkDevicePin(params).execute();
        if (response.isSuccessful()) {
            return (ConsumerResponse) response.body();
        } else {
            return null;
        }
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : Response(retrofit2.Response) VideoFavoritesResponse(com.zype.fire.api.Model.VideoFavoritesResponse) ChannelResponse(com.zype.fire.api.Model.ChannelResponse) DevicePinResponse(com.zype.fire.api.Model.DevicePinResponse) VideosResponse(com.zype.fire.api.Model.VideosResponse) AppResponse(com.zype.fire.api.Model.AppResponse) VideoResponse(com.zype.fire.api.Model.VideoResponse) VideoEntitlementsResponse(com.zype.fire.api.Model.VideoEntitlementsResponse) PlaylistsResponse(com.zype.fire.api.Model.PlaylistsResponse) ProgramResponse(com.zype.fire.api.Model.ProgramResponse) AccessTokenResponse(com.zype.fire.api.Model.AccessTokenResponse) ZobjectContentResponse(com.zype.fire.api.Model.ZobjectContentResponse) PlanResponse(com.zype.fire.api.Model.PlanResponse) PlaylistResponse(com.zype.fire.api.Model.PlaylistResponse) AccessTokenInfoResponse(com.zype.fire.api.Model.AccessTokenInfoResponse) ZobjectTopPlaylistResponse(com.zype.fire.api.Model.ZobjectTopPlaylistResponse) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) HashMap(java.util.HashMap) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) IOException(java.io.IOException)

Example 4 with ConsumerResponse

use of com.zype.fire.api.Model.ConsumerResponse in project zype-firebuilder by zype.

the class ZypeAuthentication method refreshToken.

private Map<String, Object> refreshToken(ResponseHandler responseHandler) {
    AccessTokenResponse responseAccessToken = ZypeApi.getInstance().refreshAccessToken(Preferences.getString(PREFERENCE_REFRESH_TOKEN));
    AccessTokenInfoResponse responseAccessTokenInfo = null;
    ConsumerResponse responseConsumer = null;
    if (responseAccessToken != null) {
        responseAccessTokenInfo = ZypeApi.getInstance().getAccessTokenInfo(responseAccessToken.getAccessToken());
        if (responseAccessTokenInfo != null) {
            responseConsumer = ZypeApi.getInstance().getConsumer(responseAccessTokenInfo.resourceOwnerId, responseAccessToken.getAccessToken());
        }
    } else {
        return null;
    }
    Map<String, Object> result = new HashMap<>();
    result.put(RESPONSE_ACCESS_TOKEN, responseAccessToken);
    result.put(RESPONSE_ACCESS_TOKEN_INFO, responseAccessTokenInfo);
    result.put(RESPONSE_CONSUMER, responseConsumer);
    result.put(RESPONSE_IS_DEVICE_LINKED, Preferences.getBoolean(PREFERENCE_IS_DEVICE_LINKED));
    return result;
}
Also used : HashMap(java.util.HashMap) AccessTokenInfoResponse(com.zype.fire.api.Model.AccessTokenInfoResponse) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) AccessTokenResponse(com.zype.fire.api.Model.AccessTokenResponse)

Example 5 with ConsumerResponse

use of com.zype.fire.api.Model.ConsumerResponse in project zype-firebuilder by zype.

the class ZypeAuthentication method getAccessToken.

public static Map<String, Object> getAccessToken(String username, String password) {
    // Save user name and password for re-login
    // TODO: Save encoded password
    Preferences.setString(ZypeAuthentication.PREFERENCE_CONSUMER_EMAIL, username);
    Preferences.setString(ZypeAuthentication.PREFERENCE_CONSUMER_PASSWORD, password);
    AccessTokenResponse responseAccessToken = ZypeApi.getInstance().retrieveAccessToken(username, password);
    AccessTokenInfoResponse responseAccessTokenInfo = null;
    ConsumerResponse responseConsumer = null;
    if (responseAccessToken != null) {
        responseAccessTokenInfo = ZypeApi.getInstance().getAccessTokenInfo(responseAccessToken.getAccessToken());
        if (responseAccessTokenInfo != null) {
            responseConsumer = ZypeApi.getInstance().getConsumer(responseAccessTokenInfo.resourceOwnerId, responseAccessToken.getAccessToken());
        }
    } else {
        return null;
    }
    Map<String, Object> result = new HashMap<>();
    result.put(RESPONSE_ACCESS_TOKEN, responseAccessToken);
    result.put(RESPONSE_ACCESS_TOKEN_INFO, responseAccessTokenInfo);
    result.put(RESPONSE_CONSUMER, responseConsumer);
    result.put(RESPONSE_IS_DEVICE_LINKED, false);
    return result;
}
Also used : HashMap(java.util.HashMap) AccessTokenInfoResponse(com.zype.fire.api.Model.AccessTokenInfoResponse) ConsumerResponse(com.zype.fire.api.Model.ConsumerResponse) AccessTokenResponse(com.zype.fire.api.Model.AccessTokenResponse)

Aggregations

AccessTokenInfoResponse (com.zype.fire.api.Model.AccessTokenInfoResponse)5 AccessTokenResponse (com.zype.fire.api.Model.AccessTokenResponse)5 ConsumerResponse (com.zype.fire.api.Model.ConsumerResponse)5 HashMap (java.util.HashMap)5 AppResponse (com.zype.fire.api.Model.AppResponse)2 ChannelResponse (com.zype.fire.api.Model.ChannelResponse)2 DevicePinResponse (com.zype.fire.api.Model.DevicePinResponse)2 PlanResponse (com.zype.fire.api.Model.PlanResponse)2 PlaylistResponse (com.zype.fire.api.Model.PlaylistResponse)2 PlaylistsResponse (com.zype.fire.api.Model.PlaylistsResponse)2 ProgramResponse (com.zype.fire.api.Model.ProgramResponse)2 VideoEntitlementsResponse (com.zype.fire.api.Model.VideoEntitlementsResponse)2 VideoFavoritesResponse (com.zype.fire.api.Model.VideoFavoritesResponse)2 VideoResponse (com.zype.fire.api.Model.VideoResponse)2 VideosResponse (com.zype.fire.api.Model.VideosResponse)2 ZobjectContentResponse (com.zype.fire.api.Model.ZobjectContentResponse)2 ZobjectTopPlaylistResponse (com.zype.fire.api.Model.ZobjectTopPlaylistResponse)2 IOException (java.io.IOException)2 Response (retrofit2.Response)2