Getting a list of shift requirements

URL: GET /api/v1/shiftrequirements[?startDate=<start_date>][&endDate=<end_date>]

Content: None

Returns: A list of Shift Requirements filtered by start_date and end_date, if supplied.

Getting shift requirement by ID

URL: GET /api/v1/shiftrequirements/<shift_requirement_id>

Content: None

Returns: A single Shift Requirement whose ID is shift_requirement_id.

Creating a shift requirement

URL: POST /api/v1/shiftrequirements

Content: The Shift Requirement to create.

Returns: The Shift Requirement created.

Updating shift requirement information

URL: PUT /api/v1/shiftrequirements

Content: The Shift Requirement to update.

Returns: The Shift Requirement updated.

Deleting shift requirement by ID

URL: DELETE /api/v1/shiftrequirements/<shift_requirement_id>

Content: None

Returns: None

Example Code

public string ReadFirstShiftRequirementShiftDescription(string accessToken)
{

    string shiftName = 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/shiftrequirements");
    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 shift requirement's shift description
            if (( (HttpWebResponse) webResponse).StatusCode == HttpStatusCode.OK)
            {
                var reader = new StreamReader(webResponse.GetResponseStream());
                dynamic shiftRequirementArray = JsonConvert.DeserializeObject<dynamic>(reader.ReadToEnd());

                // If the returned array contains more than one shift requirement, extract the first requirement's shift description.
                if (shiftRequirementArray.Count > 0 && shiftRequirementArray[0].Shift != null)
                {
                    shiftName = shiftRequirementArray[0].Shift.Description;
                }

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

    return shiftName;

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

	// 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 shiftRequirementArray = JSON.parse(request.responseText);

				// If the returned array contains more than one shift requirement, extract the first requirement's shift description
				if (shiftRequirementArray.length > 0 && shiftRequirementArray[0].Shift !=null)
				{
					callback(shiftRequirementArray[0].Shift.Description);
				}
				else
				{
					callback(null);
				}
			}
			else
			{
				alert("HTTP status: " + request.status + "\n" + request.responseText);
			}
		}
	}

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