Time Management Web Service

Introduction

With UKG Pro Web Services, you can leverage your UKG Pro Time Management data for solving business application and integration needs. We provide two sets of web services for you to use with Time Management:

  • Export APIs- enables you to extract data from Time Management.
  • Import APIs – enables you to import data into Time Management. (At this time, only schedule data can be imported into Time Management.)

This document describes how to use the Time Management Web Services and is intended for individuals who are familiar with software development processes and Web Services technologies.

Export APIs

UTMOdataServices API

The UTMOdataServices API enables you to programmatically retrieve time-related data from Time Management.

This document describes the methods of the Web service and also provides code examples using Microsoft’s Visual Studio 2010 using C#. The information in the Service Specifications table describes the service requirements.

Service Specifications
ProtocolRepresentational State Transfer (REST)
URL ConventionODATA 4.0 (http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html)
SSL SupportRequired
Sign Up and Licensing
Account RequiredTime Management Web Service Account

AccessGroup Object

The Time Management AccessGroup object includes the following properties.

PropertyTypeDescription
IdIntegerAccess Group ID
DescriptionStringAccess Group Name

Employee Object

The Time Management Employee object includes the following properties.

PropertyTypeDescription
IdIntegerID Number
EmpIdStringEmployee Number
CardNumIntegerBadge Number
SupIdStringSupervisor User ID
SupNameStringSupervisor Name
FirstNameStringFirst Name
LastNameStringLast Name
ActiveStringStatus
EmailStringEmail Address
BirthDateStringBirth Date
HireDateStringHire Date
PayMethodIntegerPay Method Value
PayTypeIntegerPay Type Value
HoliRuleIntegerHoliday Rule Value
PayCateStringPay Category Value
PayGroupIdIntegerPay Group ID
LocationIdIntegerLocation ID
JobIdIntegerJob ID
ProjectIdIntegerProject ID
OrgLevel1IdIntegerOrg Level 1 ID
OrgLevel2IdIntegerOrg Level 2 ID
OrgLevel3IdIntegerOrg Level 3 ID
OrgLevel4IdIntegerOrg Level 4 ID
PayPolicyIdIntegerPay Policy ID
ShiftIdIntegerShift Rule ID
AccessGroupIdIntegerAccess Group ID

Job Object

The Time Management Job object includes the following properties.

PropertyTypeDescription
IdIntegerJob ID
NameStringJob Name
DescriptionStringJob Description

Location Object

The Time Management Location object includes the following properties.

PropertyTypeDescription
IdIntegerLocation ID
NameStringLocation Name
DescriptionStringLocation Description

OrgLevel1 Object

The Time Management OrgLevel1 object includes the following properties.

PropertyTypeDescription
IdIntegerOrgLevel1 ID
NameStringOrgLevel1 Name
DescriptionStringOrgLevel1 Description

OrgLevel2 Object

The Time Management OrgLevel2 object includes the following properties.

PropertyTypeDescription
IdIntegerOrgLevel2 ID
NameStringOrgLevel2 Name
DescriptionStringOrgLevel2 Description

OrgLevel3 Object

The Time Management OrgLevel3 object includes the following properties.

PropertyTypeDescription
IdIntegerOrgLevel3 ID
NameStringOrgLevel3 Name
DescriptionStringOrgLevel3 Description

OrgLevel4 Object

The Time

PropertyTypeDescription
IdIntegerOrgLevel4 ID
NameStringOrgLevel4 Name
DescriptionStringOrgLevel4 Description

Paycode Object

The Time Management Paycode object includes the following properties.

PropertyTypeDescription
IdIntegerPaycode ID
CodeStringPaycode Express Code
DescriptionStringPaycode Description

PayGroup Object

The Time Management PayGroup object includes the following properties.

PropertyTypeDescription
IdIntegerPaygroup ID
NameStringPaygroup Name
DescriptionStringPaygroup Description

PayMatrix Object

The Time Management PayMatrix object includes the following properties.

PropertyTypeDescription
IdIntegerID Number
EmployeeIDIntegerEmployee Number
WorkDateStringWork Date
PaycodeIdIntegerPaycode ID
PayIdentStringPay Matrix ID Type
HoursDecimalHours
PayAmountDecimalDollars
TimeIdIntegerID of Time Table

Project Object

The Time Management Project object includes the following properties.

PropertyTypeDescription
IdIntegerProject ID
NameStringProject Name
DescriptionStringProject Description

Reason Object

The Time Management Reason object includes the following properties.

PropertyTypeDescription
IdIntegerReason Code ID
CodeStringReason Code
Description
Reason Code Name

Shift Object

The Time Management Shift object includes the following properties.

PropertyTypeDescription
IdIntegerShift ID
ShiftNumDecimalShift Number
DescriptionStringShift Description
ShiftTypeDecimalShift Type
ShiftCycDecimalShift Cycle
DaysCycleDecimalCycle Days
CycleRefStringCycle Reference Date
DayStartStringFlexible Shift Day Start
DayEndStringFlexible Shift Day End
LunchMetDecimalMeal Deduction Method
AutoLunchBooleanAutomatic Meal Deduction
OpenLunchDecimalConsidered A Meal Start
Lunch1HrDecimalMeal 1 Work Over Hours
Lunch2HrDecimalMeal 2 Work Over Hours
Lunch3HrDecimalMeal 3 Work Over Hours
Lunch4HrDecimalMeal 4 Work Over Hours
Lunch1DedDecimalMeal 1 Deduct In Minutes
Lunch2DedDecimalMeal 2 Deduct In Minutes
Lunch3DedDecimalMeal 3 Deduct In Minutes
Lunch4DedDecimalMeal 4 Deduct In Minutes
BreakWinDecimalApply Paid Breaks
NIBonusBooleanNo Meal Punch Bonus
NIBonusMnDecimalNo Meal Punch Bonus Minutes
NIMustWorkDecimalNo Meal Punch Bonus Must Work Over
BrkMethodDecimalApply Paid Breaks
BrkPayMinDecimalConsidered A Break When Within Minutes
BrkLimitDecimalPaid Break Up To Minutes
MealPayMinDecimalAllow Pay Reimbursement Up To Minutes
EndLunchDecimalConsidered A Meal End
SchedMealBooleanAlways Use Scheduled Meals
DedWindowBooleanAbsolute Deduction Window
CreateMealOutBooleanCreate A Minimum Meal Deduction
CreateMealOutHoursDecimalCreate A Minimum Meal Deduction Hours
AbsDedWinBooleanAbsolute Deduction Window
DynWkOnlyBooleanBased On Working Hours
NoSplitBooleanNo Not Split Punch
HasReimAfterBooleanDaily Limit Up To
ReimAfterDecimalDaily Limit Up To Minutes
MealOutIntegerDo Not Split Based On

ShiftDet Object

The Time Management ShiftDet object includes the following properties.

PropertyTypeDescription
IdIntegerShift Detail ID
ShiftNumDecimalShift Number From Shift Table
DayListDecimalDay Number
DayDescStringDay Description
WorkDayBooleanWorkday
DayStartStringFixed Shift Day Start
DayEndStringFixed Shift Day End
StartStringFixed Shift Start Time
EndStringFixed Shift End Time
LunchDecimalShift Period Meal Amount

