Project API


The general structure of API calls is:

VERB [base]/[type]/[id]{?...}

The VERB represents the verb used in the interaction, e.g. GET, PUT, POST.

Content surrounded by [] is mandatory and will be replaced by the string literal identified. Possible insertion values:

  • base is the Service Base URL which is the address where all of the resources defined by this API are found.
  • type is generally the name of a resource type, e.g. "parks".
  • id is the logical id of a resource, and will be generated by your application when a resource is created.

Content surrounded by {} is optional.

The Service Base URL takes the form of http(s)://server{/path}

The path portion is optional, and does not include a trailing slash.

Each resource type defined in this specification has a manager (or "entity set") that lives at the address /[type] where the [type] is the name of the resource type. For instance, the resource manager for the type parks will be found at: https://server/path/parks

For purposes of this API description, the path will be parkpay.

Let's say that you deploy your application in a tomcat container hosted locally, on your computer, and that tomcat has the default settings which means it will listen for requests at port 8080. The Service Base URL in this case is http://localhost:8080/parkpay. The resource manager for the type parks will be found at: http://localhost:8080/parkpay/parks.

Also, all data is in JSON format. A GET request will return JSON. A PUT or POST will submit a JSON document.

To keep things simple, no authentication is required to access any resource.

All use cases marked with (*) are not required as part of the final delivery for this project.

To make examples easier to read we'll be using the following abbreviations throughout this document, instead of single generic id:

  • pid: park ID
  • nid: note ID
  • oid: order/payment ID
  • vid: visitor ID
  • rid: report ID

The following section show the resource sets and, for each of them the use cases implemented. NOTE" "search" is not exactly a resource set, however it is a valid end point for the API and it is needed to implement the search functionality as described in the requirements.


parks

^Top^ ^parks^

Create park

POST /parks

Creates a park and returns (in the body of the response) the ID of the park.

'Location' header with link to /parks/[pid] where [pid] is the newly assigned ID for the park.

HTTP response code:

  • 201 (Created) if everything is ok.
  • 400 (Bad Request) if any of the required data is missing or is invalid. In this case the body of the response should contain JSON that explains what went wrong.

Resource URL

/parks

Parameters

location_info: Information about the park

  • name (required): the name of the park
  • region (optional): the region of the state where park is located
  • address (required): the address of the park
  • phone (optional): the phone number for the park
  • web (required): the URL for the park's website
  • geo (required): the latitude and longitude for the park

Payment_info: Payment required for various vehicle classes.

  • motorcycle (required): first element of the array is for in-state license plates and the second is for out of state
  • car (required): first element of the array is for in-state license plates and the second is for out of state
  • rv (required): first element of the array is for in-state license plates and the second is for out of state

Example Request

    POST http://localhost:8080/parkpay/parks
  

Here is data being POST-ed

    {
    	"location_info": {
    		"name": "Apple River Canyon",
        "region": "Northwestern Illinois",
    		"address": "8763 E. Canyon Rd, Apple River, IL 61001",
    		"phone": "",
    		"web": "https://www.dnr.illinois.gov/Parks/Pages/AppleRiverCanyon.aspx",
        "geo": { "lat": 42.448, "lng": -90.043 }
    	},
    	"payment_info": {
    		"motorcycle": [5, 8],
    		"car": [7, 9],
    		"rv": [10,13]
    	}
    }
  

Example Response

    {
    	"pid": "123"
    }
  

Example Response when Something Went Wrong

Let's assume that the following data is being POST-ed

    {
      "location_info": {
        "name": "Apple River Canyon",
        "address": "8763 E. Canyon Rd, Apple River, IL 61001",
        "phone": "815-745-3302",
        "web": "https://www.dnr.illinois.gov/Parks/Pages/AppleRiverCanyon.aspx"
      },
      "payment_info": {
        "motorcycle": [5, 8],
        "car": [7, 10],
        "rv": [10,13]
      }
    }
  

In this case the response body will look like this:

    {
      "type": "http://cs.iit.edu/~virgil/cs445/project/api/problems/data-validation",
      "title": "Your request data didn't pass validation",
      "detail": "Geo information is required but missing in your request",
      "status": 400,
      "instance": "/parks"
    }
  

^Top^ ^parks^

