/// <param name='operations'> /// Reference to the BoomTax.Api.SampleProject.IForm1095COperations. /// </param> /// <param name='filingId'> /// Required. /// </param> /// <param name='form1095C'> /// Required. /// </param> public static int Post(this IForm1095COperations operations, int filingId, Form1095C form1095C) { return(Task.Factory.StartNew((object s) => { return ((IForm1095COperations)s).PostAsync(filingId, form1095C); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <param name='id'> /// Required. /// </param> /// <param name='form1095C'> /// Required. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> public async Task <HttpOperationResponse <Form1095C> > PutWithOperationResponseAsync(int id, Form1095C form1095C, CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // Validate if (form1095C == null) { throw new ArgumentNullException("form1095C"); } // Tracing bool shouldTrace = ServiceClientTracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("id", id); tracingParameters.Add("form1095C", form1095C); ServiceClientTracing.Enter(invocationId, this, "PutAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/2016/Form1095C"; List <string> queryParameters = new List <string>(); queryParameters.Add("id=" + Uri.EscapeDataString(id.ToString())); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Put; httpRequest.RequestUri = new Uri(url); // Set Headers // Set Credentials if (this.Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); } // Serialize Request string requestContent = null; JToken requestDoc = form1095C.SerializeJson(null); requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); // Send Request if (shouldTrace) { ServiceClientTracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { ServiceClientTracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); if (statusCode != HttpStatusCode.OK) { HttpOperationException <object> ex = new HttpOperationException <object>(); ex.Request = httpRequest; ex.Response = httpResponse; ex.Body = null; if (shouldTrace) { ServiceClientTracing.Error(invocationId, ex); } throw ex; } // Create Result HttpOperationResponse <Form1095C> result = new HttpOperationResponse <Form1095C>(); result.Request = httpRequest; result.Response = httpResponse; // Deserialize Response if (statusCode == HttpStatusCode.OK) { Form1095C resultModel = new Form1095C(); JToken responseDoc = null; if (string.IsNullOrEmpty(responseContent) == false) { responseDoc = JToken.Parse(responseContent); } if (responseDoc != null) { resultModel.DeserializeJson(responseDoc); } result.Body = resultModel; } if (shouldTrace) { ServiceClientTracing.Exit(invocationId, result); } return(result); }
/// <param name='operations'> /// Reference to the BoomTax.Api.SampleProject.IForm1095COperations. /// </param> /// <param name='id'> /// Required. /// </param> /// <param name='form1095C'> /// Required. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> public static async Task <Form1095C> PutAsync(this IForm1095COperations operations, int id, Form1095C form1095C, CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { Microsoft.Rest.HttpOperationResponse <BoomTax.Api.SampleProject.Models.Form1095C> result = await operations.PutWithOperationResponseAsync(id, form1095C, cancellationToken).ConfigureAwait(false); return(result.Body); }
/// <param name='operations'> /// Reference to the BoomTax.Api.SampleProject.IForm1095COperations. /// </param> /// <param name='filingId'> /// Required. /// </param> /// <param name='form1095C'> /// Required. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> public static async Task <int> PostAsync(this IForm1095COperations operations, int filingId, Form1095C form1095C, CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { Microsoft.Rest.HttpOperationResponse <int> result = await operations.PostWithOperationResponseAsync(filingId, form1095C, cancellationToken).ConfigureAwait(false); return(result.Body); }
private static Form1095C[] Get1095CData() { var formRose = new Form1095C { FirstName = "Rose", MiddleName = "", LastName = "Davichi", Address = "847 Walnut Avenue", City = "Roy", State = "NM", Zip = "87743", CountryCode = "US", EmployerPhone = "5551234545", PlanStartMonth = "01", Ssn = "000000577", OfferOfCoverageAll12Months = "1E", EmployeeShareAll12Months = 0, CoveredIndividuals = new List <CoveredIndividual>() { new CoveredIndividual() { FirstName = "Omar", LastName = "Davichi", Ssn = "000000578", All12Months = true }, new CoveredIndividual() { FirstName = "Sam", LastName = "Davichi", Ssn = "000000579", All12Months = true }, new CoveredIndividual() { FirstName = "Erica", LastName = "Davichi", Dob = new DateTime(2005, 12, 5), Jan = false, Feb = false, Mar = false, Apr = false, May = false, Jun = false, Jul = true, Aug = true, Sep = true, Oct = true, Nov = true, Dec = true } } }; var formPeter = new Form1095C { FirstName = "Peter", MiddleName = "", LastName = "Davignon", Address = "5991 Sycamore Lane", City = "Sandy", State = "UT", Zip = "84094", CountryCode = "US", EmployerPhone = "5551234545", PlanStartMonth = "01", Ssn = "000000581", OfferOfCoverageAll12Months = "1A", //note, a difference between null and 0 here //EmployeeShareAll12Months = null, CoveredIndividuals = new List <CoveredIndividual>() { new CoveredIndividual() { FirstName = "Sally", MiddleName = "", LastName = "Davignon", Ssn = "000000583", All12Months = true }, new CoveredIndividual() { FirstName = "Teddy", MiddleName = "", LastName = "Davignon", Ssn = "000000589", Dob = new DateTime(2015, 6, 28), Jan = false, Feb = false, Mar = false, Apr = false, May = false, Jun = true, Jul = true, Aug = true, Sep = true, Oct = true, Nov = true, Dec = true } } }; var formOdette = new Form1095C { FirstName = "Odette", MiddleName = "Cloudy", LastName = "Davidson", Address = "2993 Spruce Lane", City = "Fort Collins", State = "CO", Zip = "80522", CountryCode = "US", EmployerPhone = "5551234545", PlanStartMonth = "01", Ssn = "000000533", OfferOfCoverageAll12Months = "1A", //EmployeeShareAll12Months = 0, CoveredIndividuals = new List <CoveredIndividual>() { new CoveredIndividual() { FirstName = "Peter", MiddleName = "", LastName = "Davidson", Dob = new DateTime(1970, 2, 6), All12Months = true }, new CoveredIndividual() { FirstName = "Mindy", LastName = "Davidson", Ssn = "000000534", All12Months = true }, new CoveredIndividual() { FirstName = "Nicolas", MiddleName = "", LastName = "Davidson", Ssn = "000000535", All12Months = true }, } }; return(new[] { formRose, formPeter, formOdette }); }
private static async Task Start() { string baseUrl = ConfigurationManager.AppSettings["BaseUrl"]; HttpResponseMessage response = new HttpResponseMessage(); using (var loginClient = new HttpClient { BaseAddress = new Uri(baseUrl) }) { //login and get token var credentials = new FormUrlEncodedContent(new Dictionary <string, string> { { "username", ConfigurationManager.AppSettings["UserName"] }, { "password", ConfigurationManager.AppSettings["Password"] }, { "grant_type", "password" } }); response = await loginClient.PostAsync("Token", credentials); } if (response.IsSuccessStatusCode) { //parse token string loginResult = await response.Content.ReadAsStringAsync(); dynamic data = JToken.Parse(loginResult); var token = data.access_token.ToString(); using (BoomTaxApi client = new BoomTaxApi(new Uri(baseUrl), new TokenCredentials(token))) { Console.WriteLine($"Getting filing types"); var filingTypes = await client.FilingType.GetFilingTypesAsync(); var aca2016FilingType = filingTypes.FirstOrDefault(o => o.TaxYear == 2016 && o.Name == "ACA Reporting (1094C/1095C)"); Console.WriteLine($"Creating filing..."); var filing = client.Filing.Post(aca2016FilingType.Id.Value, "ABC Corporation"); Console.WriteLine($"Filing id: {filing.Id}"); //all examples from pre-January 2016 test scenario #region header form data var headerFormData = new Form1094C() { CompanyName = "Darrtestfive", Ein = "000000599", Address = "4689 Redwood Avenue", City = "Austin", State = "TX", Zip = "78755", CountryCode = "US", ContactFirstName = "Susan", ContactLastName = "Williamson", ContactPhone = "5551234567", TotalNumberOfForms = "322", IsAuthoritativeTransmittal = true, IsQualifyingOfferMethod = true, IsSection4980HTransitionRelief = true, IsMinimumOfferYesJan = true, IsMinimumOfferYesFeb = true, IsMinimumOfferYesMar = true, IsMinimumOfferYesApr = true, IsMinimumOfferYesMay = true, IsMinimumOfferYesJun = true, IsMinimumOfferYesJul = true, IsMinimumOfferYesAug = true, IsMinimumOfferYesSep = true, IsMinimumOfferYesOct = true, IsMinimumOfferYesNov = true, IsMinimumOfferYesDec = true, IsAggregatedGroupJan = true, IsAggregatedGroupFeb = true, IsAggregatedGroupMar = true, IsAggregatedGroupApr = true, IsAggregatedGroupMay = true, IsAggregatedGroupJun = true, IsAggregatedGroupJul = true, IsAggregatedGroupAug = true, IsAggregatedGroupSep = true, IsAggregatedGroupOct = true, IsAggregatedGroupNov = true, IsAggregatedGroupDec = true, IsSection4980hAll12MonthsSpecified = true, Section4980HTransitionReliefIndicatorAll12Months = "A", FullTimeEmployeeCountJan = 315, TotalEmployeeCountJan = 330, FullTimeEmployeeCountFeb = 316, TotalEmployeeCountFeb = 335, FullTimeEmployeeCountMar = 316, TotalEmployeeCountMar = 335, FullTimeEmployeeCountApr = 316, TotalEmployeeCountApr = 335, FullTimeEmployeeCountMay = 316, TotalEmployeeCountMay = 335, FullTimeEmployeeCountJun = 316, TotalEmployeeCountJun = 335, FullTimeEmployeeCountJul = 318, TotalEmployeeCountJul = 335, FullTimeEmployeeCountAug = 318, TotalEmployeeCountAug = 333, FullTimeEmployeeCountSep = 318, TotalEmployeeCountSep = 333, FullTimeEmployeeCountOct = 318, TotalEmployeeCountOct = 333, FullTimeEmployeeCountNov = 318, TotalEmployeeCountNov = 333, FullTimeEmployeeCountDec = 318, TotalEmployeeCountDec = 333, IsMemberOfAggregateAle = true, Ein1 = "000000600", Name1 = "Darrtestfive Subsidiary One" }; #endregion Console.WriteLine($"Adding header form..."); var headerFormId = client.Form1094C.Post(filing.Id.Value, headerFormData); Console.WriteLine($"Header form id: {headerFormId}"); //populate our 1095-Cs //this is using static data from test scenarios. //you will likely want to pull this from your database var form1095Cs = Get1095CData(); int lastFormId = 0; //add 1095-Cs foreach (var form in form1095Cs) { Console.WriteLine($"Adding form for employee: {form.FirstName} {form.LastName}"); lastFormId = client.Form1095C.Post(filing.Id.Value, form); Console.WriteLine($"Created form with id: {lastFormId}"); } //update a form (we changed the SSN in this case) //make sure to include all fields, not just the updated fields. #region updated form data var updatedForm = new Form1095C { FirstName = "Odette", MiddleName = "Cloudy", LastName = "Davidson", Address = "2993 Spruce Lane", City = "Fort Collins", State = "CO", Zip = "80522", CountryCode = "US", EmployerPhone = "5551234545", PlanStartMonth = "01", Ssn = "000000534", OfferOfCoverageAll12Months = "1A", //EmployeeShareAll12Months = 0, CoveredIndividuals = new List <CoveredIndividual>() { new CoveredIndividual() { FirstName = "Peter", MiddleName = "", LastName = "Davidson", Dob = new DateTime(1970, 2, 6), All12Months = true }, new CoveredIndividual() { FirstName = "Mindy", LastName = "Davidson", Ssn = "000000534", All12Months = true }, new CoveredIndividual() { FirstName = "Nicolas", MiddleName = "", LastName = "Davidson", Ssn = "000000535", All12Months = true }, } }; #endregion Console.WriteLine($"Updating form at id: {lastFormId}"); client.Form1095C.Put(lastFormId, updatedForm); Console.WriteLine($"Deleting form at id: {lastFormId}"); client.Form1095C.Delete(lastFormId); Console.WriteLine($"Form deleted."); Console.WriteLine($"Initiating e-file request..."); //initiate e-file and add emails for notifications. //note: This could generate more than 1 efile request depending on what has changed since the previous e-file. IList <int> efileRequestIds = new List <int>(); //e-filing will not be available until late December/early January. //until then, this will throw an error. try { efileRequestIds = client.EfileRequest.Post(filing.Id.Value, "*****@*****.**", isSilent: false); } catch (HttpOperationException ex) { Console.WriteLine(ex.Response.AsFormattedString()); } //***************************************************************************************** //DO NOT POLL A GIVEN ID MORE THAN ONCE EVERY 15 MINUTES OR YOUR ACCOUNT MAY BE RESTRICTED. //***************************************************************************************** if (efileRequestIds.Any()) { Console.WriteLine($"Checking e-file request..."); var efileRequest = client.EfileRequest.GetEfileRequest(efileRequestIds.First()); //if the e-file request is complete, this means we have a response from the IRS. if (efileRequest.IsComplete ?? false) { Console.WriteLine($"E-File request complete. Getting response."); var efileResponse = client.EfileResponse.Get(efileRequest.EfileResponseId.Value); //get receipt and receipt detail Console.WriteLine($"ReceiptId: {efileResponse.ReceiptId}, ReceivedOn: {efileResponse.ReceivedOn}, Status: {efileResponse.Status}"); //get form errors foreach (var errorDetails in efileResponse.Errors) { Console.WriteLine($"FormId:{errorDetails.FormId}, ErrorCode:{errorDetails.ErrorCode}, ErrorMessage:{errorDetails.ErrorMessage}"); } } } Console.WriteLine($"Deleting filing..."); client.Filing.Delete(filing.Id.Value); Console.WriteLine($"Filing deleted."); } Console.ReadKey(); } }