Skip to content

Commit

Permalink
SyncAdaptr.doUploadSync(): Add "interface" param to mark it as from t…
Browse files Browse the repository at this point in the history
…he app.

Add:
interface: murrayc.com-android-galaxyzoo
to the parameters in the content of the POST to make it easier for
the server to identify the app as the source of the classifications.
See #11
  • Loading branch information
murraycu committed Dec 5, 2014
1 parent 76a933c commit 8b7ac85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public void testUploadWithSuccess() throws IOException, InterruptedException {
final URL mockUrl = server.getUrl("/");
final ZooniverseClient client = new ZooniverseClient(getContext(), mockUrl.toString());

//SyncAdapter.doUploadSync() adds an "interface" parameter too,
//but we are testing a more generic API here:
List<NameValuePair> values = new ArrayList<>();
values.add(new BasicNameValuePair("classification[subject_ids][]", "504e4a38c499611ea6010c6a"));
values.add(new BasicNameValuePair("classification[favorite][]", "true"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,18 @@ private void removeItem(final String itemId) {

private boolean doUploadSync(final String itemId, final String subjectId, final String authName, final String authApiKey) {

final String PARAM_PART_CLASSIFICATION = "classification";

//Note: I tried using HttpPost.getParams().setParameter() instead of the NameValuePairs,
//but that did not allow multiple parameters with the same name, which we need.
final List<NameValuePair> nameValuePairs = new ArrayList<>();

//Help the server know that the classification is from this Android app,
//by reusing the User-Agent string as a parameter value.
//See https://github.com/murraycu/android-galaxyzoo/issues/11
nameValuePairs.add(new BasicNameValuePair("interface",
HttpUtils.USER_AGENT_MURRAYC));

final String PARAM_PART_CLASSIFICATION = "classification";
nameValuePairs.add(new BasicNameValuePair(PARAM_PART_CLASSIFICATION + "[subject_ids][]",
subjectId));

Expand Down

0 comments on commit 8b7ac85

Please sign in to comment.