TaxApi API endpoints provide detailed sales tax rates and calculations. Currently this Api supports below two methods
GET /v1/tax/rate
: Gets the Tax rates for a given locationPOST /v1/tax/ordersaletax
: Calculates the taxes for an order
- Getting Started
- Prerequisites
- Code Structure
- ApiConsumer Configuration
- Api Actions
- Swagger Documetation
- Testing
- Version History
These instructions will help you to get a copy of this project up and running on your local machine for development and testing purposes.
- Coding Platform : .Net Core v3.1
- Testing Tool (Optional) : Postman
- Code Editors : Visual Studio 2019 / Visual Studio Code
cd [working directory] #(e.g. ~/code or C:\users\you\src)
git clone https://github.com/psgangwar-dev/IMC.TaxApi.git
cd TaxApi
As shown in the screen shot below this solution contains 5 different projects
- IMC.TaxApi.Host : This is the host project for this solution. It conatins the initialization of all the depencies in Startup file, Conatins TaxController , which has definition for both the action methods, launchSetting information and appsettings.json files.
- IMC.TaxApi.Core : This project contains below directories.
- Providers : This directory contains all the providers for this solution, these providers act as an service layer and conatin all the Orchestartion logic in it.
- Repositoies : This directory contains all "Data Access Layers"/Repository classes. These repositories can communicate to the required ApiClients based on the ApiConsumer value.
- Validators : Contains all the request valodator classes.
- Mappers : Conatins all request and response mapper classes.
- RestClients : Contains the wrapper for all the downstream/external partner rest clients.
- IMC.TaxApi.Models : This is a shared project which contains the definition of all request and response models, Entities required by the Api, and other shared class e.g. Contants.cs class.
- IMC.TaxApi.Host.Tests : Unit test project for for IMC.TaxApi.Host project
- IMC.TaxApi.Core.Test : Unit test project for for IMC.TaxApi.Core project
Both Api Actions require a ConsumerKey to be passed in the request header. Based on the ConsumerKey RestClient Gateway can fetch the required partner configurtaions (Endpoint, AuthSecret etc) and call differnet third party endpoints accoringly. Below is the current configuration for the same.
appSettings.json
"ConsumerKeyPartnerConfiguration": { "PartnerConfigurations": [ { "ConsumerKey": "IMC", "PartnerBaseEndpoint": "https://api.taxjar.com/", "AuthToken": "5da2f821eee4035db4771edab942a4cc", "TokenAuthRequired": true }, { "ConsumerKey": "IMC_TEST", "PartnerBaseEndpoint": "https://sample.com", "AuthToken": "test_key", "TokenAuthRequired": false } ] }
-
GET /v1/tax/rate
: Gets the Tax rates for a given location Sequence Diagram : https://github.com/psgangwar-dev/IMC.TaxApi/blob/main/Documentation/SequenceDiagrams/TaxRateSequenceDiagram.yuml -
POST /v1/tax/ordersaletax
: Calculates the taxes for an orderSequence Diagram : https://github.com/psgangwar-dev/IMC.TaxApi/blob/main/Documentation/SequenceDiagrams/TaxForAnOrderSequenceDiagram.yuml
LaunchSetting.js has the swagger URL as the launch URL. Once the code is executed users will be able to see the SwaggerUI on their browsers as below.
-
GET /v1/tax/rate
-
POST /v1/tax/ordersaletax
* ReadMe.md Created By Prabha S Gangwar on 04/17/2021
* Content updated by Prabha S Gangwar on 04/18/2021