Class: NewStoreApi::OrderPlacementController

Inherits:
BaseController show all
Defined in:
lib/new_store_api/controllers/order_placement_controller.rb

Overview

OrderPlacementController

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

Constructor Details

This class inherits a constructor from NewStoreApi::BaseController

Instance Method Details

#create_order_placement(idempotency_key, body, x_newstore_request_id: nil) ⇒ OrderResponse

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Place an order for processing in the NewStore platform. A successful response means the order has been accepted; payment capture, receipt generation, and downstream processing complete asynchronously. used to make order placement safe to retry. caller-provided request correlation identifier. Generated by the service when omitted.

Parameters:

  • idempotency_key (String)

    Required parameter: Caller-provided key

  • body (OrderRequest)

    Required parameter: The order to place.

  • x_newstore_request_id (String) (defaults to: nil)

    Optional parameter: Optional

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/new_store_api/controllers/order_placement_controller.rb', line 28

def create_order_placement(idempotency_key,
                           body,
                           x_newstore_request_id: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/orders',
                                 Server::API)
               .header_param(new_parameter(idempotency_key, key: 'idempotency-key'))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter(x_newstore_request_id, key: 'x-newstore-request-id'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(OrderResponse.method(:from_hash)))
    .execute
end