Class: ApimaticCalcu::SimpleCalculatorController

Inherits:
BaseController show all
Defined in:
lib/apimatic_calcu/controllers/simple_calculator_controller.rb

Overview

SimpleCalculatorController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from ApimaticCalcu::BaseController

Instance Method Details

#get_calculate(options = {}) ⇒ OperationTypeEnum

Calculates the expression using the specified operation. apply on the variables

Parameters:

  • operation (OperationTypeEnum)

    Required parameter: The operator to

  • x (Float)

    Required parameter: The LHS value

  • y (Float)

    Required parameter: The RHS value

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/apimatic_calcu/controllers/simple_calculator_controller.rb', line 15

def get_calculate(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/{operation}',
                                 Server::CALCULATOR)
               .template_param(new_parameter(options['operation'], key: 'operation')
                                .should_encode(true))
               .query_param(new_parameter(options['x'], key: 'x'))
               .query_param(new_parameter(options['y'], key: 'y')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:deserialize_primitive_types))
                .deserialize_into(proc do |response| response.to_s end)
                .is_primitive_response(true))
    .execute
end