Get a list of shifts
URL: GET /api/v1/shifts[?code=<shift_code>]
Content: None
Returns: A list of Shifts filtered by shift_code, if supplied.
Get a shift by ID
URL: GET /api/v1/shifts/<shift_id>
Content: None
Returns: A single Shift whose ID is shift_id.
Create a shift
URL: POST /api/v1/shifts
Content: The Shift to create.
Returns: The Shift created.
Update a shift
URL: PUT /api/v1/shifts
Content: The Shift to update.
Returns: The Shift updated.
Delete a shift by ID
URL: DELETE /api/v1/shifts/<shift_id>
Content: None
Returns: None
Example Code
public string ReadFirstShiftDescription(string accessToken)
{
string shift = 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/shifts");
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's description
if (( (HttpWebResponse) webResponse).StatusCode == HttpStatusCode.OK)
{
var reader = new StreamReader(webResponse.GetResponseStream());
dynamic shiftArray = JsonConvert.DeserializeObject<dynamic>(reader.ReadToEnd());
// If the returned array contains more than one shift, extract the first shift's description.
if (shiftArray.Count > 0)
{
shift = shiftArray[0].Description;
}
reader.Close();
}
}
}
catch (WebException e)
{
// An error occurred in the call -- handle appropriately
Console.WriteLine(e);
}
return shift;
}
function getFirstShiftDescription(accessToken, callback)
{
// URL of API to invoke
var serviceUrl = "https://app.snapschedule365.com/api/v1/shifts";
// 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 shiftArray = JSON.parse(request.responseText);
// If the returned array contains more than one shift, extract the first shift
if (shiftArray.length > 0)
{
callback(shiftArray[0].Description);
}
else
{
callback(null);
}
}
else
{
alert("HTTP status: " + request.status + "\n" + request.responseText);
}
}
}
// Send the request
request.send();
}