Dot Net Core Web Api to Communicate with External Tax Api (e.g. TaxJar)
- Api UML
- Api Prerequisite
- Api Architecture
- Api Security
- Api Configuration
- Api Swagger
- Api in Action
- Authors
-
Get Tax Rate
Sequence Source: https://github.com/rajforweb/TaxApi-Dot-Net-Core-App/blob/main/UML/GetTaxRate.yuml
-
Calculate Tax for an Order
Sequence Source: https://github.com/rajforweb/TaxApi-Dot-Net-Core-App/blob/main/UML/TaxForOrder.yuml
- Prerequisite : .Net Core 3.1.
- Dev Tools : VS2019 / VSCode
-
This Api is build on .Net Core 3.1 which is a lightweight, cross platform and high performance framewrok.
-
Api is build on
Onion Architecture
pattern which provides a better way to build applications for better testability, maintainability, and dependability on the infrastructures like databases and service. -
TaxApi.Host
- To Get Tax Rate [Route : /api/Tax/TaxRate]
- Calculate Tax for an Order [Route: /api/Tax/OrderTax]
- ActionFilter : Validates consumer and returns 401 unauthorized if consumer not allowed.
- ExceptionFilter : Catches all exception and returns appropriate error message with status code.
-
TaxApi.Core
- Service : Enables to communicates with Repositories. One controller will have one Service. Service layer validates the request and populates a valid apiRequest and sends to repository.
- Repository : Enables to make ApiCall and returns response.
- Validators : Validates Api request to ensure valid request sent to TaxJarApi.
- ApiClient : ApiClient makes call to external TaxJar Api using HttpClient.
- Helpers : This enables to load configured consumers.
- Excetpions : This enables custom exception handling and return error message.
-
TaxApi.Domain
- This layer keep all model & entities required to process a request.
-
Unit Tests
- TaxApi.Host.Tests
- TaxApi.Core.Tests
- Test Driven development : Xunit enables early detection of failures and provides robust software delivery. XUnit used to test app components.
-
TaxApi is Secure and only allowed to Consumer with having valid consumer key. User without valid consumer key won’t be able to use this API and request will fail. Please use consumerKey as "f4b358d793ce4105b46d9f055cf53f79" to use this App. This is configured using AppSettings.Json.
-
This allows to add consumers with external Tax provider(e.g. TaxJar) URL & their Authentication token. So, this App having capability to onboard a consumer and configure external tax api like TaxJar. As long as data contract not changing this app will handle multiple external Api to get Tax information.
- consumerKey : TaxApi consumer key to access TaxApi.
- taxApiUrl : Configure external Api (e.g. TaxJarApi) which provides Tax Data.
- taxApiAuthToken : Configure AuthToken for external Api.
- Raj Kumar