ShiftLvl Object

The Time Management ShiftLvl object includes the following properties.

PropertyTypeDescription
IdIntegerShift Level ID
ShiftNumDecimalShift Number From Shift Table
LevelStringDynamic Shift Level
StartStringDynamic Shift Start Time
EndStringDynamic Shift End Time
LunchDecimalDynamic Shift Meal Deducation
DLinkDowStringDynamic Shift Day Of Week

Time Object

The Time Management Time object includes the following properties.

PropertyTypeDescription
IdIntegerID Number
EmpIdStringEmployee Number
WorkDateStringWork Date
PaycodeIdIntegerPaycode ID
PaycodeExpStringPaycode Express Code
InOrgStringIn Original
OutOrgStringOut Original
InStringIn Time
OutStringOut Time
InRoundedStringIn Time Rounded
OutRoundedStringOut Time Rounded
InExpStringIn Express Code
OutExpStringOut Express Code
ShiftExpStringShift Rule
SchHrsDecimalScheduled Hours
RegHrDecimalRegular Hours
Overt1DecimalOT-1 Hours
Overt2DecimalOT-2 Hours
Overt3DecimalOT-3 Hours
Overt4DecimalOT-4 Hours
Overt5DecimalOT-5 Hours
RegPayDecimalRegular Dollars
Ot1PayDecimalOT-1 Dollars
Ot2PayDecimalOT-2 Dollars
Ot3PayDecimalOT-3 Dollars
Ot4PayDecimalOT-4 Dollars
Ot5PayDecimalOT-5 Dollars
WeekRegDecimalWeekly Regular Hours
WeekOt1DecimalWeekly OT-1 Hours
WeekOt2DecimalWeekly OT-2 Hours
WeekOt3DecimalWeekly OT-3 Hours
WeekOt4DecimalWeekly OT-4 Hours
WeekOt5DecimalWeekly OT-5 Hours
ReasonIdIntegerReason Code ID
PaygroupIdIntegerPay Group ID
LocationIdIntegerLocation ID
JobIdIntegerJob ID
ProjectIdIntegerProject ID
OrgLevel1IdIntegerOrg Level 1 ID
OrgLevel2IdIntegerOrg Level 2 ID
OrgLevel3IdIntegerOrg Level 3 ID
OrgLevel4IdIntegerOrg Level 4 ID
PeriodThDecimalPeriod Hours
SiteInStringSite In
SiteOutStringSite Out
QuanGoodDecimalQuantity Good
QuanScrapDecimalQuantity Scrap
BegSchedStringBegin Schedule
EndSchedStringEnd Schedule
StatusIntegerApproval ID
AdjustmentDateStringAdjustment Date

Schedule Object

The Time Management Schedule object includes the following properties.

PropertyTypeDescription
IdIntegerSchedule ID
EmployeeIDIntegerEmployee Number
WorkDateStringSchedule Date
PaycodeIdIntegerPaycode Number
SchDateStringDate Entered/Date Approved
SchByIntegerWho Approved
SchStartIntegerSchedule Start Time
SchEndIntegerSchedule End Time
HoursDoubleHours
MealDedIntegerMeal Deduction In Minutes
PaygroupIdIntegerPay Group
LocationIdIntegerLocation
JobIdIntegerJob
ProjectIdIntegerProject
OrgLevel1IdIntegerOrg Level 1
OrgLevel2IdIntegerOrg Level 2
OrgLevel3IdIntegerOrg Level 3
OrgLevel4IdIntegerOrg Level 4
StatusIntegerStatus of Request
NoteStringEmployee Note
CommentStringSupervisor Note
ScheduleRequestIdInteger

ScheduleRequest Object

The Time Management ScheduleRequest object includes the following properties.

PropertyTypeDescription
IdIntegerSchedule Request ID
DescriptionStringScheduler Request Description
StartStringFrom Date
EndStringTo Date
PaycodeIdIntegerPaycode
SubmittedStringDate Submitted
DaysIntegerNumber of Days Requested
NotesStringNote
EmployeeIdIntegerEmployee

Timesheet Object

The Time Management Timesheet object includes the following properties.

PropertyTypeDescription
IdIntegerTimesheet ID
EmployeeIdIntegerEmployee Number
StartsStringPeriod Start Date
EndsStringPeriod End Date
MissPunchIntegerMissed Punch Count
TardyIntegerTardy Count
SchHrDoubleScheduled Hours
RegHrDoubleRegular Hours
Ot1DoubleOT-1 Hours
Ot2DoubleOT-2 Hours
Ot3DoubleOT-3 Hours
Ot4DoubleOT-4 Hours
Ot5DoubleOT-5 Hours
PayAmtDoubleDollars
SubmitBooleanSubmitted
ApproveBooleanApproved
SysUpdateStringTimestamp Of Update
EarlyInIntegerEarly In Count
GraceInIntegerGrace In Count
EarlyOutIntegerEarly Out Count
LateOutIntegerLate Out Count
LongMealIntegerLong Meal Count
ShortMealIntegerShort Meal Count
LongBreakIntegerLong Break Count
Short BreakIntegerShort Break Count
AbsencesIntegerAbsent Count
DayApproveStringApprovedDays
StatusIntegerTimesheet Status
AutoMealIntegerAuto Meal Deduction Count
EarlyOutGIntegerEarly Out Grace Count
NoMealIntegerNo Meal Deduction Count
OvertimeDoubleOvertime Count
ShortWkDayIntegerShort Work Day Count
AppPunchDoubleUnapproved Punch Count
AuthOtDoubleUnauthorized Overtime Count
PaidBrkIntegerUnpaid Break Count
MlPremCntIntegerMeal Premium Count
MlPremWavIntegerMeal Premium Waived Count
BkPremCntIntegerBreak Premium Count
BkPremWavIntegerBreak Premium Waived Count

UTMOdataServices API Quick Start

This section provides steps for creating a sample application in your development environment to retrieve Time Management information.

Prerequisites

