README
Getting started
Simple calculator API hosted on APIMATIC
How to Build
The generated SDK relies on Node Package Manager (NPM) being available to resolve dependencies. If you don't already have NPM installed, please go ahead and follow instructions to install NPM from here. The SDK also requires Node to be installed. If Node isn't already installed, please install it from here
NPM is installed by default when Node is installed
To check if node and npm have been successfully installed, write the following commands in command prompt:
node --version
npm -version
Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):
npm install
This will install all dependencies in the node_modules
folder.
Once dependencies are resolved, you will need to move the folder APIMATICCalculatorHeadersIssueLib
in to your node_modules
folder.
How to Use
The following section explains how to use the library in a new project.
1. Open Project Folder
Open an IDE/Text Editor for JavaScript like Sublime Text. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
Click on File
and select Open Folder
.
Select the folder of your SDK and click on Select Folder
to open it up in Sublime Text. The folder will become visible in the bar on the left.
2. Creating a Test File
Now right click on the folder name and select the New File
option to create a new test file. Save it as index.js
Now import the generated NodeJS library using the following lines of code:
var lib = require('lib');
Save changes.
3. Running The Test File
To run the index.js
file, open up the command prompt and navigate to the Path where the SDK folder resides. Type the following command to run the file:
node index.js
How to Test
These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run. Tests can be run in a number of ways:
Method 1 (Run all tests)
- Navigate to the root directory of the SDK folder from command prompt.
- Type
mocha --recursive
to run all the tests.
Method 2 (Run all tests)
- Navigate to the
../test/Controllers/
directory from command prompt. - Type
mocha *
to run all the tests.
Method 3 (Run specific controller's tests)
- Navigate to the
../test/Controllers/
directory from command prompt. - Type
mocha APIMATIC Calculator [headers issue]Controller
to run all the tests in that controller file.
To increase mocha's default timeout, you can change the
TEST_TIMEOUT
parameter's value inTestBootstrap.js
.
Initialization
You need the following information for setting up the API client.
Parameter | Description |
---|---|
contentType | TODO: add a description |
API client can be initialized as following:
const lib = require('lib');
// Configuration parameters
lib.Configuration.contentType = "onefromadditionalheader";
Class Reference
List of Controllers
FormParamsController
Get singleton instance
The singleton instance of the FormParamsController
class can be accessed from the API Client.
var controller = lib.FormParamsController;
createVerifyEndpointLevelContentTypeShouldBeUsed
Calculates the expression using the specified operation.
function createVerifyEndpointLevelContentTypeShouldBeUsed(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
operation | Required |
The operator to apply on the variables |
body | Required |
TODO: Add a parameter description |
contentType | Required DefaultValue |
TODO: Add a parameter description |
Example Usage
var input = [];
input['operation'] = new OperationTypeEnum(MULTIPLY);
input['body'] = new Request({"x":5, "y":5});
input['contentType'] = 'application/endpointLevel';
controller.createVerifyEndpointLevelContentTypeShouldBeUsed(input, function(error, response, context) {
});
createVerifyGlobalContentTypeShouldBeUsed
TODO: Add a method description
function createVerifyGlobalContentTypeShouldBeUsed(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
operation | Required |
TODO: Add a parameter description |
body | Required |
TODO: Add a parameter description |
Example Usage
var input = [];
input['operation'] = new OperationTypeEnum(MULTIPLY);
input['body'] = new Request({"x":5, "y":5});
controller.createVerifyGlobalContentTypeShouldBeUsed(input, function(error, response, context) {
});
createCheckBodyForGlobalLevelHeader
TODO: Add a method description
function createCheckBodyForGlobalLevelHeader(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
operation | Required |
TODO: Add a parameter description |
body | Required |
TODO: Add a parameter description |
Example Usage
var input = [];
input['operation'] = new OperationTypeEnum(MULTIPLY);
input['body'] = new Request({"x":5, "y":5});
controller.createCheckBodyForGlobalLevelHeader(input, function(error, response, context) {
});
createCheckBodyForEndpointLevelHeader
TODO: Add a method description
function createCheckBodyForEndpointLevelHeader(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
operation | Required |
TODO: Add a parameter description |
body | Required |
TODO: Add a parameter description |
contentType | Required |
TODO: Add a parameter description |
Example Usage
var input = [];
input['operation'] = new OperationTypeEnum(MULTIPLY);
input['body'] = new Request({"x":5, "y":5});
input['contentType'] = 'application/endpointLevel';
controller.createCheckBodyForEndpointLevelHeader(input, function(error, response, context) {
});
BodyParamsController
Get singleton instance
The singleton instance of the BodyParamsController
class can be accessed from the API Client.
var controller = lib.BodyParamsController;
createVerifyEndpointLevelContentTypeShouldBeUsed
Calculates the expression using the specified operation.
function createVerifyEndpointLevelContentTypeShouldBeUsed(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
operation | Required |
The operator to apply on the variables |
body | Required |
TODO: Add a parameter description |
contentType | Required DefaultValue |
TODO: Add a parameter description |
Example Usage
var input = [];
input['operation'] = new OperationTypeEnum(MULTIPLY);
input['body'] = new Request({"x":5, "y":5});
input['contentType'] = 'application/endpointLevel';
controller.createVerifyEndpointLevelContentTypeShouldBeUsed(input, function(error, response, context) {
});
createVerifyGlobalContentTypeShouldBeUsed
TODO: Add a method description
function createVerifyGlobalContentTypeShouldBeUsed(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
operation | Required |
TODO: Add a parameter description |
body | Required |
TODO: Add a parameter description |
Example Usage
var input = [];
input['operation'] = new OperationTypeEnum(MULTIPLY);
input['body'] = new Request({"x":5, "y":5});
controller.createVerifyGlobalContentTypeShouldBeUsed(input, function(error, response, context) {
});
createCheckBodyForGlobalLevelHeader
TODO: Add a method description
function createCheckBodyForGlobalLevelHeader(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
operation | Required |
TODO: Add a parameter description |
body | Required |
TODO: Add a parameter description |
Example Usage
var input = [];
input['operation'] = new OperationTypeEnum(MULTIPLY);
input['body'] = new Request({"x":5, "y":5});
controller.createCheckBodyForGlobalLevelHeader(input, function(error, response, context) {
});
createCheckBodyForEndpointLevelHeader
TODO: Add a method description
function createCheckBodyForEndpointLevelHeader(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
operation | Required |
TODO: Add a parameter description |
body | Required |
TODO: Add a parameter description |
contentType | Required |
TODO: Add a parameter description |
Example Usage
var input = [];
input['operation'] = new OperationTypeEnum(MULTIPLY);
input['body'] = new Request({"x":5, "y":5});
input['contentType'] = 'application/endpointLevel';
controller.createCheckBodyForEndpointLevelHeader(input, function(error, response, context) {
});