Skip to content

psgangwar-dev/IMC.TaxApi

Repository files navigation

TaxApi

TaxApi API endpoints provide detailed sales tax rates and calculations. Currently this Api supports below two methods

  1. GET /v1/tax/rate : Gets the Tax rates for a given location
  2. POST /v1/tax/ordersaletax : Calculates the taxes for an order

Api Specifications:

Getting Started

These instructions will help you to get a copy of this project up and running on your local machine for development and testing purposes.

Prerequisites

Required software instalations

  1. Coding Platform : .Net Core v3.1
  2. Testing Tool (Optional) : Postman
  3. Code Editors : Visual Studio 2019 / Visual Studio Code

Clone the repository from github

cd [working directory] #(e.g. ~/code or C:\users\you\src)
git clone https://github.com/psgangwar-dev/IMC.TaxApi.git
cd TaxApi

Code Structure

As shown in the screen shot below this solution contains 5 different projects

  1. 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.
  2. IMC.TaxApi.Core : This project contains below directories.
    1. 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.
    2. Repositoies : This directory contains all "Data Access Layers"/Repository classes. These repositories can communicate to the required ApiClients based on the ApiConsumer value.
    3. Validators : Contains all the request valodator classes.
    4. Mappers : Conatins all request and response mapper classes.
    5. RestClients : Contains the wrapper for all the downstream/external partner rest clients.
  3. 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.
  4. IMC.TaxApi.Host.Tests : Unit test project for for IMC.TaxApi.Host project
  5. IMC.TaxApi.Core.Test : Unit test project for for IMC.TaxApi.Core project

image

ApiConsumer Configuration

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 } ] }

Api Actions/Methods

  1. 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

    image

  2. POST /v1/tax/ordersaletax : Calculates the taxes for an order

    Sequence Diagram : https://github.com/psgangwar-dev/IMC.TaxApi/blob/main/Documentation/SequenceDiagrams/TaxForAnOrderSequenceDiagram.yuml

    image

Swagger Documetation

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.

image

Testing

  1. GET /v1/tax/rate

    Request Section image

    Response image

  2. POST /v1/tax/ordersaletax

    Request Section image

    Error Response image

    Success Response image

Version History

* ReadMe.md Created By Prabha S Gangwar on 04/17/2021
* Content updated by Prabha S Gangwar on 04/18/2021

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages