1.0.0 • Published 3 years ago

absar v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Getting Started with Calc

Getting Started

Introduction

Simple calculator API hosted on APIMATIC

Install the Package

Run the following command from your project directory to install the package from npm:

npm install absar@1.0.0

You can also view the package at: https://www.npmjs.com/package/absar/v/1.0.0

Initialize the API Client

The API client can be initialized as follows:

const lib = require('lib');
const configuration = lib.Configuration;

Client Class Documentation

Calc Client

The gateway for the SDK. This class acts as a factory for the Controllers and also holds the configuration of the SDK.

Controllers

NameDescription
simpleCalculatorGets SimpleCalculatorController

API Reference

List of APIs

Simple Calculator

Overview

Get singleton instance

The singleton instance of the SimpleCalculatorController class can be accessed from the API Client.

const lib = require('lib');
const controller = lib.SimpleCalculatorController;

Get Calculate

Calculates the expression using the specified operation.

:information_source: Note This endpoint does not require authentication.

getCalculate(input)
Parameters
ParameterTypeTagsDescription
operationOperationTypeEnumTemplate, RequiredThe operator to apply on the variables
xdoubleQuery, RequiredThe LHS value
ydoubleQuery, RequiredThe RHS value
Response Type

double

Example Usage
let input = [];
let operation = lib.OperationTypeEnum.MULTIPLY;
input['operation'] = operation;

let x = 222.14;
input['x'] = x;

let y = 165.14;
input['y'] = y;

const promise = controller.getCalculate(input);
promise.then((response) => {
    // this block will be executed on successful endpoint call
    // `response` will be of type 'double'
}, (err) => {
    // this block will be executed on endpoint call failure
    // `err` is an 'object' containing more information about the error
});
Errors
HTTP Status CodeError DescriptionException Class
412Could not compute the requested calculationCouldNotComputeException

Model Reference

Enumerations

Operation Type

Possible operators are sum, subtract, multiply, divide

Class Name

OperationTypeEnum

Fields
NameDescription
SUMRepresents the sum operator
SUBTRACTRepresents the subtract operator
MULTIPLYRepresents the multiply operator
DIVIDERepresents the divide operator

Exceptions

Could Not Compute

Is thrown when invalid input is given such as div by zero

Class Name

CouldNotComputeException

Fields
NameTypeTagsDescription
serverMessagestringRequiredRepresents the server's exception message
serverCodeintRequiredRepresents the server's error code
Example (as JSON)
{
  "ServerMessage": "ServerMessage6",
  "ServerCode": 170
}