Getting a list of employees

URL: GET /api/v1/employees[?code=<employee_code>]

Content: None

Returns: A list of Employees filtered by employee_code, if supplied.

Getting employee by ID

URL: GET /api/v1/employees/<employee_id>

Content: None

Returns: A single Employee whose ID is employee_id.

Creating an employee

URL: POST /api/v1/employees

Content: The Employee to create.

Returns: The Employee created.

Updating employee information

URL: PUT /api/v1/employees

Content: The Employee to update.

Returns: The Employee updated.

Deleting employee by ID

URL: DELETE /api/v1/employees/<employee_id>

Content: None

Returns: None

Example Code

public string ReadFirstEmployeeName(string accessToken)
{

	string employeeName = string.Empty;

	// Create web request to call API (be sure to add access token to request header)
	var webRequest = (HttpWebRequest) WebRequest.Create(@"https://app.snapschedule365.com/api/v1/employees");
	webRequest.Method = "GET";
	webRequest.Accept = @"application/json";

	webRequest.Headers.Add("Authorization", "Bearer " + accessToken);
	webRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

	try
	{
		using (WebResponse webResponse = webRequest.GetResponse())
		{
			// If the web response is OK, then read the reply and extract the first employee's name
			if (( (HttpWebResponse) webResponse).StatusCode == HttpStatusCode.OK)
			{
				var reader = new StreamReader(webResponse.GetResponseStream());
				dynamic employeeArray = JsonConvert.DeserializeObject<dynamic>(reader.ReadToEnd());

				// If the returned array contains more than one employee, extract the first name
				if (employeeArray.Count > 0)
				{
					employeeName = employeeArray.First.Name;
				}

				reader.Close();
			}
		}
	}
	catch (WebException e)
	{
		// An error occurred in the call -- handle appropriately
		Console.WriteLine(e);
	}
	
	return employeeName;

}
function getFirstEmployeeName(accessToken, callback)
{
	// URL of API to invoke
	var serviceUrl = "https://app.snapschedule365.com/api/v1/employees";

	// Create the request
	var request = new XMLHttpRequest();

	// Build the request
	request.open("GET", serviceUrl, true);
	request.setRequestHeader("accept", "application/json");
	
	// Add access token to request
	request.setRequestHeader("Authorization", "Bearer " + accessToken);  

	// Set up request status handler to invoke the callback function when complete
	request.onreadystatechange = function()
	{
		if (request.readyState == 4)
		{
			if (request.status == 200)
			{
				var employeeArray = JSON.parse(request.responseText);

				// If the returned array contains employees, extract the first name
				if (employeeArray.length > 0)
				{
					callback(employeeArray[0].Name);
				}
				else
				{
					callback(null);
				}
			}
			else
			{
				alert("HTTP status: " + request.status + "\n" + request.responseText);
			}
		}
	}

	// Send the request
	request.send();
}