Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AseedUsmani/9f50aa3598b6bcd5ec36d0ca29658ecf to your computer and use it in GitHub Desktop.
Save AseedUsmani/9f50aa3598b6bcd5ec36d0ca29658ecf to your computer and use it in GitHub Desktop.
protected Map<String, String> getParams() {
JSONArray jsonArray = new JSONArray(); //for list of products ordered
Map<String, String> params = new HashMap<>();
SharedPreferences sharedPreferences = getSharedPreferences(Constants.KEY_LOGIN_PREFERENCE, Context.MODE_PRIVATE);
params.put("merchantMobileNo", "7204826250");
params.put("customerMobileNo", sharedPreferences.getString(Constants.KEY_MOBILE, "N/A"));
params.put("merchantName", "Pandey tiffin center");
params.put("customerName", sharedPreferences.getString(Constants.KEY_USERNAME, "N/A"));
for (int i = 0; i < order.size(); i++) {
JSONObject jsonObject = new JSONObject(); //to add in jsonArray
try {
jsonObject.put("productId", order.get(i).getProductId());
jsonObject.put("name", order.get(i).getName());
jsonObject.put("quantity", order.get(i).getQuantity());
jsonObject.put("price", order.get(i).getPrice());
jsonArray.put(jsonObject);
} catch (JSONException e) {
e.printStackTrace();
}
}
params.put("products", jsonArray.toString());
params.put("cAuthToken", sharedPreferences.getString(Constants.KEY_LOGIN_AUTH, "N/A"));
Log.v("XYZ", params.toString());
return params;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment