Class: CyberSourceMergedSpec::OrdersController

Inherits:
BaseController show all
Defined in:
lib/cyber_source_merged_spec/controllers/orders_controller.rb

Overview

OrdersController

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_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from CyberSourceMergedSpec::BaseController

Instance Method Details

#create_order(create_order_request) ⇒ ApiResponse

A create order request enables you to send the itemized details along with the order. This API can be used by merchants initiating their transactions with the create order API. type description here

Parameters:

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
# File 'lib/cyber_source_merged_spec/controllers/orders_controller.rb', line 15

def create_order(create_order_request)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pts/v2/intents',
                                 Server::DEFAULT)
               .body_param(new_parameter(create_order_request)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PtsV2CreateOrderPost201Response.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2CreateOrderPost400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2CreateOrderPost502ResponseException))
    .execute
end

#update_order(id, update_order_request) ⇒ ApiResponse

This API can be used in two flavours - for updating the order as well as saving the order. create order response. type description here

Parameters:

  • id (String)

    Required parameter: The ID returned from the original

  • update_order_request (UpdateOrderRequest)

    Required parameter: TODO:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/cyber_source_merged_spec/controllers/orders_controller.rb', line 45

def update_order(id,
                 update_order_request)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/pts/v2/intents/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .body_param(new_parameter(update_order_request)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PtsV2UpdateOrderPatch201Response.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2UpdateOrderPatch400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2UpdateOrderPatch502ResponseException))
    .execute
end