Labor2.svc
Calls
Sending a Request to Labor2.svc
All calls to Labor2.svc require the AccessToken and the LocationToken in the HTTP Web Request
Headers of the request. The parameters for the request body of each call are outlined in the sections
below.
Labor2.svc Endpoint
Endpoint
https://{{server}}.brinkpos.net/Labor2.svc
HTTP Web Request Headers
Header Name
Header Value
AccessToken
{{AccessToken}}
LocationToken
{{LocationToken}}
This call is to retrieve a LaborSchedule object for the location.
GetLaborSchedule Request
Data Name
Data Type
Data Description
EndDate
DateTime
Specify the end date of the range you would like to see the Labor Schedule to
StartDate
DateTime
Specify the start date of the range you would like to see the Labor Schedule from
GetLaborSchedule Response
Data Name
Data Type
Data Description
Message
string
Returns a Brink Error message if the request did not go through. Otherwise, this field will be null.
ResultCode
int
Returns one of the following:
- 0 = Request went through successfully
- 1 = Request returned an unknown error
- 2 = Request was not valid
- 3 = Server is currently unavailable and unable to receive the request
- 4 = Access Denied
This call is to retrieve an array of Shift objects for the location.
GetShifts Request
Data Name
Data Type
Data Description
BusinessDate
DateTime?
Specify the business date for which you would like to see the shifts worked
ModifiedTime
DateTimeOffset?
(Optional) When specified, only shifts that have been modified on or after the specified time will be retrieved. This compares against any edited shifts on the Register time.
GetShifts Response
Data Name
Data Type
Data Description
Message
string
Returns a Brink Error message if the request did not go through. Otherwise, this field will be null.
ResultCode
int
Returns one of the following:
- 0 = Request went through successfully
- 1 = Request returned an unknown error
- 2 = Request was not valid
- 3 = Server is currently unavailable and unable to receive the request
- 4 = Access Denied
This call is to save a labor schedule of scheduled shifts for the location for one or more days.
SaveLaborSchedule Request
Data Name
Data Type
Data Description
SaveLaborSchedule Response
Data Name
Data Type
Data Description
EmployeeId
int?
Populated with an Employee Id if the request is invalid, e.g. if the employee has been terminated or in the case of an invalid JobId listed for an employee. Otherwise, this field will be null.
JobId
int?
Populated with a Job Id if the request is invalid, e.g. in the case of there is an invalid JobId listed for an employee. Otherwise, this field will be null.
Message
string
Returns a Brink Error message if the request did not go through. Otherwise, this field will be null.
ResultCode
int
Returns one of the following:
- 0 = Request went through successfully
- 1 = Request returned an unknown error
- 2 = Request was not valid
- 3 = Server is currently unavailable and unable to receive the request
- 4 = Access Denied
ValidationMessages
Array of string
Details if the request was unsuccessful
Global Type
All the Types available in Labor2.svc will be displayed below.
Break Type
Data Name
Data Type
Data Description
EndTime
DateTimeOffset
End time of this Break
Minutes
int
Minutes of this paid Break (unpaid Breaks not included)
Number
byte
Incremental count of the employee's Breaks for a particular business date. (e.g. Returns a "1" for first break of the day, "2" for second, etc.)
IsPaid
bool
True if this is paid Break, False if not
StartTime
DateTimeOffset
Start time of this Break
LaborSchedule Type
Data Name
Data Type
Data Description
LaborScheduleDay Type
Data Name
Data Type
Data Description
BusinessDate
DateTime
Business date for this LaborScheduleDay (the time component will always return as 00:00:00)
Shift Type
Data Name
Data Type
Data Description
BusinessDate
DateTime
Business date of this Shift (the time component will always return as 00:00:00)
ClockOutBusinessDate
DateTime
Business date on which this Shift was clocked out (the time component will always return as 00:00:00)
DeclaredTips
decimal
Tips declared for this Shift
EndTime
DateTimeOffset
End time of this Shift
ExtendedMinutesWorked
int
Amount of minutes worked for this Shift outside of regular working hours, to be paid at a regular pay rate
Id
Guid
Unique Id of this Shift
MinutesWorked
int
Amount of total minutes worked for this Shift
ModifiedTime
DateTimeOffset
Date and time of the last time this Shift was modified (e.g. by a clock in/out or break event)
Number
byte
Incremental count of the employee's Shifts for a particular business date. (e.g. Returns a "1" for first shift of the day, "2" for second, etc.)
OvertimeMinutesWorked
int
Amount of minutes worked for this Shift in overtime, to be paid at an overtime pay rate
PayRate
decimal
Payrate that was current for the job at the time of this Shift
RegularMinutesWorked
int
Amount of minutes worked for this Shift within regular working hours, to be paid at a regular pay rate
StartTime
DateTimeOffset
Start time of this Shift
GetLaborSchedule Sample Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; using System.ServiceModel.Web; using Labor2_GetLaborSchedule.Labor2ServiceReference; namespace Labor2_GetLaborSchedule { class Program { static void Main(string[] args) { //Connect to Labor2 service client var client = new LaborWebService2Client(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include tokens in HTTP Web Request Headers var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["AccessToken"] = @"AccessToken"; headers["LocationToken"] = @"LocationToken"; DateTime startDate = new DateTime(2001, 01, 01); DateTime endDate = new DateTime(2001, 01, 08); //Include StartDate and EndDate parameters in request body var request = new GetLaborScheduleRequest() { StartDate = startDate, EndDate = endDate, }; //Make GetLaborSchedule call var response = client.GetLaborSchedule(request); //If call is successful if (response.ResultCode == 0) { if (response.LaborSchedule.Days.Length > 0) { //Loop through collection of LaborScheduleDay objects returned foreach (var day in response.LaborSchedule.Days) { Console.WriteLine("BusinessDate: " + day.BusinessDate); if (day.Shifts.Length > 0) { //Loop through collection of ScheduledShift objects returned for each BusinessDate foreach (var shift in day.Shifts) { Console.WriteLine("Shifts:"); Console.WriteLine("\tEmployeeId: " + shift.EmployeeId); Console.WriteLine("\tJobId: " + shift.JobId); Console.WriteLine("\tStartTime: " + shift.StartTime); Console.WriteLine("\tEndTime: " + shift.EndTime); Console.WriteLine("\t------------"); } } else { Console.WriteLine("\tNo Shifts"); } Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Labor Schedule"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); Console.ReadKey(); } } } } }
GetLaborSchedule Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference6; using System.ServiceModel; using System.ServiceModel.Channels; namespace Labor2_GetLaborSchedule { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLaborServiceClient() { services.AddTransient<ILaborWebService2>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILaborWebService2> factory = new ChannelFactory<ILaborWebService2>(binding, endpointAddress); return factory.CreateChannel(); }); } static void Main(string[] args) { AddLaborServiceClient(); ILaborWebService2 client = services.BuildServiceProvider().GetRequiredService<ILaborWebService2>(); try { int count = 1; using (OperationContextScope scope = new OperationContextScope((IContextChannel)client)) { OperationContext context = OperationContext.Current; HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers["AccessToken"] = 'AccessToken'; httpRequestProperty.Headers["LocationToken"] = 'LocationToken'; context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; DateTime startDate = new DateTime(2001, 01, 01); DateTime endDate = new DateTime(2001, 01, 08); //Include StartDate and EndDate parameters in request body var request = new GetLaborScheduleRequest() { StartDate = startDate, EndDate = endDate, }; //Make GetLaborSchedule call var response = client.GetLaborScheduleAsync(request); Console.WriteLine("GetLaborSchedule"); Console.WriteLine("-----------------"); //If call is successful if (response.Result.ResultCode == 0) { Console.WriteLine(response.Result.ResultCode); if (response.Result.LaborSchedule.Days.Length > 0) { //Loop through collection of LaborScheduleDay objects returned foreach (var day in response.Result.LaborSchedule.Days) { Console.WriteLine("BusinessDate: " + day.BusinessDate); if (day.Shifts.Length > 0) { //Loop through collection of ScheduledShift objects returned for each BusinessDate foreach (var shift in day.Shifts) { Console.WriteLine("Shifts:"); Console.WriteLine("\tEmployeeId: " + shift.EmployeeId); Console.WriteLine("\tJobId: " + shift.JobId); Console.WriteLine("\tStartTime: " + shift.StartTime); Console.WriteLine("\tEndTime: " + shift.EndTime); Console.WriteLine("\t------------"); } } else { Console.WriteLine("\tNo Shifts"); } Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Labor Schedule"); Console.WriteLine("---------------------------"); } Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.Result.ResultCode); Console.WriteLine("Message: " + response.Result.Message); } } } catch (Exception ex) { Console.WriteLine("Error calling GetLaborSchedule operation: " + ex.Message); } } } }
GetShifts Sample Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; using System.ServiceModel.Web; using Labor2_GetShifts.Labor2ServiceReference; namespace Labor2_GetShifts { class Program { static void Main(string[] args) { //Connect to Labor2 service client var client = new LaborWebService2Client(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include tokens in HTTP Web Request Headers var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["AccessToken"] = @"AccessToken"; headers["LocationToken"] = @"LocationToken"; DateTime businessDate = new DateTime(2001, 01, 01); //Include BusinessDate parameter in UTC in request body var request = new GetShiftsRequest() { BusinessDate = businessDate, }; //Make GetShifts call var response = client.GetShifts(request); //If call is successful if (response.ResultCode == 0) { if (response.Shifts.Length > 0) { //Loop through collection of Shift objects returned foreach (var shift in response.Shifts) { Console.WriteLine("BusinessDate: " + shift.BusinessDate); Console.WriteLine("ClockOutBusinessDate: " + shift.ClockOutBusinessDate); Console.WriteLine("EmployeeId: " + shift.EmployeeId); Console.WriteLine("JobId: " + shift.JobId); Console.WriteLine("Id: " + shift.Id); Console.WriteLine("StartTime: " + shift.StartTime); Console.WriteLine("EndTime: " + shift.EndTime); Console.WriteLine("ModifiedTime: " + shift.ModifiedTime); Console.WriteLine("Number: " + shift.Number); Console.WriteLine("PayRate: " + shift.PayRate); Console.WriteLine("DeclaredTips: " + shift.DeclaredTips); Console.WriteLine("MinutesWorked: " + shift.MinutesWorked); Console.WriteLine("RegularMinutesWorked: " + shift.RegularMinutesWorked); Console.WriteLine("ExtendedMinutesWorked: " + shift.ExtendedMinutesWorked); Console.WriteLine("OvertimeMinutesWorked: " + shift.OvertimeMinutesWorked); if (shift.Breaks.Length > 0) { //Loop through collection of Break objects returned for each Shift foreach (var workBreak in shift.Breaks) { Console.WriteLine("Breaks: "); Console.WriteLine("\tStartTime: " + workBreak.StartTime); Console.WriteLine("\tEndTime: " + workBreak.EndTime); Console.WriteLine("\tNumber: " + workBreak.Number); Console.WriteLine("\tMinutes: " + workBreak.Minutes); Console.WriteLine("\tIsPaid: " + workBreak.IsPaid); Console.WriteLine("\t------------"); } } else { Console.WriteLine("\tNo Breaks"); } Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Shifts"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); Console.ReadKey(); } } } } }
GetShifts Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference6; using System.ServiceModel; using System.ServiceModel.Channels; namespace Labor2_GetShifts { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLaborServiceClient() { services.AddTransient<ILaborWebService2>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILaborWebService2> factory = new ChannelFactory<ILaborWebService2>(binding, endpointAddress); return factory.CreateChannel(); }); } static void Main(string[] args) { AddLaborServiceClient(); ILaborWebService2 client = services.BuildServiceProvider().GetRequiredService<ILaborWebService2>(); try { int count = 1; using (OperationContextScope scope = new OperationContextScope((IContextChannel)client)) { OperationContext context = OperationContext.Current; HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers["AccessToken"] = 'AccessToken'; httpRequestProperty.Headers["LocationToken"] = 'LocationToken'; context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; DateTime businessDate = new DateTime(2024, 04, 08); //Include BusinessDate parameter in UTC in request body var request = new GetShiftsRequest() { BusinessDate = businessDate, ModifiedTime = businessDate }; //Make GetShifts call var response = client.GetShiftsAsync(request); Console.WriteLine("GetShifts"); Console.WriteLine("----------"); //If call is successful if (response.Result.ResultCode == 0) { Console.WriteLine(response.Result.ResultCode); if (response.Result.Shifts.Length > 0) { //Loop through collection of Shift objects returned foreach (var shift in response.Result.Shifts) { Console.WriteLine("BusinessDate: " + shift.BusinessDate); Console.WriteLine("ClockOutBusinessDate: " + shift.ClockOutBusinessDate); Console.WriteLine("EmployeeId: " + shift.EmployeeId); Console.WriteLine("JobId: " + shift.JobId); Console.WriteLine("Id: " + shift.Id); Console.WriteLine("StartTime: " + shift.StartTime); Console.WriteLine("EndTime: " + shift.EndTime); Console.WriteLine("ModifiedTime: " + shift.ModifiedTime); Console.WriteLine("Number: " + shift.Number); Console.WriteLine("PayRate: " + shift.PayRate); Console.WriteLine("DeclaredTips: " + shift.DeclaredTips); Console.WriteLine("MinutesWorked: " + shift.MinutesWorked); Console.WriteLine("RegularMinutesWorked: " + shift.RegularMinutesWorked); Console.WriteLine("ExtendedMinutesWorked: " + shift.ExtendedMinutesWorked); Console.WriteLine("OvertimeMinutesWorked: " + shift.OvertimeMinutesWorked); if (shift.Breaks.Length > 0) { //Loop through collection of Break objects returned for each Shift foreach (var workBreak in shift.Breaks) { Console.WriteLine("Breaks: "); Console.WriteLine("\tStartTime: " + workBreak.StartTime); Console.WriteLine("\tEndTime: " + workBreak.EndTime); Console.WriteLine("\tNumber: " + workBreak.Number); Console.WriteLine("\tMinutes: " + workBreak.Minutes); Console.WriteLine("\tIsPaid: " + workBreak.IsPaid); Console.WriteLine("\t------------"); } } else { Console.WriteLine("\tNo Breaks"); } Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Shifts"); Console.WriteLine("---------------------------"); } Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.Result.ResultCode); Console.WriteLine("Message: " + response.Result.Message); } } } catch (Exception ex) { Console.WriteLine("Error calling GetShifts operation: " + ex.Message); } } } }
SaveLaborSchedule Sample Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; using System.ServiceModel.Web; using Labor2_SaveLaborSchedule.Labor2ServiceReference; namespace Labor2_SaveLaborSchedule { class Program { public static LaborSchedule CreateLaborSchedule() { //Create ScheduledShift objects ScheduledShift shift = new ScheduledShift() { EmployeeId = 123, StartTime = new TimeSpan(8, 0, 0), EndTime = new TimeSpan(16, 0, 0), JobId = 456, }; List<ScheduledShift> scheduledShifts = new List<ScheduledShift>(); scheduledShifts.Add(shift); //Include BusinessDate and array of ScheduledShift objects in LaborScheduleDay object LaborScheduleDay laborScheduleDay = new LaborScheduleDay() { BusinessDate = new DateTime(2001, 01, 01), Shifts = scheduledShifts.ToArray(), }; List<LaborScheduleDay> laborScheduleDays = new List<LaborScheduleDay>(); laborScheduleDays.Add(laborScheduleDay); //Include array of LaborScheduleDay objects in LaborSchedule object LaborSchedule laborSchedule = new LaborSchedule() { Days = laborScheduleDays.ToArray(), }; return laborSchedule; } static void Main(string[] args) { //Connect to Labor2 service client var client = new LaborWebService2Client(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include tokens in HTTP Web Request Headers var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["AccessToken"] = @"AccessToken"; headers["LocationToken"] = @"LocationToken"; //Include LaborSchedule parameter in request body var request = new SaveLaborScheduleRequest() { LaborSchedule = CreateLaborSchedule(), }; //Make SaveLaborSchedule call var response = client.SaveLaborSchedule(request); //If call is successful if (response.ResultCode == 0) { Console.WriteLine("Success!"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); if (response.EmployeeId != null) { Console.WriteLine("EmployeeId: " + response.EmployeeId); } if (response.JobId != null) { Console.WriteLine("JobId: " + response.JobId); } Console.ReadKey(); } } } } }
SaveLaborSchedule Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference6; using System.ServiceModel; using System.ServiceModel.Channels; namespace Labor2_SaveLaborSchedule { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLaborServiceClient() { services.AddTransient<ILaborWebService2>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILaborWebService2> factory = new ChannelFactory<ILaborWebService2>(binding, endpointAddress); return factory.CreateChannel(); }); } public static LaborSchedule CreateLaborSchedule() { //Create ScheduledShift objects ScheduledShift shift = new ScheduledShift() { EmployeeId = 4003634, StartTime = new TimeSpan(8, 0, 0), EndTime = new TimeSpan(16, 0, 0), JobId = 1, }; List<ScheduledShift> scheduledShifts = new List<ScheduledShift>(); scheduledShifts.Add(shift); //Include BusinessDate and array of ScheduledShift objects in LaborScheduleDay object LaborScheduleDay laborScheduleDay = new LaborScheduleDay() { BusinessDate = new DateTime(2024, 04, 08), Shifts = scheduledShifts.ToArray(), }; List<LaborScheduleDay> laborScheduleDays = new List<LaborScheduleDay>(); laborScheduleDays.Add(laborScheduleDay); //Include array of LaborScheduleDay objects in LaborSchedule object LaborSchedule laborSchedule = new LaborSchedule() { Days = laborScheduleDays.ToArray(), }; return laborSchedule; } static void Main(string[] args) { AddLaborServiceClient(); ILaborWebService2 client = services.BuildServiceProvider().GetRequiredService<ILaborWebService2>(); try { int count = 1; using (OperationContextScope scope = new OperationContextScope((IContextChannel)client)) { OperationContext context = OperationContext.Current; HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers["AccessToken"] = 'AccessToken'; httpRequestProperty.Headers["LocationToken"] = 'LocationToken'; context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; var request = new SaveLaborScheduleRequest() { LaborSchedule = CreateLaborSchedule(), }; //Make SaveLaborSchedule call var response = client.SaveLaborScheduleAsync(request); Console.WriteLine("SaveLaborSchedule"); Console.WriteLine("-------------------"); //If call is successful if (response.Result.ResultCode == 0) { Console.WriteLine("Success!"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.Result.ResultCode); Console.WriteLine("Message: " + response.Result.Message); if (response.Result.EmployeeId != null) { Console.WriteLine("EmployeeId: " + response.Result.EmployeeId); } if (response.Result.JobId != null) { Console.WriteLine("JobId: " + response.Result.JobId); } Console.ReadKey(); } } } catch (Exception ex) { Console.WriteLine("Error calling SaveLaborSchedule operation: " + ex.Message); } } } }