public static async Task <List <TWP_Accruals> > GetAccruals(int siteId, string apiToken, DateTime?asOfDate = null, string category = null) { List <TWP_Accruals> allAccruals = new List <TWP_Accruals>(); string pagedURL = $"{TWP_API_UTILS.ACCRUALS_ENDPOINT}?pageSize={API_PAGE_SIZE}"; if (asOfDate != null) { pagedURL += $"&asOfDate={TWP_API_UTILS.FormatAPIDate(asOfDate.Value)}"; } if (category != null) { pagedURL += $"&category={category}"; } while (!String.IsNullOrEmpty(pagedURL)) { string apiResponse = await CallTWPAPI(siteId, apiToken, pagedURL, HttpMethod.Get); TWP_API_List_Response result = JsonConvert.DeserializeObject <TWP_API_List_Response>(apiResponse); allAccruals.AddRange(result.Results.Select(accJson => accJson.ToObject <TWP_Accruals>())); pagedURL = result.NextPageLink; } return(allAccruals); }
public static async Task <JObject> GetTimecardDetails(int siteId, string apiToken, DateTime?payPeriodDate = null, List <string> employeeIds = null) { string dateParam = TWP_API_UTILS.FormatAPIDate(payPeriodDate ?? DateTime.Now); string timecardDetailsURL = $"{TWP_API_UTILS.TIMECARD_DETAILS_ENDPOINT}?periodDate={dateParam}"; if (employeeIds.SafeCount() > 0) { timecardDetailsURL += $"&ids={String.Join(",", employeeIds)}"; } string timecardDetailsJSON = await CallTWPAPI(siteId, apiToken, timecardDetailsURL); return(JObject.Parse(timecardDetailsJSON)); }
public static async Task <List <TWP_AccrualActivities> > GetAccrualActivity(int siteId, string apiToken, DateTime?startDate = null, DateTime?endDate = null, string category = null, List <string> employeeIds = null) { List <TWP_AccrualActivities> allAccruals = new List <TWP_AccrualActivities>(); string pagedURL = $"{TWP_API_UTILS.ACCRUALS_ACTIVITY_ENDPOINT}?pageSize={API_PAGE_SIZE}"; if (startDate != null) { pagedURL += $"&startDate={TWP_API_UTILS.FormatAPIDate(startDate.Value)}"; } if (endDate != null) { pagedURL += $"&endDate={TWP_API_UTILS.FormatAPIDate(endDate.Value)}"; } if (category != null) { pagedURL += $"&category={category}"; } if (employeeIds.SafeCount() > 0) { pagedURL += $"&ids={String.Join(",", employeeIds)}"; } while (!String.IsNullOrEmpty(pagedURL)) { string apiResponse = await CallTWPAPI(siteId, apiToken, pagedURL, HttpMethod.Get); TWP_API_List_Response result = JsonConvert.DeserializeObject <TWP_API_List_Response>(apiResponse); allAccruals.AddRange(result.Results.Select(accJson => accJson.ToObject <TWP_AccrualActivities>())); pagedURL = result.NextPageLink; } return(allAccruals); }
public static async Task <TWP_PayrollActivities> GetPayrollActivities(int siteId, string apiToken, DateTime?payPeriodDate = null, List <string> employeeIds = null, string payrollFormat = null) { string dateParam = TWP_API_UTILS.FormatAPIDate(payPeriodDate ?? DateTime.Now); string payrollActivityURL = $"{TWP_API_UTILS.PAYROLL_ACTIVITIES_ENDPOINT}?periodDate={dateParam}"; if (!String.IsNullOrEmpty(payrollFormat)) { payrollActivityURL += $"&format={payrollFormat}"; } TWP_PayrollActivitiesRequest requestBody = null; if (employeeIds.SafeCount() > 0) { requestBody = new TWP_PayrollActivitiesRequest(employeeIds); } return(JsonConvert.DeserializeObject <TWP_PayrollActivities>( await CallTWPAPI(siteId, apiToken, payrollActivityURL, HttpMethod.Post, requestBody))); }