Getting Started with APIMATIC Calculator
Getting Started
Introduction
Simple calculator API hosted on APIMATIC
Install the Package
Install the gem from the command line:
gem install testr1 -v 1.0.0
Or add the gem to your Gemfile and run bundle
:
gem 'testr1', '1.0.0'
For additional gem details, see the RubyGems page for the testr1 gem.
Initialize the API Client
The following parameters are configurable for the API Client:
Parameter | Type | Description |
---|---|---|
environment |
Environment | The API environment. Default: Environment.PRODUCTION |
timeout |
Float |
The value to use for connection timeout. Default: 60 |
max_retries |
Integer |
The number of times to retry an endpoint call if it fails. Default: 0 |
retry_interval |
Float |
Pause in seconds between retries. Default: 1 |
backoff_factor |
Float |
The amount to multiply each successive retry's interval amount by in order to provide backoff. Default: 1 |
The API client can be initialized as follows:
client = ApimaticCalculator::Client.new(
environment: Environment::PRODUCTION,
)
Test the SDK
To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
rake
Client Class Documentation
APIMATIC CalculatorClient
The gateway for the SDK. This class acts as a factory for the Controllers and also holds the configuration of the SDK.
Controllers
Name | Description |
---|---|
simple_calculator | Provides access to SimpleCalculatorController |
API Reference
List of APIs
Simple Calculator
Overview
Get instance
An instance of the SimpleCalculatorController
class can be accessed from the API Client.
simple_calculator_controller = client.simple_calculator
Get Calculate
Calculates the expression using the specified operation.
:information_source: Note This endpoint does not require authentication.
def get_calculate(options = {})
Parameters
Parameter | Type | Tags | Description |
---|---|---|---|
operation |
OperationTypeEnum |
Template, Required | The operator to apply on the variables |
x |
Float |
Query, Required | The LHS value |
y |
Float |
Query, Required | The RHS value |
Response Type
Float
Example Usage
collect = {}
operation = OperationTypeEnum::MULTIPLY
collect['operation'] = operation;
x = 222.14
collect['x'] = x;
y = 165.14
collect['y'] = y;
result = simple_calculator_controller.get_calculate(collect)
Model Reference
Enumerations
Operation Type
Possible operators are sum, subtract, multiply, divide
Class Name
OperationTypeEnum
Fields
Name | Description |
---|---|
SUM |
Represents the sum operator |
SUBTRACT |
Represents the subtract operator |
MULTIPLY |
Represents the multiply operator |
DIVIDE |
Represents the divide operator |
Utility Classes Documentation
ApiHelper Class
API utility class.
Methods
Name | Return Type | Description |
---|---|---|
json_deserialize | Hash | Deserializes a JSON string to a Ruby Hash. |
rfc3339 | DateTime | Safely converts a string into an RFC3339 DateTime object. |
Common Code Documentation
HttpResponse
Http response received.
Properties
Name | Type | Description |
---|---|---|
status_code | Integer | The status code returned by the server. |
reason_phrase | String | The reason phrase returned by the server. |
headers | Hash | Response headers. |
raw_body | String | Response body. |
request | HttpRequest | The request that resulted in this response. |
HttpRequest
Represents a single Http Request.
Properties
Name | Type | Tag | Description |
---|---|---|---|
http_method | HttpMethodEnum | The HTTP method of the request. | |
query_url | String | The endpoint URL for the API request. | |
headers | Hash | Optional | Request headers. |
parameters | Hash | Optional | Request body. |