public async Task <ServiceResponse <SelfEmploymentObligationsResponse> > GetEmploymentObligations(string token, string nino, string selfEmploymentId) { var response = new ServiceResponse <SelfEmploymentObligationsResponse>() { Data = new SelfEmploymentObligationsResponse() }; if (String.IsNullOrEmpty(nino)) { response.AddError("NINO", "Please enter a National Insurance Number"); } if (response.IsValid) { response = await _commonDataService.CallApiAsync <SelfEmploymentObligationsResponse>($"/self-assessment/ni/{nino}/self-employments/{selfEmploymentId}/obligations", token, HttpRequestType.Get); } return(response); }
public async Task <ServiceResponse <VATObligationsResponse> > GetVATObligations(string token, string vrn, DateTime from, DateTime to, VATStatus vatStatus) { var response = new ServiceResponse <VATObligationsResponse>() { Data = new VATObligationsResponse() }; if (String.IsNullOrEmpty(vrn)) { response.AddError("VRN", "Please enter a VAT Registration Number"); } if (response.IsValid) { response = await _commonDataService.CallApiAsync <VATObligationsResponse>($"vat/{vrn}/obligations?from={from.ToString("yyyy-MM-dd")}&to={to.ToString("yyyy-MM-dd")}&status={vatStatus.ToString()}", token, HttpRequestType.Get); } return(response); }
public async Task <ServiceResponse <TaxCalculationResponse> > IntentToCrystalise(string token, string nino, string taxYear) { var response = new ServiceResponse <TaxCalculationResponse>() { Data = new TaxCalculationResponse() }; Validator.ValidateNinoandTaxYear(nino, taxYear, response); if (!response.IsValid) { var createResponse = await _commonDataService.CallApiAsync <CrystalisationIntentResponse>($"/self-assessment/ni/{nino}/{taxYear}/intent-to-crystallise", token, HttpRequestType.Post); if (createResponse.IsValid) { var taxCalcLocation = createResponse.Location; var taxCalulationId = taxCalcLocation.Split('/').Last(); //I Imagine there will be a delay here response = await _commonDataService.CallApiAsync <TaxCalculationResponse>($"{createResponse.Location}", token, HttpRequestType.Get); } } return(response); }
public async Task <ServiceResponse <TaxCalculationResponse> > CalculateTax(string token, string nino, string taxYear) { var response = new ServiceResponse <TaxCalculationResponse>() { Data = new TaxCalculationResponse() }; Validator.ValidateNinoandTaxYear(nino, taxYear, response); if (!response.IsValid) { var calcresponse = await _commonDataService.CallApiAsync <CreateTaxCalcResponse>($"/self-assessment/ni/{nino}/calculations", token, HttpRequestType.Get); if (calcresponse.IsValid) { var delay = calcresponse.Data.etaSeconds; //Delay for a few seconds to try again await Task.Delay(delay * 1000); response = await _commonDataService.CallApiAsync <TaxCalculationResponse>($"{calcresponse.Location}", token, HttpRequestType.Get); } } return(response); }
public async Task <ServiceResponse <IndividualBenefits> > GetBenefitsAsync(string utr, string taxYear) { var response = new ServiceResponse <IndividualBenefits>() { Data = new IndividualBenefits() }; HmrcDotNet.Helpers.Validator.ValidateUtRandTaxYear(utr, taxYear, response); if (response.IsValid) { response = await _commonDataService.CallApiAsync <IndividualBenefits>($"/individual-benefits/sa/{utr}/annual-summary/{taxYear}", _token, HttpRequestType.Get); } return(response); }