Get a list of time off reasons
URL: GET /api/v1/timeoffreasons[?code=<time_off_reason_code>]
Content: None
Returns: A list of Time Off Reasons filtered by time_off_reason_code, if supplied.
Get a time off reason by ID
URL: GET /api/v1/timeoffreasons/<time_off_reason_id>
Content: None
Returns: A single Time Off Reason whose ID is time_off_reason_id.
Create a time off reason
URL: POST /api/v1/timeoffreasons
Content: The Time Off Reason to create.
Returns: The Time Off Reason created.
Update a time off reason
URL: PUT /api/v1/timeoffreasons
Content: The Time Off Reason to update.
Returns: The Time Off Reason updated.
Delete a time off reason by ID
URL: DELETE /api/v1/timeoffreasons/<time_off_reason_id>
Content: None
Returns: None
Example Code
public bool IsFirstTimeOffReasonPaid(string accessToken)
{
bool isPaid = false;
// 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/timeoffreasons");
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 determine whether or not the first time off reason is paid.
if (( (HttpWebResponse) webResponse).StatusCode == HttpStatusCode.OK)
{
var reader = new StreamReader(webResponse.GetResponseStream());
dynamic timeOffReasonArray = JsonConvert.DeserializeObject<dynamic>(reader.ReadToEnd());
// If the returned array contains more than one time off reason, determine whether the first reason is paid.
if (timeOffReasonArray.Count > 0)
{
isPaid = timeOffReasonArray[0].IsPaid;
}
reader.Close();
}
}
}
catch (WebException e)
{
// An error occurred in the call -- handle appropriately
Console.WriteLine(e);
}
return isPaid;
}
function isFirstTimeOffReasonPaid(accessToken, callback)
{
// URL of API to invoke
var serviceUrl = "https://app.snapschedule365.com/api/v1/timeoffreasons";
// 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 timeOffArray = JSON.parse(request.responseText);
// If the returned array contains more than one time off reason, determine whether the first reason is paid.
if (timeOffArray.length > 0)
{
callback(timeOffArray[0].IsPaid);
}
else
{
callback(null);
}
}
else
{
alert("HTTP status: " + request.status + "\n" + request.responseText);
}
}
}
// Send the request
request.send();
}