Exemplo n.º 1
0
        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 = $"{TWPApiUtil.Accruals_EndPoint}?pageSize={API_Page_Size}";

            if (asOfDate != null)
            {
                pagedURL += $"&asOfDate={TWPApiUtil.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);
        }
Exemplo n.º 2
0
        public static async Task <TWP_PayrollActivities> GetPayrollActivities(int siteId, string APIToken, DateTime?payPeriodDate = null, List <string> employeeIds = null, string payrollFormat = null)
        {
            string dateParam = TWPApiUtil.FormatAPIDate(payPeriodDate ?? DateTime.Now);

            string payrollActivityURL = $"{TWPApiUtil.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);
            }
            else
            {
                List <string> eeid     = new List <string>();
                var           response = await ListEmployees(siteId, APIToken);

                foreach (TWP_Employee ee in response)
                {
                    eeid.Add(ee.EmployeeCode);
                }
                requestBody = new TWP_PayrollActivitiesRequest(eeid);
            }

            return(JsonConvert.DeserializeObject <TWP_PayrollActivities>(
                       await CallTWPAPI(siteId, APIToken, payrollActivityURL, HttpMethod.Post, requestBody)));
        }
Exemplo n.º 3
0
        public static async Task <TWP_PayrollActivities> getActivitiesBySDED(int siteId, string APIToken, DateTime?startDate = null, DateTime?endDate = null, string payrollFormat = null)
        {
            string startdate          = TWPApiUtil.FormatAPIDate(startDate ?? DateTime.Now);
            string enddate            = TWPApiUtil.FormatAPIDate(endDate ?? DateTime.Now);
            string payrollActivityURL = $"{TWPApiUtil.Payroll_Activities_EndPoint}?beginDate={startdate}&endDate={enddate}";

            if (!string.IsNullOrEmpty(payrollFormat))
            {
                payrollActivityURL += $"&format={payrollFormat}";
            }


            return(JsonConvert.DeserializeObject <TWP_PayrollActivities>(await CallTWPAPI(siteId, APIToken, payrollActivityURL, HttpMethod.Post)));
        }
Exemplo n.º 4
0
        public static async Task <JObject> getTimeCardSum(int siteId, string APIToken, DateTime?payPeriodDate = null, List <string> employeeIds = null)
        {
            string dateParam = TWPApiUtil.FormatAPIDate(payPeriodDate ?? DateTime.Now);

            string timecardSumURL = $"{TWPApiUtil.getTimeCardSum}?periodDate={dateParam}";

            if (employeeIds.safeCount() > 0)
            {
                timecardSumURL += $"&ids={String.Join(",", employeeIds)}";
            }

            string timecardsumJSON = await CallTWPAPI(siteId, APIToken, timecardSumURL);

            return(JObject.Parse(timecardsumJSON));
        }
Exemplo n.º 5
0
        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 = $"{TWPApiUtil.Accruals_Activity_EndPoint}?pageSize={API_Page_Size}";

            if (startDate != null)
            {
                pagedURL += $"&startDate={TWPApiUtil.FormatAPIDate(startDate.Value)}";
            }

            if (endDate != null)
            {
                pagedURL += $"&endDate={TWPApiUtil.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);
        }