In order to use the UTMOdataServices API, the following pre-requisite items must be completed:

  • Obtain a Time Management Web Service Account username and password.
  • Enter a support request to obtain the URL and to have user accounts created and passwords generated for access
  • Add a reference to Newtonsoft.Json (Json.NET http://www.newtonsoft.com/json) in your C# project.

Example Code - C#

The following code is an example of retrieving employee information from your Time Management data in a console application.

You can copy the entire contents to a C# console application and update the following values and have an operating application.

UserName = "YOUR UTM WEB SERVICE ACCOUNT ",

Password = "YOUR PASSWORD",

The following are client classes that call the UtmOdataServices API given the provided credentials and URL.

OdataClientCredentials

public class OdataClientCredentials

{

	public string Username { get; set; }

	public string Password { get; set; }

	public Uri Url { get; set; }

}

OdataClient

	public class OdataClient
	{
		private readonly OdataClientCredentials _credentials;


		public OdataClient(OdataClientCredentials credentials)
	{
		if (credentials == null)
		{
			throw new ArgumentNullException("credentials");
		}


		_credentials = credentials;
	}


	public List<T> CallService<T>()
	{
		return CallService<T>(null);
	}


	public List<T> CallService<T>(string query)
	{
		var data = new List<T>();


		var fullyEscapedUri = _credentials.Url.AbsoluteUri.EndsWith("/")
			? _credentials.Url
			: new Uri(_credentials.Url + "/");
		var uri = new Uri(fullyEscapedUri, typeof(T).Name);


		if (!string.IsNullOrWhiteSpace(query))
		{
			var uriBuilder = new UriBuilder(uri) {Query = query};
			uri = uriBuilder.Uri;
		}


		var request = WebRequest.Create(uri);
		request.Method = "GET";


		string base64EncodedUsernameAndPassword = string.Format("{0}:{1}", _credentials.Username, _credentials.Password);
		string authHeader = string.Format("Basic {0}", Convert.ToBase64String(Encoding.UTF8.GetBytes(base64EncodedUsernameAndPassword)));
		request.Headers["Authorization"] = authHeader;


		using (var response = request.GetResponse())
		{
			using (var stream = response.GetResponseStream())
		{
			using (var reader = new StreamReader(stream))
			{
				string json = reader.ReadToEnd();
				var jsonObj = JsonConvert.DeserializeObject(json) as JObject;
				var jsonArray = jsonObj["value"] as JArray;


				foreach (var jsonEmp in jsonArray)
			{
				var obj = JsonConvert.DeserializeObject<T>(jsonEmp.ToString());
				data.Add(obj);
			}
		}
	}
}


return data;
}
}

A proxy class should be made for each object (aka table) available via the UTMOdataServices API. This will be used by the OdataClient to parse the Json response.

public class AccessGroup
{
public int Id { get; set; }
public string Description { get; set; }
}


public class Employee
{
public int Id { get; set; }
public string EmpId { get; set; }
public int? CardNum { get; set; }
public string SupId { get; set; }
public string SupName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Active { get; set; }
public string Email { get; set; }
public string BirthDate { get; set; }
public string HireDate { get; set; }
public int? PayMethod { get; set; }
public int? PayType { get; set; }
public int? HoliRule { get; set; }
public string PayCate { get; set; }
public int? PaygroupId { get; set; }
public int? LocationId { get; set; }
public int? JobId { get; set; }
public int? ProjectId { get; set; }
public int? OrgLevel1Id { get; set; }
public int? OrgLevel2Id { get; set; }
public int? OrgLevel3Id { get; set; }
public int? OrgLevel4Id { get; set; }
public int? PayPolicyId { get; set; }
public int? ShiftId { get; set; }
public int? AccessGroupId { get; set; }
}


public class Job
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}


public class Location
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}


public class OrgLevel1
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}


public class OrgLevel2
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}




public class OrgLevel3
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}


public class OrgLevel4
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}


public class Paycode
{
public int Id { get; set; }
public string Code { get; set; }
public string Description { get; set; }
}


public class Paygroup
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}


public class PayMatrix
{
public int Id { get; set; }
public int? EmployeeId { get; set; }
public DateTime? WorkDate { get; set; }
public int? PaycodeId { get; set; }
public string PayIdent { get; set; }
public decimal? Hours { get; set; }
public decimal? PayAmount { get; set; }
public int? TimeId { get; set; }
}


public class Project
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}


public class Reason
{
public int Id { get; set; }
public string Code { get; set; }
public string Description { get; set; }
}


public class Schedule
{
public int Id { get; set; }
public int? EmployeeId { get; set; }
public DateTime? WorkDate { get; set; }
public int? PaycodeId { get; set; }
public DateTime? SchDate { get; set; }
public int? SchBy { get; set; }
public int? SchStart { get; set; }
public int? SchEnd { get; set; }
public double? Hours { get; set; }
public int? MealDed { get; set; }
public int? PaygroupId { get; set; }
public int? LocationId { get; set; }
public int? JobId { get; set; }
public int? ProjectId { get; set; }
public int? OrgLevel1Id { get; set; }
public int? OrgLevel2Id { get; set; }
public int? OrgLevel3Id { get; set; }
public int? OrgLevel4Id { get; set; }
public int? Status { get; set; }
public string Note { get; set; }
public string Comment { get; set; }
public int? ScheduleRequestId { get; set; }
}

public class ScheduleRequest
{
public int Id { get; set; }
public string Description { get; set; }
public DateTime? Start { get; set; }
public DateTime? End { get; set; }
public int? PaycodeId { get; set; }
public DateTime? Submitted { get; set; }
public int? Days { get; set; }
public string Notes { get; set; }
public int? EmployeeId { get; set; }
}

public class Shift
{
public int Id { get; set; }
public decimal? ShiftNum { get; set; }
public string Description { get; set; }
public decimal? ShiftType { get; set; }
public decimal? ShiftCyc { get; set; }
public decimal? DaysCycle { get; set; }
public string CycleRef { get; set; }
public string DayStart { get; set; }
public string DayEnd { get; set; }
public decimal? LunchMet { get; set; }
public bool? AutoLunch { get; set; }
public decimal? OpenLunch { get; set; }
public decimal? Lunch1Hr { get; set; }
public decimal? Lunch2Hr { get; set; }
public decimal? Lunch3Hr { get; set; }
public decimal? Lunch4Hr { get; set; }
public decimal? Lunch1Ded { get; set; }
public decimal? Lunch2Ded { get; set; }
public decimal? Lunch3Ded { get; set; }
public decimal? Lunch4Ded { get; set; }
public decimal? BreakWin { get; set; }
public bool? NlBonus { get; set; }
public decimal? NlBonusMn { get; set; }
public decimal? NlMustWork { get; set; }
public decimal? Brkmethod { get; set; }
public decimal? BrkPayMin { get; set; }
public decimal? BrkLimit { get; set; }
public decimal? MealPyMin { get; set; }
public decimal? EndLunch { get; set; }
public bool? SchedMeal { get; set; }
public bool? DedWindow { get; set; }
public bool? CreateMealOut { get; set; }
public decimal? CreateMealOutHours { get; set; }
public bool? AbsDedWin { get; set; }
public bool? DynWkOnly { get; set; }
public bool? NoSplit { get; set; }
public bool? HasReimAfter { get; set; }
public decimal? ReimAfter { get; set; }
public int? MealOut { get; set; }
}


public class ShiftDet
{
public int Id { get; set; }
public decimal? ShiftNum { get; set; }
public decimal? DayList { get; set; }
public string DayDesc { get; set; }
public bool? WorkDay { get; set; }
public string DayStart { get; set; }
public string DayEnd { get; set; }
public string Start { get; set; }
public string End { get; set; }
public decimal? Lunch { get; set; }
}

public class ShiftLvl
{
public int Id { get; set; }
public decimal? ShiftNum { get; set; }
public string Level { get; set; }
public string Start { get; set; }
public string End { get; set; }
public decimal? Lunch { get; set; }
public string DLinkDow { get; set; }
}

