@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
83 lines • 3.24 kB
JavaScript
import { TaxEngineRequestSchema, TaxEngineResponseSchema, } from '../schemas';
/**
* Creates the taxEngine resource methods
* OpenAPI Path: /tax-engine → taxEngine.*
* @description Tax calculations and jurisdiction-based tax determination
*/
export function createTaxEngineResource(executeRequest) {
return {
/**
* Create tax calculation using the tax engine
* @description Tax calculation endpoint with postal code-based rate lookups and jurisdiction breakdowns
* @fullPath api.pricing.taxEngine.create
* @service pricing
* @domain tax-calculation
* @dataMethod taxEngineData.create
* @discoverable true
* @searchTerms ["tax engine", "tax calculation", "tax computation", "create tax"]
* @relatedEndpoints ["api.pricing.priceEngine.get"]
* @commonPatterns ["calculate tax", "run tax engine", "tax computation"]
* @param request Tax calculation request with customer, items, and shipping address information
* @returns Detailed tax calculation with total tax, rates, and jurisdiction-specific breakdowns
* @throws ValidationError When request is invalid or response is malformed
* @example
* ```typescript
* const tax = await client.taxEngine.create({
* customer_id: 12345,
* postal_code: '12345',
* items: [
* {
* item_id: 'ABC123',
* quantity: 2,
* unit_price: 25.99,
* extended_amount: 51.98
* }
* ],
* ship_to_address: {
* street: '123 Main St',
* city: 'Anytown',
* state: 'NY',
* postal_code: '12345'
* }
* });
*
* console.log('Total Tax:', tax.total_tax);
* console.log('Tax Rate:', tax.tax_rate);
* tax.jurisdictions.forEach(j => {
* console.log(`${j.jurisdiction_name}: ${j.tax_rate}% = $${j.tax_amount}`);
* });
* ```
*/
create: async (request) => {
return executeRequest({
method: 'POST',
path: '/tax-engine',
paramsSchema: TaxEngineRequestSchema,
responseSchema: TaxEngineResponseSchema,
}, request);
},
};
}
/**
* Creates the taxEngineData resource methods (data-only versions)
*/
export function createTaxEngineDataResource(taxEngine) {
return {
/**
* Create tax calculation data without response metadata
* @fullPath api.pricing.taxEngineData.create
* @service pricing
* @domain tax-calculation
* @discoverable true
* @searchTerms ["tax engine data", "create tax data", "tax calculation data"]
* @relatedEndpoints ["api.pricing.taxEngine.create"]
* @commonPatterns ["create tax data", "tax calculation data"]
* @returns Promise<TaxEngineData> Tax calculation data directly
*/
create: async (request) => {
const response = await taxEngine.create(request);
return response.data;
},
};
}
//# sourceMappingURL=tax-engine.js.map