/** * Make a request request call to restful * * @param uri * @throws JSONException */ private void requestRequests(String uri) throws JSONException { RequestPackaging p = new RequestPackaging(); p.setMethod("POST"); // Set the HTTP REQUEST method p.setUri(uri); // Sets the URI JSONArray jar = new JSONArray(); JSONObject object = new JSONObject(); object.put("query", "select"); // What kind of query object.put("method", "getborrowbookrequest"); // What kind of request object.put( "id", SaveSharedPreference.getID(getActivity())); // Pass the id for the user to the webservice jar.put(object); p.setJarParams(jar); // Add the param objects to the JSONArray MyTask task = new MyTask(); task.execute(p); }
/** * Make a reply request call to restful * * @param position * @throws JSONException */ public void requestReplyRequest(int position) throws JSONException { BorrowedBook borrowedBook = (BorrowedBook) borrowedBooks.get(position); RequestPackaging p = new RequestPackaging(); p.setMethod("POST"); // Set the HTTP REQUEST method p.setUri(BookshelfConstants.CONNECTION_URI); // Sets the URI JSONArray jar = new JSONArray(); JSONObject object = new JSONObject(); object.put("query", "update"); // What kind of query object.put("method", "replyborrowedbook"); // What kind of request object.put( "friendid", SaveSharedPreference.getID(getActivity())); // Pass the id for the user to the webservice object.put("id", borrowedBook.getRenter().getId()); object.put("isbn", borrowedBooks.get(position).getIsbn()); object.put("accepted", "FALSE"); object.put("replied", "TRUE"); jar.put(object); p.setJarParams(jar); // Add the param objects to the JSONArray MyTask task = new MyTask(); task.execute(p); }