public class Time
{
public int Id { get; set; }
public string EmpId { get; set; }
public DateTime? WorkDate { get; set; }
public int? PaycodeId { get; set; }
public string PaycodeExp { get; set; }
public DateTime? InOrg { get; set; }
public DateTime? OutOrg { get; set; }
public DateTime? In { get; set; }
public DateTime? Out { get; set; }
public DateTime? InRounded { get; set; }
public DateTime? OutRounded { get; set; }
public string InExp { get; set; }
public string OutExp { get; set; }
public string ShiftExp { get; set; }
public decimal? SchHrs { get; set; }
public decimal? RegHr { get; set; }
public decimal? Overt1 { get; set; }
public decimal? Overt2 { get; set; }
public decimal? Overt3 { get; set; }
public decimal? Overt4 { get; set; }
public decimal? Overt5 { get; set; }
public decimal? RegPay { get; set; }
public decimal? Ot1Pay { get; set; }
public decimal? Ot2Pay { get; set; }
public decimal? Ot3Pay { get; set; }
public decimal? Ot4Pay { get; set; }
public decimal? Ot5Pay { get; set; }
public decimal? WeekReg { get; set; }
public decimal? WeekOt1 { get; set; }
public decimal? WeekOt2 { get; set; }
public decimal? WeekOt3 { get; set; }
public decimal? WeekOt4 { get; set; }
public decimal? WeekOt5 { get; set; }
public int? ReasonId { get; set; }
public int? PaygroupId { get; set; }
public int? LocationId { get; set; }
public int? JobId { get; set; }
public int? ProjectId { get; set; }
public int? OrgLevel1Id { get; set; }
public int? OrgLevel2Id { get; set; }
public int? OrgLevel3Id { get; set; }
public int? OrgLevel4Id { get; set; }
public decimal? PeriodTh { get; set; }
public string SiteIn { get; set; }
public string SiteOut { get; set; }
public decimal? QuanGood { get; set; }
public decimal? QuanScrap { get; set; }
public string BegSched { get; set; }
public string EndSched { get; set; }
public int? Status { get; set; }
public string AdjustmentDate { get; set; }
}


public class Timesheet
{
public int Id { get; set; }
public int? EmployeeId { get; set; }
public DateTime? Starts { get; set; }
public DateTime? Ends { get; set; }
public int? MissPunch { get; set; }
public int? Tardy { get; set; }
public double? SchHr { get; set; }
public double? RegHr { get; set; }
public double? Ot1 { get; set; }
public double? Ot2 { get; set; }
public double? Ot3 { get; set; }
public double? Ot4 { get; set; }
public double? Ot5 { get; set; }
public double? PayAmt { get; set; }
public bool? Submit { get; set; }
public bool? Approve { get; set; }
public DateTime? SysUpdate { get; set; }
public int? EarlyIn { get; set; }
public int? GraceIn { get; set; }
public int? EarlyOut { get; set; }
public int? LateOut { get; set; }
public int? LongMeal { get; set; }
public int? ShortMeal { get; set; }
public int? LongBreak { get; set; }
public int? ShortBreak { get; set; }
public int? Absences { get; set; }
public string DayApprove { get; set; }
public int? Status { get; set; }
public int? AutoMeal { get; set; }
public int? EarlyOutG { get; set; }
public int? NoMeal { get; set; }
public double? Overtime { get; set; }
public int? ShortWkDay { get; set; }
public double? AppPunch { get; set; }
public double? AuthOt { get; set; }
public int? PaidBrk { get; set; }
public int? MlPremCnt { get; set; }
public int? MlPremWav { get; set; }
public int? BkPremCnt { get; set; }
public int? BkPremWav { get; set; }
}
}
}

After creating these classes, the client can be used as follows:

var credentials = new OdataClientCredentials
{
Username = "yourusername",
Password = "yourpassword",
Url = new Uri("http://youruri/api"),
};


var client = new OdataClient(credentials);
var accessGroup = client.CallService<AccessGroup>();
var employees = client.CallService<Employee>();
var jobs = client.CallService<Job>();
var locations = client.CallService<Location>();
var org1Levels = client.CallService<OrgLevel1>();
var org2Levels = client.CallService<OrgLevel2>();
var org3Levels = client.CallService<OrgLevel3>();
var org4Levels = client.CallService<OrgLevel4>();
var paycodes = client.CallService<Paycode>();
var paymatrices = client.CallService<PayMatrix>();
var projects = client.CallService<Project>();
var reasons = client.CallService<Reason>();
var schedules = client.CallService<Schedule>();
var scheduleRequests = client.CallService<ScheduleRequest>();
var shifts = client.CallService<Shift>();
var shiftDetails = client.CallService<ShiftDet>();
var shiftLevels = client.CallService<ShiftLvl>();
var time = client.CallService<Time>();
var timesheets = client.CallService<Timesheet>();


// Call service with ODATA compliant filter
// Gets time records with WorkDates between 3/4/2012 and 3/20/2012
// See http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html for more info
var filteredTimes = client.CallService<Time>("$filter=WorkDate ge 2012-03-04 and WorkDate le 2012-03-20");
}

Import APIs

Labor Metrics API

The Labor Metrics API enables you to import only changes rather than a full import.

This section describes the methods of the Web service and also provides code examples using Microsoft’s Visual Studio 2010 using C#. The information in the Service Specifications table describes the service requirements.

Service Specifications
ProtocolRepresentational State Transfer (REST)
SSL SupportRequired

ImportEmpGroupAccessData Object

The ImportEmpGroupAccessData object includes the following properties.

PropertyTypeDescription
EmployeeIDStringEmployee Number in Time Management
GroupInfoListList of Group Infos

GroupInfo Object

The GroupInfo object includes the following properties.

PropertyTypeDescription
GroupNumberStringGroup Number
GroupValueStringGroup Code
DescriptionStringGroup Description

Labor Metrics API Quick Start

This section provides steps for creating a sample application in your development environment to import labor metrics access group data into Time Management.

Prerequisites

