diff --git a/lift-app-challenge/_create_and_edit_lift.html.md b/lift-app-challenge/_create_and_edit_lift.html.md
new file mode 100644
index 0000000..8818cdc
--- /dev/null
+++ b/lift-app-challenge/_create_and_edit_lift.html.md
@@ -0,0 +1,154 @@
+## Creating and editing a lift
+Now that we have designed the basic layout for MainActivity we will proceed to design an UI for creating and editing a lift in **CreateLiftActivity**.
+A lift entity consists of four attributes:
+* Phone number: The phone number of the car owner.
+* Location: The initial location of the lift.
+* Start time from home : The departure time from the location.
+* Start time from office : The departure time from the office.
+
+For the UI of **CreateLiftActivity**, create a new xml file called **activity_create_lift.xml** and paste the code into the file shown below.
+
+
+http://codelearn-liftapp.herokuapp.com/api/lifts ++ +###Request + +**Fetching lifts**: A simple GET request without any request parameters is sufficient to get a response. + +###Response + +**Fetching lifts**: The endpoint will provide an array of lifts as a JSON response when a GET call is received. + +
+[
+ {
+ "etime": "17:20",
+ "stime": "14:20",
+ "location": "narnia",
+ "phone": "9876543210"
+ },
+ {
+ "etime": "17:32",
+ "stime": "14:32",
+ "location": "hogwarts",
+ "phone": "1234567890"
+ },
+ {
+ "etime": "14:35",
+ "stime": "8:35",
+ "location": "mordor",
+ "phone": "9999988888"
+ },
+ {
+ "etime": "18:14",
+ "stime": "10:14",
+ "location": "pandora",
+ "phone": "9538384545"
+ }
+]
+
+
+## Example
+
+In the JSON response above, the first lift has location narnia followed by hogwarts, mordor & pandora. It should appear as the order below in LiftListScreen
+
+`order of lifts on LiftListActivity`
++narnia +hogwarts +mordor +pandora ++ +##Lift Details + +While displaying minimal details about the lifts in the LiftListScreen, we need to fire up a new activity which diplays all the information of the lift when the corresponding lift is clicked on the list. We need to also allow the user to call or message the lift number if the user needs to contact the lift owner. The layout of the lift detail activity can be as follows. + + +###Tasks + +1. Modify LiftListActivity to make an HTTP GET call when the Activity is created to fetch lifts. Handle the received Lift objects and render them in the ListView. + +2. Register an **onListItemClick** listener which, on clicking a list item, fires up the activity **LiftDetailAcitivty** to display the corresponding lift details. + +2. Add two buttons with ids **R.id.call** and **R.id.message** to call or message the lift phone number repectively. The button click should launch the proper intents. + +###Restrictions +* You must only use **AndroidHttpClient** or **DefaultHttpClient** to do network calls as they can only be mocked & tested with Robolectric. Any other library is not supported. +* For JSON parsing, you can use **GSON** & **Jackson** libraries only diff --git a/lift-app-challenge/_http_requests.html.md b/lift-app-challenge/_http_requests.html.md new file mode 100644 index 0000000..0f85627 --- /dev/null +++ b/lift-app-challenge/_http_requests.html.md @@ -0,0 +1,75 @@ +## Executing HTTP requests +In this level, your task is to send different types HTTP requests to the Codelearn Test API and handle the response appropriately. We will be submitting and updating lift data and deleting a lift enitiy using the API endpoint. + +###Lift creation API +The Codelearn LiftApp API endpoint for submitting the lift data is available at: + +
+http://codelearn-liftapp.herokuapp.com/api/create ++ +####Request +The JSON request object for the HTTP **POST** request can be as follows. +
+{
+"phone" : "9876543219",
+"location" : "narnia",
+"stime" : "8:15",
+"etime" : 16:30"
+}
+
+
+Note that the field names must be same as the ones given above.
+
+####Response
+The API will provide you with the lift id as a JSON response
+Note that this id is unique for each lift entity stored in the database.
+
+{
+"id" : "_sfdf3rcfht4t553"
+}
+
+
+==================================================================================
+###Lift updating API
+For updating the lift data in the database, a **PUT** request encoded with the lift id can be sent to the API endpoint as follows:
+
+http://codelearn-liftapp.herokuapp.com/api/lifts/{{id}}
+
+Where ``{{id}}`` should be replaced with your lift id. For example:
++http://codelearn-liftapp.herokuapp.com/api/lifts/_sfdf3rcfht4t553 ++ +####Request + +The JSON request object for the HTTP **PUT** request should be similar to the **POST** request. +
+{
+"phone" : "9876543219",
+"location" : "narnia_new",
+"stime" : "8:20",
+"etime" : 16:40"
+}
+
+
+===================================================================================
+###Lift deletion API
+For deleting a lift enitiy from the database a **DELETE** request encoded with the lift id could be sent to the API endpoint as follows:
+
++http://codelearn-liftapp.herokuapp.com/api/lifts/_sfdf3rcfht4t553 ++ + +##Tasks + +1. Modify the app the send the lift data to the API endpoint as a HTTP POST call on creating a lift in the CreateLiftActivity. +2. Once you receive a successful response, store the received id in SharedPreference, specifying the name of the preference file as **codelearn_liftapp** and the name of the preference key as **pref_lift_id** +3. For updating the lift data from the edit/create lift screen, a HTTP PUT call must be sent to the API endpoint. +4. Add a menu item to LiftListActivity which allows the user to delete the lift. On clicking the menu item a HTTP DELETE call should be made to the API endpoint. + +##Restrictions +1. The lift id must be stored in a SharedPreference file named "codelearn_liftapp" with preference key, *"pref_lift_id". +2. You must use only DefaultHttpClient or AndroidHttpClient for HTTP calls +3. There must be exactly two items i.e edit and delete in the menu of LiftListActivity.