Search in sources :

Example 11 with LbryRequestException

use of com.odysee.app.exceptions.LbryRequestException in project odysee-android by OdyseeTeam.

the class Lbry method resolve.

public static List<Claim> resolve(List<String> urls, String connectionString) throws ApiCallException {
    List<Claim> claims = new ArrayList<>();
    Map<String, Object> params = new HashMap<>();
    params.put("urls", urls);
    try {
        JSONObject result = (JSONObject) parseResponse(apiCall(METHOD_RESOLVE, params, connectionString));
        Iterator<String> keys = result.keys();
        if (keys != null) {
            while (keys.hasNext()) {
                Claim claim = Claim.fromJSONObject(result.getJSONObject(keys.next()));
                claims.add(claim);
                addClaimToCache(claim);
            }
        }
    } catch (LbryRequestException | LbryResponseException | JSONException ex) {
        throw new ApiCallException("Could not execute resolve call", ex);
    }
    return claims;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ApiCallException(com.odysee.app.exceptions.ApiCallException) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) LbryResponseException(com.odysee.app.exceptions.LbryResponseException) LbryRequestException(com.odysee.app.exceptions.LbryRequestException) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) Claim(com.odysee.app.model.Claim)

Aggregations

LbryRequestException (com.odysee.app.exceptions.LbryRequestException)11 LbryResponseException (com.odysee.app.exceptions.LbryResponseException)10 JSONObject (org.json.JSONObject)9 JSONException (org.json.JSONException)8 ApiCallException (com.odysee.app.exceptions.ApiCallException)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 LinkedHashMap (java.util.LinkedHashMap)6 IOException (java.io.IOException)5 OkHttpClient (okhttp3.OkHttpClient)5 Request (okhttp3.Request)5 JSONArray (org.json.JSONArray)5 Response (okhttp3.Response)4 Claim (com.odysee.app.model.Claim)3 Uri (android.net.Uri)2 ClaimCacheKey (com.odysee.app.model.ClaimCacheKey)2 LbryFile (com.odysee.app.model.LbryFile)2 ResponseBody (okhttp3.ResponseBody)2 Handler (android.os.Handler)1 WebResourceRequest (android.webkit.WebResourceRequest)1