use of com.odysee.app.exceptions.ApiCallException in project odysee-android by OdyseeTeam.
the class ChannelCreateUpdateTask method doInBackground.
protected Claim doInBackground(Void... params) {
Map<String, Object> options = new HashMap<>();
if (!update) {
options.put("name", claim.getName());
} else {
options.put("claim_id", claim.getClaimId());
}
options.put("bid", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(deposit.doubleValue()));
if (!Helper.isNullOrEmpty(claim.getTitle())) {
options.put("title", claim.getTitle());
}
if (!Helper.isNullOrEmpty(claim.getCoverUrl())) {
options.put("cover_url", claim.getCoverUrl());
}
if (!Helper.isNullOrEmpty(claim.getThumbnailUrl())) {
options.put("thumbnail_url", claim.getThumbnailUrl());
}
if (!Helper.isNullOrEmpty(claim.getDescription())) {
options.put("description", claim.getDescription());
}
if (!Helper.isNullOrEmpty(claim.getWebsiteUrl())) {
options.put("website_url", claim.getWebsiteUrl());
}
if (!Helper.isNullOrEmpty(claim.getEmail())) {
options.put("email", claim.getEmail());
}
if (claim.getTags() != null && claim.getTags().size() > 0) {
options.put("tags", claim.getTags());
}
options.put("blocking", true);
Claim claimResult = null;
String method = !update ? Lbry.METHOD_CHANNEL_CREATE : Lbry.METHOD_CHANNEL_UPDATE;
try {
JSONObject result = (JSONObject) Lbry.authenticatedGenericApiCall(method, options, authToken);
if (result.has("outputs")) {
JSONArray outputs = result.getJSONArray("outputs");
for (int i = 0; i < outputs.length(); i++) {
JSONObject output = outputs.getJSONObject(i);
if (output.has("claim_id") && output.has("claim_op")) {
claimResult = Claim.claimFromOutput(output);
break;
}
}
}
} catch (ApiCallException | ClassCastException | JSONException ex) {
error = ex;
}
return claimResult;
}
Aggregations