示例#1
0
        public async Task GetEmployeesTest()
        {
            string ifModifiedSince = "2020-12-25"; // SDK validates date format

            string where = AutoFaker.Generate <string>();
            string order    = AutoFaker.Generate <string>();
            int?   page     = AutoFaker.Generate <int>();
            var    response = await instance.GetEmployeesAsync(accessToken, xeroTenantId, ifModifiedSince, where, order, page);

            Assert.IsType <Employees>(response);
        }
        // GET: /EmployeesInfo/
        public async Task <ActionResult> Index()
        {
            var xeroToken  = TokenUtilities.GetStoredToken();
            var utcTimeNow = DateTime.UtcNow;

            if (utcTimeNow > xeroToken.ExpiresAtUtc)
            {
                var client = new XeroClient(XeroConfig.Value, httpClientFactory);
                xeroToken = (XeroOAuth2Token)await client.RefreshAccessTokenAsync(xeroToken);

                TokenUtilities.StoreToken(xeroToken);
            }

            string accessToken  = xeroToken.AccessToken;
            string xeroTenantId = xeroToken.Tenants[0].TenantId.ToString();

            var PayrollAUApi = new PayrollAuApi();
            var response     = await PayrollAUApi.GetEmployeesAsync(accessToken, xeroTenantId);

            var employees = response._Employees;

            return(View(employees));
        }