Get a list of time off schedules
URL: GET /api/v1/timeoffschedules[?startDate=<start_date>][&endDate=<end_date>]
Content: None
Returns: A list of Time Off Schedules filtered by start_date and end_date, if supplied.
Get a time off schedule by ID
URL: GET /api/v1/timeoffschedules/<time_off_schedule_id>
Content: None
Returns: A single Time Off Schedule whose ID is time_off_schedule_id.
Create a time off schedule
URL: POST /api/v1/timeoffschedules
Content: The Time Off Schedule to create.
Returns: The Time Off Schedule created.
Update a time off schedule
URL: PUT /api/v1/timeoffschedules
Content: The Time Off Schedule to update.
Returns: The Time Off Schedule updated.
Delete a time off schedule by ID
URL: DELETE /api/v1/timeoffschedules/<time_off_schedule_id>
Content: None
Returns: None
Example Code
public int ReadFirstScheduledTimeOffDuration(string accessToken)
{
int duration = 0;
// 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/timeoffschedules");
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 scheduled time off's duration in minutes
if (( (HttpWebResponse) webResponse).StatusCode == HttpStatusCode.OK)
{
var reader = new StreamReader(webResponse.GetResponseStream());
dynamic timeOffScheduleArray = JsonConvert.DeserializeObject<dynamic>(reader.ReadToEnd());
// If the returned array contains more than one scheduled time off, extract the first time off's duration.
if (timeOffScheduleArray.Count > 0)
{
duration = timeOffScheduleArray[0].Duration;
}
reader.Close();
}
}
}
catch (WebException e)
{
// An error occurred in the call -- handle appropriately
Console.WriteLine(e);
}
return duration;
}
function getFirstScheduledTimeOffDuration(accessToken, callback)
{
// URL of API to invoke
var serviceUrl = "https://app.snapschedule365.com/api/v1/timeoffschedules";
// 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 scheduled time off, extract the first time off's duration.
if (timeOffArray.length > 0)
{
callback(timeOffArray[0].Duration);
}
else
{
callback(null);
}
}
else
{
alert("HTTP status: " + request.status + "\n" + request.responseText);
}
}
}
// Send the request
request.send();
}