Skip to content

Commit

Permalink
#1352 - switch to saved_locations v2 API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
budowski committed Sep 23, 2024
1 parent eba8cf6 commit f8a86c3
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,7 @@ private boolean downloadToFile(String uri, String outputFilename) {


private boolean deletePinnedLocation(String id) throws AuthenticationException {
JSONArray result = delete(String.format(Locale.ENGLISH, "%s/saved_locations/%s.json", HOST, id), null);
JSONArray result = delete(String.format(Locale.ENGLISH, "%s/saved_locations/%s", API_V2_HOST, id), null);

if (result != null) {
return true;
Expand All @@ -1767,20 +1767,28 @@ private boolean deletePinnedLocation(String id) throws AuthenticationException {
}

private boolean pinLocation(Double latitude, Double longitude, Double accuracy, String geoprivacy, String title) throws AuthenticationException {
ArrayList<Pair<String, String>> params = new ArrayList<Pair<String, String>>();
params.add(new Pair("saved_location[latitude]", latitude.toString()));
params.add(new Pair("saved_location[longitude]", longitude.toString()));
params.add(new Pair("saved_location[positional_accuracy]", accuracy.toString()));
params.add(new Pair("saved_location[geoprivacy]", geoprivacy));
params.add(new Pair("saved_location[title]", title));

JSONArray result = post(HOST + "/saved_locations.json", params);
try {
JSONObject jsonBody = new JSONObject();
JSONObject savedLocation = new JSONObject();
savedLocation.put("latitude", latitude);
savedLocation.put("longitude", longitude);
savedLocation.put("positional_accuracy", accuracy.intValue());
savedLocation.put("geoprivacy", geoprivacy);
savedLocation.put("title", title);
jsonBody.put("saved_location", savedLocation);
JSONArray result = post(API_V2_HOST + "/saved_locations", jsonBody);

if (result != null) {
return true;
} else {
return false;
}

if (result != null) {
return true;
} else {
} catch (JSONException e) {
return false;
}

}

private void syncObservations(long[] idsToSync) throws AuthenticationException, CancelSyncException, SyncFailedException {
Expand Down

0 comments on commit f8a86c3

Please sign in to comment.