In order to use the Schedule API, the following pre-requisites must be completed:

  • Enter a support request to obtain the URL and auth GUID.
  • Add a reference to Newtonsoft.Json (Json.NET http://www.newtonsoft.com/json) in your C# project.

Request JSON

Request:

{
            "EmployeeGroupAssignmentData": [
                        {
                                    "EmployeeId": STRING,
                                    "GroupInfo": [
                                                {
                                                            "GroupNumber": STRING,
                                                            "GroupValue": STRING
                                                },
                                                {
                                                            "GroupNumber": STRING,
                                                            "GroupValue": STRING
                                                }
                                    ]
                        }
            ]
}

Example:

{
            "EmployeeGroupAssignmentData": [
                        {
                                    "EmployeeId": "000000001-5B8U4",
                                    "GroupInfo": [
                                                {
                                                            "GroupNumber": "2",
                                                            "GroupValue": "CA"
                                                },
                                                {
                                                            "GroupNumber": "4",
                                                            "GroupValue": "PROJ"
                                                }
                                    ]
                        },
                        {
                                    "EmployeeId": "000000001-PTO15",
                                    "GroupInfo": [
                                                {
                                                            "GroupNumber": "2",
                                                            "GroupValue": "CA"
                                                },
                                                {
                                                            "GroupNumber": "4",
                                                            "GroupValue": "PROJ"
                                                }
                                    ]
                        }
            ]
}

Responses and Error Codes

When a request is successful, the StatusCode returned is “0” and the StatusDescription returned is “Success.” If the request is not successful, an error code is received.

Error CodeDescription
1Unhandled exception
5Either EmployeeId or ExternalEmployeeId is required
6Request too large

Here is an example response for a successful import.

{
	"StatusCode":0,
	"StatusDescription":"Success.",
	"Results":{ 
	"ResultCount":0,
	"PageNumber":0,
	"TotalPages":0,
	"Data":null
	}
}

Example Code – C#

The following is an example of code that can be used to import labor metrics group access import from a console application into Time Management.

You can copy the entire contents to a C# console application and update the following values and have an operating application.

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json;


namespace LaborMetricGroupAccessExample
{
class Program
{
private const string Url = "https://[ENVIRONMENTURL]/UtmRestServices/[CLIENTID]/EmployeeGroupAssignment/Update?AuthGUID=[AUTHGUID]";
static void Main(string[] args)
{
var request = new LaborMetricGroupAccessRequest
{
EmployeeGroupAssignmentData = new List<EmployeeGroupAssignmentData>()
};
var groupInfo = new List<GroupInfo>()
groupInfo.add(new GroupInfo
{ 
GroupNumber = "[Group Number]",
GroupValue = "[Group Value]",
Description = "[Description]"
});
request.EmployeeGroupAssignmentData.Add(
new EmployeeGroupAssignmentData
{
EmployeeId = "[Employee Id]",
GroupInfo = groupInfo
});


var json = JsonConvert.SerializeObject(request);


Post(Url, json);
}


public static void Post(string url, string json)
{
var encoding = new UTF8Encoding();
var byteArray = encoding.GetBytes(json);
var request = (HttpWebRequest) WebRequest.Create(url);
request.Method = "POST";
request.ContentLength = byteArray.Length;
request.ContentType = @"application/json";


using (var dataStream = request.GetRequestStream())
{
dataStream.Write(byteArray, 0, byteArray.Length);
}


using (var response = (HttpWebResponse) request.GetResponse())
{
var stream = response.GetResponseStream();


if (stream != null)
{
using (var readStream = new StreamReader(stream, Encoding.UTF8))
{
var info = readStream.ReadToEnd();
var responseObj = JsonConvert.DeserializeObject<EmployeeGroupAssignmentDataResponse>(info);
Console.WriteLine(responseObj);
}
}
}
}
}


public class LaborMetricGroupAccessRequest
{
public List<EmployeeGroupAssignmentData> EmployeeGroupAssignmentData { get; set; }
}


public class EmployeeGroupAssignmentData
{
public string EmployeeId { get; set; }
public List<GroupInfo>
}


public class GroupInfo
{
public string GroupNumber { get; set; }
public string GroupValue { get; set; }
public string Description { get; set; }
}




public class EmployeeGroupAssignmentDataResponse
{
public int StatusCode { get; set; }
public string StatusDescription { get; set; }
public EmployeeGroupAssignmentDataResults Results { get; set; }
}


public class EmployeeGroupAssignmentDataResults
{
public int ResultCount { get; set; }
public int PageNumber { get; set; }
public int TotalPages { get; set; }
public object Data { get; set; }
}
}

Schedule API

The Schedule API enables you to programmatically import schedule data from a third-party system into Time Management.

This section describes the methods of the Web service and also provides code examples using Microsoft’s Visual Studio 2010 using C#. The information in the Service Specifications table describes the service requirements.

Service Specifications
ProtocolRepresentational State Transfer (REST)
SSL SupportRequired

Schedule Object

The Schedule object includes the following properties.

PropertyTypeDescription
DateStringSchedule Date
EmployeeIDStringEmployee Number in Time Management
ExternalEmployeeIdStringEmployee ID from the third-party system
StartsString

Start time for the record; must be paired with end time

HH:MM am/pm

24HH:MM (for example, 09:30 am and 5:30 pm)

EndsString

End time for the record; must be paired with start time

HH:MM am/pm

24HH:MM (for example, 09:30 AM and 5:30 PM)

Org1StringOrg Level 1
Org2StringOrg Level 2
Org3StringOrg Level 3
Org4StringOrg Level 4
Org5StringOrg Level 5
Org6StringOrg Level 6
Org7StringOrg Level 7
Org8StringOrg Level 8
MealFromString

Start time for the meal

HH:MM am/pm

24HH:MM

MealToString

End time for the meal
HH:MM am/pm

24HH:MM

MealMinutesStringTotal time scheduled for employee break (for example, 30 minutes)
PaycodeIdString

Pay code ID associated with the record

Note: The Import process applies the employee default value if the Pay Code field is blank.

PaycodeCodeStringFour character value assigned to the pay code

Schedule API Quick Start

This section provides steps for creating a sample application in your development environment to import schedule data into Time Management.

Prerequisites

In order to use the Schedule API, the following pre-requisites must be completed:

  • Enter a support request to obtain the URL and auth GUID.
  • Add a reference to Newtonsoft.Json (Json.NET http://www.newtonsoft.com/json) in your C# project.

Request JSON

Request

{
"Schedules":[
		{
			"Date":STRING,
			"EmployeeId":STRING,
			"ExternalEmployeeId":STRING, 
			"Starts":STRING,
			"Ends":STRING,
			"Org1":STRING,
			"Org2":STRING,
			"Org3":STRING,
			"Org4":STRING,
			"Org5":STRING,
			"Org6":STRING,
			"Org7":STRING,
			"Org8":STRING,
			"MealFrom":STRING,
			"MealTo":STRING,
			"MealMinutes":STRING,
			"PaycodeId":STRING,
			"PaycodeCode":STRING,
		}
	]
}

Example:

{
"Schedules":[
		{
			"Date":"2/6/2017",
			"EmployeeId":"000000001-5B8U4",
			"ExternalEmployeeId":"12345",
			"Starts":"9:00 AM",
			"Ends":"5:30 PM",
			"Org1":"QATESTER",
			"Org2":"QATESTER",
			"Org3":"QATESTER",
			"Org4":"QATESTER",
			"Org5":"QATESTER",
			"Org6":"QATESTER",
			"Org7":"QATESTER",
			"Org8":"QATESTER",
			"MealFrom":"8:00",
			"MealTo":"9:00",
			"MealMinutes":"30",
			"PaycodeId":"1",
			"PaycodeCode":"WRKH"
		}
	]
}

Responses and Error Codes

When a request is successful, the StatusCode returned is “0” and the StatusDescription returned is “Success.” If the request is not successful, an error code is received.

Error CodeDescription
1Unhandled exception
5Either EmployeeId or ExternalEmployeeId is required
5Date is required
6Request too large

Here is an example response for a successful import.

{
	"StatusCode":0,
	"StatusDescription":"Success.",
	"Results":{ 
	"ResultCount":0,
	"PageNumber":0,
	"TotalPages":0,
	"Data":null
	}
}

Example Code – C#

The following is an example of code that can be used to import schedules from a console application into Time Management.

You can copy the entire contents to a C# console application and update the following values and have an operating application.

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json;


namespace ScheduleImportExample
{
class Program
{
private const string Url = "https://[ENVIRONMENTURL]/UtmRestServices/[CLIENTID]/ScheduleImport?AuthGUID=[AUTHGUID]";


static void Main(string[] args)
{
var request = new ScheduleImportRequest
{
Schedules = new List<Schedule>()
};


request.Schedules.Add(
new Schedule
{
Date = "[DATE]",
EmployeeId = "[EMP ID]",
ExternalEmployeeId = "[EXTERNAL EMPLOYEE ID]",
Starts = "[START DATE]",
Ends = "[END DATE]",
Org1 = "[ORG1]",
Org2 = "[ORG2]",
Org3 = "[ORG3]",
Org4 = "[ORG4]",
Org5 = "[ORG5]",
Org6 = "[ORG6]",
Org7 = "[ORG7]",
Org8 = "[ORG8]",
MealFrom = "[MEAL FROM TIME]",
MealMinutes = "[MEAL MINUTES]",
MealTo = "[MEAL TO TIME]",
PaycodeCode = "[PAYCODE]",
PaycodeId = "[PAYCODE ID]"
});


var json = JsonConvert.SerializeObject(request);
Post(Url, json);
}


public static void Post(string url, string json)
{
var encoding = new UTF8Encoding();
var byteArray = encoding.GetBytes(json);
var request = (HttpWebRequest) WebRequest.Create(url);
request.Method = "POST";
request.ContentLength = byteArray.Length;
request.ContentType = @"application/json";


using (var dataStream = request.GetRequestStream())
{
dataStream.Write(byteArray, 0, byteArray.Length);
}


using (var response = (HttpWebResponse) request.GetResponse())
{
var stream = response.GetResponseStream();


if (stream != null)
{
using (var readStream = new StreamReader(stream, Encoding.UTF8))
{
var info = readStream.ReadToEnd();
var responseObj = JsonConvert.DeserializeObject<ScheduleImportResponse>(info);
Console.WriteLine(responseObj);
}
}
}
}
}


public class ScheduleImportRequest
{
public List<Schedule> Schedules { get; set; }
}


public class Schedule
{
public string Date { get; set; }
public string EmployeeId { get; set; }
public string ExternalEmployeeId { get; set; }
public string Starts { get; set; }
public string Ends { get; set; }
public string Org1 { get; set; }
public string Org2 { get; set; }
public string Org3 { get; set; }
public string Org4 { get; set; }
public string Org5 { get; set; }
public string Org6 { get; set; }
public string Org7 { get; set; }
public string Org8 { get; set; }
public string MealFrom { get; set; }
public string MealTo { get; set; }
public string MealMinutes { get; set; }
public string PaycodeId { get; set; }
public string PaycodeCode { get; set; }
}


public class ScheduleImportResponse
{
public int StatusCode { get; set; }
public string StatusDescription { get; set; }
public ScheduleImportResults Results { get; set; }
}


public class ScheduleImportResults
{
public int ResultCount { get; set; }
public int PageNumber { get; set; }
public int TotalPages { get; set; }
public object Data { get; set; }
}
}

Time Import API Quick Start

This section provides steps for creating a sample application in your development environment to import time data into Time Management.

Prerequisites

In order to use the Time Import API, the following prerequisites must be completed:

  • Enter a support request to obtain the URL and auth GUID.
  • Add a reference to Newtonsoft.Json (Json.NET http://www.newtonsoft.com/json) in your C# project.

Request JSON

{
    "TimeImportData": [
        {
            "EmpId":STRING,
            "CardNum":INTEGER,
            "WorkDate":STRING,
            "In": STRING,
            "Out": STRING,
            “PaycodeId”:INTEGER,
            “RegHr”:DECIMAL,
			“Overt1”:DECIMAL,
			“Overt2”:DECIMAL,
			“Overt3”:DECIMAL,
			“Overt4”:DECIMAL,
			“Overt5”:DECIMAL,
            “PaygroupId”:INTEGER,
            “LocationId”:INTEGER,
            “JobId”:INTEGER,
            “ProjectId”:INTEGER,
            “OrgLevel1Id”:INTEGER,
            “OrgLevel2Id”:INTEGER,
            “OrgLevel3Id”:INTEGER,
            “OrgLevel4Id”:INTEGER,
			“QuanGood”:DECIMAL,
			“QuanScrap”:DECIMAL,
			“RegPay”:DECIMAL,
            “ReasonId”:STRING,
            "Note": STRING
        }
    ]
}

Example:

{
    "TimeImportData": [
        {
            "EmpId": "876878799-GCDRX",
            "WorkDate": "12/18/2019",
            "In": "5:37",
            "Out": "10:11",
            "PaycodeId": 0,
            "RegHr": 8,
            "Overt1": 1.75,
            "Overt2": "",
            "Overt3": "",
            "Overt4": "",
            "Overt5": "",
            "PaygroupId": "UTM02",
            "LocationId": "FL",
            "JobId": "BARBACK",
            "ProjectId": "PROJ",
            "OrgLevel1Id": "ORGLV1",
            "OrgLevel2Id": "ORGLV2",
            "OrgLevel3Id": "ORGLV3",
            "OrgLevel4Id": "ORGLV4",
            "QuanGood": 800.25,
            "QuanScrap": "",
            "RegPay": "",
            "ReasonId": "",
            "Note": "This is an example note"
        },
        {
            "CardNum": 8798,
            "WorkDate": "12/18/2019",
            "In": "10:37",
            "Out": "14:57",
            "PaycodeId": 0,
            "RegHr": 8,
            "Overt1": 1.75,
            "Overt2": "",
            "Overt3": "",
            "Overt4": "",
            "Overt5": "",
            "PaygroupId": "UTM02",
            "LocationId": "FL",
            "JobId": "BARBACK",
            "ProjectId": "PROJ",
            "OrgLevel1Id": "ORGLV1",
            "OrgLevel2Id": "ORGLV2",
            "OrgLevel3Id": "ORGLV3",
            "OrgLevel4Id": "ORGLV4",
            "QuanGood": 800.25,
            "QuanScrap": "",
            "RegPay": "",
            "ReasonId": “”
        }
    ]
}

Responses and Error Codes

When a request is successful, the StatusCode returned is “0” and the StatusDescription returned is “Success.” If the request is not successful, an error code is received.

Error CodeDescription
0Success
1Unhandled exception

The response object will have a Results object that contains a ResultCount which will always be 0, a PageNumber which will always be 0, and a TotalPages which will always be 0.

The Data property will be an array of 1 that contains an object with the following:

  • RecordsImported - Contains the number of successfully imported time records.
  • RecordsFailed - Contains the number of failed time records.
  • Failures, if there are any failed records (RecordsFailed > 0) - Contains an array of objects with the failed data and a Reason property.

Here is an example response for a successful import.

{
    "StatusCode": 0,
    "StatusDescription": "Success.",
    "Results": {
        "ResultCount": 0,
        "PageNumber": 0,
        "TotalPages": 0,
        "Data": [
            {
                "RecordsImported": 3,
                "RecordsFailed": 0,
                "Failures": []
            }
        ]
    }
}

Here is an example response for a failed import.

{
    "StatusCode": 0,
    "StatusDescription": "Success.",
    "Results": {
        "ResultCount": 0,
        "PageNumber": 0,
        "TotalPages": 0,
        "Data": [
            {
                "RecordsImported": 0,
                "RecordsFailed": 2,
                "Failures": [
                    {
                        "Reason": "Data already exists.",
                        "Data": {
                            "Id": null,
                            "EmpSeq": null,
                            "EmpId": "563626270-GCDQM",
                            "CardNum": null,
                            "WorkDate": "12/11/2019",
                            "In": "07:00",
                            "Out": "11:00",
                            "PaycodeId": 0,
                            "RegHr": null,
                            "Overt1": null,
                            "Overt2": null,
                            "Overt3": null,
                            "Overt4": null,
                            "Overt5": null,
                            "PaygroupId": null,
                            "LocationId": null,
                            "JobId": null,
                            "ProjectId": null,
                            "OrgLevel1Id": null,
                            "OrgLevel2Id": null,
                            "OrgLevel3Id": null,
                            "OrgLevel4Id": null,
                            "QuanGood": null,
                            "QuanScrap": null,
                            "RegPay": null,
                            "ReasonId": null,
                            "Note": "from postman"
                        }
                    },
                    {
                        "Reason": "Data already exists.",
                        "Data": {
                            "Id": null,
                            "EmpSeq": null,
                            "EmpId": "563626270-GCDQM",
                            "CardNum": null,
                            "WorkDate": "12/11/2019",
                            "In": "09:00",
                            "Out": "18:00",
                            "PaycodeId": 0,
                            "RegHr": null,
                            "Overt1": null,
                            "Overt2": null,
                            "Overt3": null,
                            "Overt4": null,
                            "Overt5": null,
                            "PaygroupId": null,
                            "LocationId": null,
                            "JobId": null,
                            "ProjectId": null,
                            "OrgLevel1Id": null,
                            "OrgLevel2Id": null,
                            "OrgLevel3Id": null,
                            "OrgLevel4Id": null,
                            "QuanGood": null,
                            "QuanScrap": null,
                            "RegPay": null,
                            "ReasonId": null,
                            "Note": "from postman"
                        }
                    }
                ]
            }
        ]
    }
}

Example Code – C#

The following is an example of code that can be used to import time from a console application into Time Management.

You can copy the entire contents to a C# console application, update the following values, and have an operating application.

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json;


namespace TimeImportExample
{
    class Program
    {
        private const string Url = "https://[ENVIRONMENTURL]/UtmRestServices/[CLIENTID]/TimeImport?AuthGUID=[AUTHGUID]";


        static void Main(string[] args)
        {
            var request = new TimeImportRequest
            {
                TimeImportData = new List<TimeImportData>()
            };


            request.TimeImportData.Add(
            new TimeImportData
            {
                EmpId = "[EMP ID]",
                CardNum = 0, // [CARD NUMBER]
                WorkDate = "[WORK DATE]",
                In = "[IN TIME]",
                Out = "[OUT TIME]",
                PaycodeId = 0, //"[PAYCODE ID]"
                RegHr = 0, //"[REGULAR HOURS]"
                Overt1 = 0, //"[OVERTIME 1 HOURS]"
                Overt2 = 0, //"[OVERTIME 2 HOURS]"
                Overt3 = 0, //"[OVERTIME 3 HOURS]"
                Overt4 = 0, //"[OVERTIME 4 HOURS]"
                Overt5 = 0, //"[OVERTIME 5 HOURS]"
                PaygroupId = "[PAYGROUP ID]",
                LocationId = "[LOCATION ID]",
                JobId = "[JOB ID]",
                ProjectId = "[PROJECT ID]",
                OrgLevel1Id = "[ORG LEVEL 1 ID]",
                OrgLevel2Id = "[ORG LEVEL 2 ID]",
                OrgLevel3Id = "[ORG LEVEL 3 ID]",
                OrgLevel4Id = "[ORG LEVEL 4 ID]",
                QuanGood = 0, //"[QUANTITY GOOD]"
                QuanScrap = 0, //"[QUANTITY SCRAP]"
                RegPay = 0, //"[REGULAR PAY]"
                ReasonId = "[REASON ID]",
                Note = "[NOTES]"
            });


            var json = JsonConvert.SerializeObject(request);


            Post(Url, json);
        }


        public static void Post(string url, string json)
        {
            var encoding = new UTF8Encoding();
            var byteArray = encoding.GetBytes(json);
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentLength = byteArray.Length;
            request.ContentType = @"application/json";


            using (var dataStream = request.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
            }


            using (var response = (HttpWebResponse)request.GetResponse())
            {
                var stream = response.GetResponseStream();


                if (stream != null)
                {
                    using (var readStream = new StreamReader(stream, Encoding.UTF8))
                    {
                        var info = readStream.ReadToEnd();
                        var responseObj = JsonConvert.DeserializeObject<TimeImportResponse>(info);
                        Console.WriteLine(responseObj);
                    }
                }
            }
        }
    }




    public class TimeImportRequest
    {
        public List<TimeImportData> TimeImportData { get; set; }
    }


    public class TimeImportData
    {
        public string EmpId { get; set; }
        public int? CardNum { get; set; }
        public string WorkDate { get; set; }
        public string In { get; set; }
        public string Out { get; set; }
        public int? PaycodeId { get; set; }
        public decimal? RegHr { get; set; }
        public decimal? Overt1 { get; set; }
        public decimal? Overt2 { get; set; }
        public decimal? Overt3 { get; set; }
        public decimal? Overt4 { get; set; }
        public decimal? Overt5 { get; set; }
        public string PaygroupId { get; set; }
        public string LocationId { get; set; }
        public string JobId { get; set; }
        public string ProjectId { get; set; }
        public string OrgLevel1Id { get; set; }
        public string OrgLevel2Id { get; set; }
        public string OrgLevel3Id { get; set; }
        public string OrgLevel4Id { get; set; }
        public decimal? QuanGood { get; set; }
        public decimal? QuanScrap { get; set; }
        public decimal? RegPay { get; set; }
        public string ReasonId { get; set; }
        public string Note { get; set; }
    }


    public class TimeImportResponse
    {
        public int StatusCode { get; set; }
        public string StatusDescription { get; set; }
        public TimeImportResults Results { get; set; }
    }


    public class TimeImportResults
    {
        public int ResultCount { get; set; }
        public int PageNumber { get; set; }
        public int TotalPages { get; set; }
        public List<TimeImportResultsData> Data { get; set; }
    }


    public class TimeImportResultsData
    {
        public int RecordsImported { get; set; }
        public int RecordsFailed { get; set; }
        public List<TimeImportFailure> Failures { get; set; }
    }


    public class TimeImportFailure
    {
        public string Reason { get; set; }
        public TimeImportData Data { get; set; }
    }
}

Swipe and Go Import API Quick Start

This section provides steps for creating a sample application in your development environment to import punch data into Time Management.

Prerequisites

In order to use the Time Import API, the following prerequisites must be completed:

  • Enter a support request to obtain the URL and auth GUID.
  • Add a reference to Newtonsoft.Json (Json.NET http://www.newtonsoft.com/json) in your C# project.

Request JSON

{
    "SwipeAndGoImportData": [
        {
            "EmpId":STRING,
            "CardNum":INTEGER,
            "WorkDate":STRING,
            "Punch": STRING,                                                        
            “PaygroupId”:INTEGER,
            “LocationId”:INTEGER,
            “JobId”:INTEGER,
            “ProjectId”:INTEGER,
            “OrgLevel1Id”:INTEGER,
            “OrgLevel2Id”:INTEGER,
            “OrgLevel3Id”:INTEGER,
            “OrgLevel4Id”:INTEGER,
            “ReasonId:”:STRING,
            “Note”:STRING
        }
    ]
}

Example:

{
   "SwipeAndGoImportData": [
        {
            "EmpId": "876878799-GCDRX",
            "WorkDate": "12/10/2019",
            "PaycodeId" : 0,
            "Punch": "14:30"
        },
         {
            "EmpId": "876878799-GCDRX",
            "WorkDate": "12/10/2019",
            "PaycodeId" : 0,
            "Punch": "15:30"
        }
        ,
         {
            "EmpId": "876878799-GCDRX",
            "WorkDate": "12/10/2019",
            "PaycodeId" : 0,
            "Punch": "17:30"
        }
    ]
}

Responses and Error Codes

When a request is successful, the StatusCode returned is “0” and the StatusDescription returned is “Success.” If the request is not successful, an error code is received.

Error CodeDescription
0Success
1Unhandled exception

The response object will have a Results object that contains a ResultCount which will always be 0, a PageNumber which will always be 0, and a TotalPages which will always be 0.

The Data property will be an array of 1 that contains an object with the following:

  • RecordsImported - Contains the number of successfully imported time records.
  • RecordsFailed - Contains the number of failed time records.
  • Failures, if there are any failed records (RecordsFailed > 0) - Contains an array of objects with the failed data and a Reason property.

Here is an example response for a successful import.

{
    "StatusCode": 0,
    "StatusDescription": "Success.",
    "Results": {
        "ResultCount": 0,
        "PageNumber": 0,
        "TotalPages": 0,
        "Data": [
            {
                "RecordsImported": 3,
                "RecordsFailed": 0,
                "Failures": []
            }
        ]
    }
}

Here is an example response for a failed import.

{
    "StatusCode": 0,
    "StatusDescription": "Success.",
    "Results": {
        "ResultCount": 0,
        "PageNumber": 0,
        "TotalPages": 0,
        "Data": [
            {
                "RecordsImported": 0,
                "RecordsFailed": 1,
                "Failures": [
                    {
                        "Reason": "PaygroupId does not exist.",
                        "Data": {
                            "Id": null,
                            "EmpSeq": null,
                            "EmpId": "876878799-GCDRX",
                            "CardNum": null,
                            "WorkDate": "12/10/2019",
                            "Punch": "14:30",
                            "PaygroupId": "BAD ID",
                            "PaycodeId": 0,
                            "LocationId": null,
                            "JobId": null,
                            "ProjectId": null,
                            "OrgLevel1Id": null,
                            "OrgLevel2Id": null,
                            "OrgLevel3Id": null,
                            "OrgLevel4Id": null,
                            "ReasonId": null,
							"Note": null
                        }
                    }
                ]
            }
        ]
    }
}

Example Code – C#

The following is an example of code that can be used to import punches from a console application into Time Management.

You can copy the entire contents to a C# console application, update the following values, and have an operating application.


using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json;


namespace SwipeAndGoImportExample
{
    class Program
    {
        private const string Url = "https://[ENVIRONMENTURL]/UtmRestServices/[CLIENTID]/SwipeAndGoImport?AuthGUID=[AUTHGUID]";


        static void Main(string[] args)
        {
            var request = new SwipeAndGoImportRequest
            {
                SwipeAndGoImportData = new List<SwipeAndGoImportData>()
            };


            request.SwipeAndGoImportData.Add(
           new SwipeAndGoImportData
           {
               EmpId = "[EMP ID]",
               CardNum = 0, // [CARD NUMBER]
               WorkDate = "[WORK DATE]",
               Punch = "[PUNCH TIME]",
               PaycodeId = 0, //"[PAYCODE ID]"
               PaygroupId = "[PAYGROUP ID]",
               LocationId = "[LOCATION ID]",
               JobId = "[JOB ID]",
               ProjectId = "[PROJECT ID]",
               OrgLevel1Id = "[ORG LEVEL 1 ID]",
               OrgLevel2Id = "[ORG LEVEL 2 ID]",
               OrgLevel3Id = "[ORG LEVEL 3 ID]",
               OrgLevel4Id = "[ORG LEVEL 4 ID]",
               ReasonId = "[REASON ID]",
			   Note = "[NOTE]",
           });


            var json = JsonConvert.SerializeObject(request);


            Post(Url, json);
        }


        public static void Post(string url, string json)
        {
            var encoding = new UTF8Encoding();
            var byteArray = encoding.GetBytes(json);
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentLength = byteArray.Length;
            request.ContentType = @"application/json";


            using (var dataStream = request.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
            }


            using (var response = (HttpWebResponse)request.GetResponse())
            {
                var stream = response.GetResponseStream();


                if (stream != null)
                {
                    using (var readStream = new StreamReader(stream, Encoding.UTF8))
                    {
                        var info = readStream.ReadToEnd();
                        var responseObj = JsonConvert.DeserializeObject<SwipeAndGoImportResonse>(info);
                        Console.WriteLine(responseObj);
                    }
                }
            }
        }
    }


    public class SwipeAndGoImportRequest
    {
        public List<SwipeAndGoImportData> SwipeAndGoImportData { get; set; }
    }


    public class SwipeAndGoImportData
    {
        public string EmpId { get; set; }
        public int? CardNum { get; set; }
        public string WorkDate { get; set; }
        public string Punch { get; set; }
        public string PaygroupId { get; set; }
        public int? PaycodeId { get; set; }
        public string LocationId { get; set; }
        public string JobId { get; set; }
        public string ProjectId { get; set; }
        public string OrgLevel1Id { get; set; }
        public string OrgLevel2Id { get; set; }
        public string OrgLevel3Id { get; set; }
        public string OrgLevel4Id { get; set; }
		public string ReasonId { get; set; }
		public string Note { get; set; }
    }


    public class SwipeAndGoImportResonse
    {
        public int StatusCode { get; set; }
        public string StatusDescription { get; set; }
        public SwipeAndGoImportResults Results { get; set; }
    }


    public class SwipeAndGoImportResults
    {
        public int ResultCount { get; set; }
        public int PageNumber { get; set; }
        public int TotalPages { get; set; }
        public List<SwipeAndGoImportResultsData> Data { get; set; }
    }


    public class SwipeAndGoImportResultsData
    {
        public int RecordsImported { get; set; }
        public int RecordsFailed { get; set; }
        public List<SwipeAndGoImportFailure> Failures { get; set; }
    }


    public class SwipeAndGoImportFailure
    {
        public string Reason { get; set; }
        public SwipeAndGoImportData Data { get; set; }
    }
}