Created
May 6, 2018 13:15
-
-
Save AseedUsmani/9f50aa3598b6bcd5ec36d0ca29658ecf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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