TheLegace

Untitled

Apr 25th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1. import org.alexd.jsonrpc.*;
  2. import org.json.JSONArray;
  3. import org.json.JSONException;
  4. import org.json.JSONObject;
  5. public class WaiterappClient {
  6.  
  7.     /**
  8.      * @param args
  9.      * @throws JSONException
  10.      */
  11.     public static void main(String[] args) throws JSONException {
  12.         // // Create client specifying JSON-RPC version 2.0
  13.         JSONRPCClient service = JSONRPCClient.create("http://TheLegace:[email protected]/waiterapp/default/call/jsonrpc", JSONRPCParams.Versions.VERSION_1);
  14.         service.setConnectionTimeout(2000);
  15.         service.setSoTimeout(2000);
  16.         try
  17.         {  
  18.            
  19.             JSONArray count = (JSONArray) service.call("restaurants_area","43.7747943","-79.7420149","2");
  20.             System.out.println(count);
  21.             count = (JSONArray) service.call("restaurants_area");
  22.             System.out.println(count);
  23.            
  24.             /*for(int i=0;i<count.length();i++){
  25.                 JSONObject r = count.getJSONObject(i);
  26.                 System.out.println(r.get("id"));
  27.             }*/
  28.            
  29.             JSONObject restaurant = count.getJSONObject(0);
  30.             int id = restaurant.getInt("id");
  31.            
  32.             JSONObject check = (JSONObject) service.call("check_in", id);
  33.             System.out.println(check);
  34.            
  35.             JSONArray menu = (JSONArray) service.call("restaurant_menu");
  36.             System.out.println(menu);
  37.            
  38.             JSONObject reserve = (JSONObject) service.call("reserve_table", 4);
  39.             System.out.println(reserve);
  40.            
  41.             JSONObject orderItem = (JSONObject) service.call("order_item", 1, 4, true);
  42.             System.out.println(orderItem);
  43.            
  44.             JSONArray orders = (JSONArray) service.call("order_poll");
  45.             System.out.println(orders);
  46.            
  47.            
  48.         }
  49.         catch (JSONRPCException e)
  50.         {
  51.           e.printStackTrace();
  52.         }
  53.  
  54.     }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment