   digitalWrite(LED, LOW);
 }
 
-// Returns true if the read was successful, false otherwise.
+// Returns true if no card is being read, false otherwise
 bool readCard() {
   return ( (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) );
 }
 
+// Cheating test function that tests authorization of current card
+bool cheatAuthorization() {
+  if(UID == 0x647B403B)
+    return true;
+  else
+    return false;
+}
+
+bool cheatAuthorization2() {
+  Serial.print("Attempting to cheat Authorization...\n");
+  if(UID == 0x647B403B){
+    UID = 12345678; // This is a staff ID#
+    Serial.print("Authorization should be set to True\n");
+    return (checkAuthorization());
+  }
+  else {
+    Serial.print("Authorization should be set to False\n");
+    return false;
+  }
+}
+
+// Generates a path to be used for the post and get API commands
+// The command field should either be the string "swipe" or "update"
+// A string containing the path to be updated is returned...
+// Returned string looks like the following
+// "/command/key/lotID/spotID/"
+String createPath(String command)
+{
+  String tempPath;
+  String spotsHW = "/spotsHW";
+  tempPath =  spotsHW + '/' + command + '/' + apiKey + '/' + lotID + '/' + spotID + '/';
+//  Serial.print("Generated path: ");
+//  Serial.print(tempPath);
+//  Serial.println();
+//  delay(100);
+  return tempPath;
+}
+
+// Updates the vacancy of the spot with the server
+// If the spot is not occupied, set vacant = true;
+// else, set it to false
+bool updateVacancy(bool vacant)
+{
+  String updatePath = createPath("update");
+  const char * c;
+  int statusCode;
+  response = "";
+  
+  if(vacant) {
+    updatePath = updatePath + "true";
+  }
+  else {
+    updatePath = updatePath + "false";
+  }
+
+  c = updatePath.c_str();
+  Serial.print("Generated path: ");
+  Serial.print(c);
+  Serial.println();
+  delay(10);
+  // This is done in this way because client.post requires a const char* for the path...
+  // client.post(const char* path, const char* body, String* response)
+  statusCode = client.post(c, "POSTDATA", &response);
+  Serial.print("Status code from server: ");
+  Serial.println(statusCode);
+  Serial.print("Response body from server: ");
+  Serial.println(response);
+  delay(10);
+  if(statusCode == 200) // Status Code 200 means "OK"
+    return true;
+  else
+    return false;
+}
+
+// Checks the whether the user was authorized
+// Returns true if the user is authorized,
+// false otherwise.
+bool checkAuthorization()
+{
+  String swipePath = createPath("swipe");
+  // UID is a global variable that contains the integer representation of the card ID
+  String cardID = String(UID);
+  swipePath = swipePath + cardID;
+  const char * c;
+  int statusCode;
+  int len;
+  
+  c = swipePath.c_str();
+  Serial.print("swipePath: ");
+  Serial.print(c);
+  Serial.println();
+  statusCode = client.post(c, "POSTDATA", &response);
+  Serial.print("Status code from server: ");
+  Serial.println(statusCode);
+  Serial.print("Response body from server: ");
+  Serial.println(response); 
+  delay(10);
+
+  // Search the response string for "true" to see if user is authorized
+  len = response.length();
+  for(int i = 0; i <= len; i++) {
+    if(response.substring(i, i + 4) == "true")
+      return true;
+  }
+  // if we can't find "true" in the response string, user is not authorized...
+  return false;
+}

unsigned long start_time = 0;
unsigned long current_time = 0;
unsigned long timer = 0;
unsigned int timeLimit = 300000;  // Time in milliseconds for sign in
String response;
bool cardPresent = false;
bool authorized = false;

// List of all the beautiful functions used for this immaculate device
void Wifi_connect();  // Setup code to connect the ESP8266 to the wifi_chip
void get_UID();     // Function to read the data UID from a card
void flash_LED();
bool readCard();    // Convenience Function to read a card

void setup() {
  pinMode(Sensor_Pin, INPUT);

#include <MFRC522.h>      // Library Downloaded from: https://github.com/miguelbalboa/rfid
#include "RestClient.h"   // Library Downloaded from: https://github.com/DaKaZ/esp8266-restclient

#define apiKey  "1234"    //  Key for interacting with server
#define lotID  "NV"    //  The hardware's current lotID, must be changed for each post...
#define spotID  "NV010"  //  The lot number the hardware is set up at, must be changed for each post...

// These two fields must be changed if a different access point is used.
#define weefee_ID       "stuff"
#define weefee_Password "stuffy"

#define Green_Led   15
#define Red_Led     0