Update park

PUT /parks/[pid]

Updates the park identified by [pid].

HTTP response codes:

  • 204 (No content) if everything is ok.
  • 400 (Bad Request) if any of the required data is missing or is invalid. In this case the body of the response should contain JSON that explains what went wrong.
  • 404 (Not found) the park identified by [pid] doesn't exist.

Resource URL

/parks/[pid]

Parameters

location_info: Information about the park

  • name (required): the name of the park
  • region (optional): the region of the state where park is located
  • address (required): the address of the park
  • phone (optional): the phone number for the park
  • web (required): the URL for the park's website
  • geo (required): the latitude and longitude for the park

Payment_info: Payment required for various vehicle classes. NOTE: all payment data must be positive numbers or zero.

  • motorcycle (required): first element of the array is for in-state license plates and the second is for out of state
  • car (required): first element of the array is for in-state license plates and the second is for out of state
  • rv (requied): first element of the array is for in-state license plates and the second is for out of state

Example Request

    PUT http://localhost:8080/parkpay/parks/123
  

Here is data being PUT

    {
    	"location_info": {
    		"name": "Apple River Canyon",
    		"region": "Northwestern Illinois",
    		"address": "8763 E. Canyon Rd, Apple River, IL 61001",
    		"phone": "815-745-3302",
    		"web": "https://www.dnr.illinois.gov/Parks/Pages/AppleRiverCanyon.aspx",
    		"geo": { "lat": 42.448, "lng": -90.043 }
    	},
    	"payment_info": {
    		"motorcycle": [5, 8],
    		"car": [7, 10],
    		"rv": [10, 13]
    	}
    }
  

Example Successful Response

The body of the response is empty.

Example Response when Something Went Wrong

Let's assume that the following data is being PUT

    {
    	"location_info": {
    		"name": "Apple River Canyon",
    		"region": "Northwestern Illinois",
    		"address": "8763 E. Canyon Rd, Apple River, IL 61001",
    		"phone": "815-745-3302",
    		"web": "https://www.dnr.illinois.gov/Parks/Pages/AppleRiverCanyon.aspx",
    		"geo": { "lat": 42.448, "lng": -90.043 }
    	},
    	"payment_info": {
    		"motorcycle": [5, -3],
    		"car": [7, 10],
    		"rv": [10, 13]
    	}
    }
  

In this case the response body will look like this:


    {
      "type": "http://cs.iit.edu/~virgil/cs445/project/api/problems/data-validation",
      "title": "Your request data didn't pass validation",
      "detail": "All payment data must be a number greater than or equal to zero",
      "status": 400,
      "instance": "/parks/123"
   }
  

^Top^ ^parks^

Delete park

DELETE /parks/[pid]

Deletes the park identified by [pid].

HTTP response codes:

  • 204 (No content) if the entity has been removed and there is no additional information in the body of the response.
  • 404 (Not found) if the park identified by [pid] doesn't exist.

Resource URL

/parks/[pid]

Parameters

None

Example Request

    DELETE http://localhost:8080/parkpay/parks/123
  

Example Successful Response

The body of the response is empty.

^Top^ ^parks^

View all parks

GET /parks

Returns a JSON array with all parks.

HTTP response codes:

  • 200 (OK).

Resource URL

/parks

Parameters

None

Example Request

    GET http://localhost:8080/parkpay/parks
  

Example Successful Response

    [{
    		"pid": 123,
    		"location_info": {
    			"name": "Apple River Canyon",
    			"region": "Northwestern Illinois",
    			"address": "8763 E. Canyon Rd, Apple River, IL 61001",
    			"phone": "815-745-3302",
    			"web": "https://www.dnr.illinois.gov/Parks/Pages/AppleRiverCanyon.aspx",
    			"geo": { "lat": 42.448, "lng": -90.043 }
    		}
    	},
    	{
    		"pid": 124,
    		"location_info": {
    			"name": "Castle Rock",
    			"region": "Northwestern Illinois",
    			"address": "1365 W. Castle Rd, Oregon IL 61061",
    			"phone": "815-732-7329",
    			"web": "https://www.dnr.illinois.gov/Parks/Pages/CastleRock.aspx",
    			"geo": { "lat": 41.978, "lng": -89.364 }
    		}
    	},
    	{
    		"pid": 131,
    		"location_info": {
    			"name": "Mermet Lake",
    			"region": "Southern Illinois",
    			"address": "1812 Grinnell Road, Belknap, IL 62908",
    			"phone": "618-524-5577",
    			"web": "https://www.dnr.illinois.gov/Parks/Pages/MermetLake.aspx",
    			"geo": { "lat": 37.275, "lng": -88.849 }
    		}
    	}
    ]
  

