Class: VisaAcceptanceMergedSpec::CaptureApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/visa_acceptance_merged_spec/apis/capture_api.rb

Overview

CaptureApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from VisaAcceptanceMergedSpec::BaseApi

Instance Method Details

#capture_payment(id, body) ⇒ ApiResponse

Include the payment ID in the POST request to capture the payment amount. previous payment request. This ID links the capture to the payment. description here

Parameters:

  • id (String)

    Required parameter: The payment ID returned from a

  • body (CapturePaymentRequest)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/visa_acceptance_merged_spec/apis/capture_api.rb', line 15

def capture_payment(id,
                    body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pts/v2/payments/{id}/captures',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(And.new('BearerAuth', 'Accept')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PtsV2PaymentsCapturesPost201Response.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2PaymentsCapturesPost400Response1Exception)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2PaymentsCapturesPost502Response1Exception))
    .execute
end