Skip to content

Commit

Permalink
feat: add stop-id to the survey request body
Browse files Browse the repository at this point in the history
Signed-off-by: Amr Hossam <[email protected]>
  • Loading branch information
amrhossamdev authored and aaronbrethorst committed Sep 4, 2024
1 parent e72c076 commit 49247ee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ public Builder setUserIdentifier(String userIdentifier) {
return this;
}

public Builder setStopIdentifier(String stopIdentifier) {
try {
mPostData.appendQueryParameter("stop_identifier", stopIdentifier);
} catch (Exception e) {
e.printStackTrace();
}
return this;
}

public Builder setSurveyId(int surveyId) {
try {
mPostData.appendQueryParameter("survey_id", Integer.toString(surveyId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ private String getSubmitSurveyApiUrl(boolean isHeroQuestion) {
*/
private void sendSurveySubmission(String apiUrl, String userIdentifier, int surveyId, JSONArray requestBody) {
showProgress();
ObaSubmitSurveyRequest request = new ObaSubmitSurveyRequest.Builder(context, apiUrl).setUserIdentifier(userIdentifier).setSurveyId(surveyId).setResponses(requestBody).setListener(submitSurveyRequestListener).build();
ObaSubmitSurveyRequest request = new ObaSubmitSurveyRequest.Builder(context, apiUrl)
.setUserIdentifier(userIdentifier)
.setSurveyId(surveyId)
.setStopIdentifier(SurveyUtils.getCurrentStopIdentifier(currentStop,isVisibleOnStops))
.setResponses(requestBody)
.setListener(submitSurveyRequestListener).build();
new Thread(request::call).start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,21 @@ public static ArrayList<String> getRoutesIDList(String[] routes) {
return new ArrayList<>(Arrays.asList(routes));
}

/**
* Returns the stop identifier if the stop is non-null, has a valid ID,
* and is marked as visible; otherwise, returns null.
*
* @param currentStop The current stop object.
* @param visibleOnStops Indicates if the stop is visible.
* @return The stop identifier or null if conditions are not met.
*/
public static String getCurrentStopIdentifier(ObaStop currentStop, boolean visibleOnStops) {
return (currentStop != null && currentStop.getId() != null && visibleOnStops)
? currentStop.getId()
: null;
}




}

0 comments on commit 49247ee

Please sign in to comment.