^Top^ ^parks^

View park detail

GET /parks/[pid]

Get detailed information about the park identified by [pid].

HTTP response codes:

  • 200 (OK).
  • 404 (Not found) if the park identified by [pid] doesn't exist.

Resource URL

/parks/[pid]

Parameters

None

Example Request

    GET http://localhost:8080/parkpay/parks/124
  

Example Successful Response

    {
      "pid": 124,
      "location_info": {
        "name": "Castle Rock",
        "region": "Northwestern Illinois",
        "address": "1365 W. Castle Rd, Oregon IL 61061",
        "phone": "815-732-7329",
        "web": "https://www.dnr.illinois.gov/Parks/Pages/CastleRock.aspx",
        "geo": { "lat": 41.978, "lng": -89.364 }
      },
      "payment_info": {
        "motorcycle": [2, 3],
        "car": [4.50, 7],
        "rv": [7, 9.25]
      }
    }
  

^Top^ ^parks^

Search parks

GET /parks?key=keyword

Returns an array of summary park information for the parks that match the search criteria.

HTTP response codes:

  • 200 (OK).

Resource URL

/parks

Parameters

  • key (required): the search key. Anything that matches the keyword (the value of key) will be included in the result set. The search is case insensitive. If keyword is empty, then match everything.
  • Example Request

        GET http://localhost:8080/parkpay/parks?key=south
      

    Example Response

        [
          {
            "pid": 131,
        	  "location_info": {
        	    "name": "Mermet Lake",
        	    "region": "Southern Illinois",
        	    "address": "1812 Grinnell Road, Belknap, IL 62908",
        	    "phone": "618-524-5577",
        	    "web": "https://www.dnr.illinois.gov/Parks/Pages/MermetLake.aspx",
        	    "geo": { "lat": 37.275, "lng": -88.849 }
        	  }
          }
        ]
      

    ^Top^ ^parks^

    View all notes associated with park

    GET /parks/[pid]/notes

    Get an array of summary information for notes associated with the park identified by [pid].

    HTTP response codes:

    • 200 (OK).
    • 404 (Not found) if the park identified by [pid] doesn't exist.

    Resource URL

    /parks/[pid]/notes

    Parameters

    None

    Example Request

        GET http://localhost:8080/parkpay/parks/124/notes
      

    Example Response

        [{
        		"nid": 311,
        		"date": "2018-07-03",
        		"title": "No campground"
        	},
        	{
        		"nid": 583,
        		"date": "2018-08-02",
        		"title": "Great fishing"
        	}
        ]
      

    ^Top^ ^parks^

    View note associated with park

    GET /parks/[pid]/notes/[nid]

    Get note [nid] associated with the park identified by [pid].

    HTTP response codes:

    • 200 (OK).
    • 400 (Bad request) if [nid] and [pid] are valid but the note [nid] is not associated with park [pid].
    • 404 (Not found) if the park identified by [pid] doesn't exist, or the note [nid] doesn't exist.

    Resource URL

    /parks/[pid]/notes/[nid]

    Parameters

    None

    Example Request

        GET http://localhost:8080/parkpay/parks/124/notes/583
      

    Example Response

        {
          "nid": 583,
          "pid": 124,
          "vid": 447,
          "date": "2018-08-02",
          "title": "Great fishing",
          "text": "Caught a walleye here, did't really expect anything other than catfish."
        }
      

    ^Top^ ^parks^

    Create note and associate with park

    POST /parks/[pid]/notes

    Creates a note and associates it with park [pid]. Returns (in the body of the response) the ID of the note.

    'Location' header with link to /notes/[nid] where [nid] is the ID for the newly created note.

    HTTP response code:

    • 201 (Created) if everything is ok.
    • 400 (Bad Request) if any of the required data is missing or is invalid, or if there is no record that the visitor has paid in the past for admission in the park [pid]. In this case the body of the response should contain JSON that explains what went wrong.

    Resource URL

    /parks/[pid]/notes

    Parameters

    • vid (required): visitor ID
    • title (required): a title for the note
    • text (required): detailed note

    Example Request

        POST http://localhost:8080/parkpay/parks/124/notes
      

    Here is data being POST-ed

        {
          "vid": 411,
          "title": "No campground",
          "text": "This place is beautiful, too bad that there is no campground here."
        }
      

    Example Response

        {
        	"nid": "311"
        }
      

    Example Response when Something Went Wrong

    Let's assume that the following data is being POST-ed

        {
          "vid": 412,
          "title": "Mosquitos galore",
          "text": "This is a nice place with good fihsing, but this year the mosquitos are killing us."
        }
      

    and that the visitor 412 never really paid for entrance to park 124.

    In this case the response body will look like this:

    
        {
          "type": "http://cs.iit.edu/~virgil/cs445/project/api/problems/data-validation",
          "title": "Your request data didn't pass validation",
          "detail": "You may not post a note to a park unless you paid for admission at that park",
          "status": 400,
          "instance": "/parks/124"
       }
      

    ^Top^ ^parks^


    notes

    ^Top^ ^notes^

    View all notes

    GET /notes

    Get an array of summary information for all notes.

    HTTP response codes:

    • 200 (OK).

    Resource URL

    /notes

    Parameters

    None

    Example Request

        GET http://localhost:8080/parkpay/notes
      

    Example Response

        [
          {
            "pid": 123,
            "notes": [
              {
                "nid": 317,
                "date": "2018-07-04",
                "title": "Mosquitos galore"
              }
            ]
          },
          {
            "pid": 124,
            "notes": [
              {
                "nid": 311,
                "date": "2018-07-03",
                "title": "No campground"
              },
              {
                "nid": 583,
                "date": "2018-08-02",
                "title": "Great fishing"
              }
            ]
          }
        ]
      

    ^Top^ ^notes^

    View note

    GET /notes/[nid]

    Get note [nid].

    HTTP response codes:

    • 200 (OK).
    • 404 (Not found) if note [nid] doesn't exist.

    Resource URL

    /notes/[nid]

    Parameters

    None

    Example Request

        GET http://localhost:8080/parkpay/notes/317
      

    Example Response

        {
          "nid": 317,
          "pid": 123,
          "vid": 412,
          "date": "2018-07-04",
          "title": "Mosquitos galore",
          "text": "This is a nice place with good fihsing, but this year the mosquitos are killing us."
        }
      

    ^Top^ ^notes^

    Update note

    PUT /notes/[nid]

    Updates note [nid].

    HTTP response code:

    • 204 (No content) if everything is ok.
    • 400 (Bad Request) if any of the required data is missing or is invalid. In this case the body of the response should contain JSON that explains what went wrong.
    • 404 (Not found) if [nid] doesn't exist.

    Resource URL

    /notes/[nid]

    Parameters

    • vid (required): visitor ID
    • title (required): a title for the note
    • text (required): detailed note

    Example Request

        PUT http://localhost:8080/parkpay/notes/317
      

    Here is data being POST-ed

        {
          "vid": 412,
          "title": "Mosquitos galore",
          "text": "This is a nice place with good fishing, but this year the mosquitos are killing us."
        }
      

    Example Response

    The body of the response is empty.

    ^Top^ ^notes^

    Search notes

    GET /notes?key=keyword

    Returns an array of summary notes information for the notes that match the search criteria.

    HTTP response codes:

    • 200 (OK).

    Resource URL

    /notes

    Parameters

  • key (required): the search key. Anything that matches the keyword (the value of key) will be included in the result set. The search is case insensitive. If keyword is empty, then match everything.
  • Example Request

        GET http://localhost:8080/parkpay/notes?key=FISH
      

    Example Response

        [
          {
            "pid": 123,
            "notes": [
              {
                "nid": 317,
                "date": "2018-07-04",
                "title": "Mosquitos galore"
              }
            ]
          },
          {
            "pid": 124,
            "notes": [
              {
                "nid": 583,
                "date": "2018-08-02",
                "title": "Great fishing"
              }
            ]
          }
        ]
      

    ^Top^ ^notes^


    orders

    ^Top^ ^orders^

    Create order

    POST /orders

    Creates an order and returns (in the body of the response) the ID of the order.

    'Location' header with link to /orders/[oid] where [oid] is the newly assigned ID for the order.

    HTTP response code:

    • 201 (Created) if everything is ok.
    • 400 (Bad Request) if any of the required data is missing or is invalid, or if the credit card processor returns an error. In this case the body of the response should contain JSON that explains what went wrong.

    Resource URL

    /orders

    Parameters

    pid (required): The ID of the park.

    vehicle (required): Detailed information about the vehicle the payment (order) is for.

    • state (required): Two letter abbreviations for the state that issued the license plate, e.g. "IL", "CA", "NY", etc.
    • plate (required): The license plate number, e.g. "GOCUBS".
    • type (required): The vehicle type; must match one of the types described in the park "payment_info" section.

    visitor (required): Information about the visitor.

    • name (optional): Visitor's name.
    • email (required): email address where the order confirmation will be sent.
    • payment_info (required): Credit/debit card information.
      • card (required): Card number, 15 (AmEx) or 16 numerical digits (Visa, MC).
      • name_on_card (required): Name on the card.
      • expiration_date (required): Date in "MM/YY" format.
      • zip (required): Billing address zip code.

    Example Request

        POST http://localhost:8080/parkpay/orders
      

    Here is data being POST-ed

        {
          "pid": 124,
          "vehicle": {
            "state": "IL",
            "plate": "GOCUBS",
            "type": "car"
          },
          "visitor": {
            "name": "John Doe",
            "email": "john.doe@example.com",
            "payment_info": {
              "card": "4388567890987654",
              "name_on_card": "John Doe",
              "expiration_date": "12/19",
              "zip": 60616
            }
          }
        }
      

    Example Response

        {
          "oid": "751"
        }
      

    Example Request

        POST http://localhost:8080/parkpay/orders
      

    Here is another example if data being POST-ed

        {
          "pid": 124,
          "vehicle": {
            "state": "CA",
            "plate": "60MPG",
            "type": "rv"
          },
          "visitor": {
            "name": "",
            "email": "jane.smith@example.com",
            "payment_info": {
              "card": "373456789045678",
              "name_on_card": "Jane Smith",
              "expiration_date": "05/23",
              "zip": 94102
            }
          }
        }
      

    Example Response

        {
          "oid": "761"
        }
      

    Example Response when Something Went Wrong

    Let's assume that the following data is being POST-ed and that the credit card processor decides to decline the transaction. Everything looks good as far as submitted data goes, so you don't have any validation errors, but that's not enough for a credit/debit transaction to go through.

        {
          "pid": 124,
          "vehicle": {
            "state": "CA",
            "plate": "60MPG",
            "type": "rv"
          },
          "visitor": {
            "name": "",
            "email": "jane.smith@example.com",
            "payment_info": {
              "card": "373456789074007",
              "name_on_card": "Jane Smith",
              "expiration_date": "05/23",
              "zip": 94102
            }
          }
        }
      

    In this case the response body may look like this:

    
        {
          "type": "http://cs.iit.edu/~virgil/cs445/project/api/problems/processing-errors",
          "title": "There has been an error processing your request.",
          "detail": "Credit card transaction declined.",
          "status": 400,
          "instance": "/orders"
       }
      

    ^Top^ ^orders^

    View all orders

    GET /orders

    Get an array of summary information for all orders.

    HTTP response codes:

    • 200 (OK).

    Resource URL

    /notes

    Parameters

    None

    Example Request

        GET http://localhost:8080/parkpay/orders
      

    Example Response

        [
          {
            "oid": 751,
            "pid": 124,
            "date": "2018-07-03",
            "type": "car",
            "amount": 4.50
          },
          {
            "oid": 761,
            "pid": 124,
            "date": "2018-08-02",
            "type": "rv",
            "amount": 9.25
          },
          {
            "oid": 757,
            "pid": 123,
            "date": "2018-07-04",
            "type": "car",
            "amount": 10
          },
          {
            "oid": 773,
            "pid": 123,
            "date": "2018-08-05",
            "type": "rv",
            "amount": 13
          }
        ]
      

    ^Top^ ^orders^

    View order

    GET /orders/[oid]

    Get order [oid].

    HTTP response codes:

    • 200 (OK).
    • 404 (Not found) if note [oid] doesn't exist.

    Resource URL

    /notes/[oid]

    Parameters

    None

    Example Request

        GET http://localhost:8080/parkpay/orders/751
      

    Example Response

        {
        	"oid": 751,
        	"pid": 123,
        	"amount": 4.50,
        	"vid": 411,
        	"date": "2018-07-03",
        	"vehicle": {
        		"state": "IL",
        		"plate": "GOCUBS",
        		"type": "car"
        	},
        	"visitor": {
        		"name": "John Doe",
        		"email": "john.doe@example.com",
        		"payment_info": {
        			"card": "xxxxxxxxxxxx7654",
        			"name_on_card": "John Doe",
        			"expiration_date": "12/19",
        			"zip": 60616
        		}
        	},
        	"payment_processing": {
        		"card_transaction_id": "123-4567-89",
        		"date_and_time": "2018-07-03T15:28:56.782Z"
        	}
        }
      

    ^Top^ ^orders^

    Search orders

    GET /orders?key=keyword

    Returns an array of summary order information for the orders that match the search criteria.

    HTTP response codes:

    • 200 (OK).

    Resource URL

    /orders

    Parameters

  • key (required): the search key. Anything that matches the keyword (the value of key) will be included in the result set. The search is case insensitive. If keyword is empty, then match everything.
  • Example Request

        GET http://localhost:8080/parkpay/orders?key=60MPG
      

    Example Response

        [
          {
            "oid": 761,
            "pid": 124,
            "date": "2018-08-02",
            "type": "rv",
            "amount": 9.25
          },
          {
            "oid": 773,
            "pid": 123,
            "date": "2018-08-05",
            "type": "rv",
            "amount": 13
          }
        ]
      

    Another Example Request

        GET http://localhost:8080/parkpay/orders?key=john.doe
      

    Example Response

        [
          {
            "oid": 751,
            "pid": 124,
            "date": "2018-07-03",
            "type": "car",
            "amount": 4.50
          }
        ]
      

    ^Top^ ^orders^


    visitors

    ^Top^ ^visitors^

    View all visitors

    GET /visitors

    Get an array of summary information for all visitors.

    HTTP response codes:

    • 200 (OK).

    Resource URL

    /visitors

    Parameters

    None

    Example Request

        GET http://localhost:8080/parkpay/visitors
      

    Example Response

        [
          {
            "vid": 411,
            "name": "John Doe",
            "email": "john.doe@example.com"
          },
          {
            "vid": 412,
            "name": "John Q. Public",
            "email": "jqpublic@example.com"
          },
          {
            "vid": 447,
            "name": "Jane Smith",
            "email": "jane.smith@example.com"
          }
        ]
      

    ^Top^ ^visitors^

    View visitor

    GET /visitors/[vid]

    Get visitor [vid] and order history.

    HTTP response codes:

    • 200 (OK).
    • 404 (Not found) if visitor [vid] doesn't exist.

    Resource URL

    /visitors/[vid]

    Parameters

    None

    Example Request

        GET http://localhost:8080/parkpay/visitors/447
      

    Example Response

        {
        	"vid": 447,
        	"visitor": {
        		"name": "Jane Smith",
        		"email": "jane.smith@example.com"
        	},
        	"orders": [{
        			"oid": 761,
        			"pid": 124,
        			"date": "2018-08-02"
        		},
        		{
        			"oid": 773,
        			"pid": 123,
        			"date": "2018-08-05"
        		}
        	],
        	"notes": [{
        		"nid": 583,
        		"pid": 124,
        		"date": "2018-08-02",
        		"title": "Great fishing"
        	}]
        }
      

    ^Top^ ^visitors^

    Search visitors

    GET /visitors?key=keyword

    Returns an array of summary visitor information that match the search criteria.

    HTTP response codes:

    • 200 (OK).

    Resource URL

    /visitors

    Parameters

  • key (required): the search key. Anything that matches the keyword (the value of key) will be included in the result set. The search is case insensitive. If keyword is empty, then match everything.
  • Example Request

        GET http://localhost:8080/parkpay/visitors?key=John
      

    Example Response

        [
          {
            "vid": 411,
            "name": "John Doe",
            "email": "john.doe@example.com"
          },
          {
            "vid": 412,
            "name": "John Q. Public",
            "email": "jqpublic@example.com"
          }
        ]
      

    ^Top^ ^visitors^


    reports

    ^Top^ ^reports^

    View all reports

    GET /reports

    Returns an array of report IDs with their corresponding names.

    HTTP response code: 200 (OK).

    Resource URL

    /reports

    Parameters

    None.

    Example Request

    
        GET http://localhost:8080/parkpay/reports
      

    Example Response

        [{
            "rid": 907,
            "name": "Admissions report"
          }, {
            "mrid": 911,
            "name": "Revenue report"
          }
        ]
      

    ^Top^ ^reports^

    Get report

    GET /reports/[rid]{?start_date=YYYYMMDD&end_date=YYYYMMDD}

    Returns the report identified by [rid]. If no dates are provided, then include all admissions you have in the system. If a start_date is provided and no end_date, then include all admissions on the start_date and after. If only the end_date is specified, then include all admissions prior to and on the end_date. Finally, if both the start_date and end_date are provided, then only include admissions in that range (including admissions on the start and dates). The report must include all parks.

    HTTP response codes:

    • 200 (OK).
    • 404 (Not Found) if [rid] doesn't exist.

    Resource URL

    /reports/[rid]

    Parameters

    • start_date (optional): the start date for the date range of the report.
    • end_date (optional): the end date for the date range of the report.

    Example Request

        GET http://localhost:8080/parkpay/reports/907
      

    Example Response

        {
        	"rid": 907,
        	"name": "Admissions report",
        	"start_date": "",
        	"end_date": "",
        	"total_admissions": 4,
        	"detail_by_park": [{
        			"pid": 123,
        			"name": "Apple River Canyon",
        			"admissions": 2
        		},
        		{
        			"pid": 124,
        			"name": "Castle Rock",
        			"admissions": 2
        		},
        		{
        			"pid": 131,
        			"name": "Mermet Lake",
        			"admissions": 0
        		}
        	]
        }
      

    Another Example Request

        GET http://localhost:8080/parkpay/reports/911?start_date=20180701&end_date=20180731
      

    Example Response

        {
        	"rid": 911,
        	"name": "Revenue report",
        	"start_date": "2018-08-01",
        	"end_date": "2018-08-31",
        	"total_orders": 2,
        	"total_revenue": 22.25,
        	"detail_by_park": [{
        			"pid": 123,
        			"name": "Apple River Canyon",
        			"orders": 1,
        			"revenue": 13.00
        		},
        		{
        			"pid": 124,
        			"name": "Castle Rock",
        			"orders": 1,
        			"revenue": 9.25
        		},
        		{
        			"pid": 131,
        			"name": "Mermet Lake",
        			"orders": 0,
        			"revenue": 0.00
        		}
        	]
        }
      

    ^Top^ ^reports^


    search

    ^Top^ ^search^

    • Search ( GET /search?key=keyword{&start_date=YYYYMMDD&end_date=YYYYMMDD} )

    ^Top^ ^search^

    Search

    GET /search?key=keyword{&start_date=YYYYMMDD&end_date=YYYYMMDD}

    Returns an array that includes all parks, orders, visitors, notes that match the keyword. The start and end dates are used to filter out matches that fall outside the data range. If a start_date is provided and no end_date, then include all search results on the start_date and after. If only the end_date is specified, then include all search results prior to and on the end_date.

    HTTP response codes:

    • 200 (OK).

    Resource URL

    /search

    Parameters

    • key (required): the search key. Anything that matches the keyword (the value of key) will be included in the result set. The search is case insensitive. If keyword is empty, then match everything.
    • start_date (optional): the start date for the date range of the report.
    • end_date (optional): the end date for the date range of the report.

    Example Request

        GET http://localhost:8080/parkpay/search?key=&start_date=20180802&end_date=20180802
      

    Example Response

    
      

    ^Top^ ^search^


    Last update: Oct 25, 2018 Virgil Bistriceanu cs445 Computer Science