Class: NewStoreApi::OrdersController

Inherits:
BaseController show all
Defined in:
lib/new_store_api/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

Constructor Details

This class inherits a constructor from NewStoreApi::BaseController

Instance Method Details

#create_order(request_id, tenant, x_newstore_tenant, body) ⇒ Object

TODO: type endpoint description here here description here can be found [here](https://gitlab.com/newstore/engineering/order-management/order-mana gement/-/blob/main/services/sales_order/definitions/schemas/add_sales_orde r_items.json). The same schema is used for AddSalesOrderItemsJSON gRPC call.

Parameters:

  • request_id (String)

    Required parameter: TODO: type description

  • tenant (String)

    Required parameter: TODO: type description here

  • x_newstore_tenant (String)

    Required parameter: TODO: type

  • body (Object)

    Required parameter: The schema for the request body

Returns:

  • (Object)

    Response from the API call.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/new_store_api/controllers/orders_controller.rb', line 107

def create_order(request_id,
                 tenant,
                 x_newstore_tenant,
                 body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/order-management/orders',
                                 Server::API)
               .header_param(new_parameter(request_id, key: 'Request-Id'))
               .header_param(new_parameter(tenant, key: 'Tenant'))
               .header_param(new_parameter(x_newstore_tenant, key: 'X-Newstore-Tenant'))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(APIHelper.method(:json_serialize))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize)))
    .execute
end

#show_order(order_id, state: nil, transaction_state: nil) ⇒ SignatureResponseV1Dto

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Get fiscal transactions and signatures for an order (sale or exchange). This API should be used to get the fiscal transaction for returned items that were part of an exchange. Based on the country, the transactions array in the response for exchanges will contain one of the following: * 1 `exchange` transaction that represents both the returned and the sold part of the exchanged items. * 2 transactions, 1 `sale` transactions and `return` transaction each representing their respective parts of the exchanged items. description here type description here

Parameters:

  • order_id (String)

    Required parameter: TODO: type description here

  • state (OrderManagementStateEnum) (defaults to: nil)

    Optional parameter: TODO: type

  • transaction_state (TransactionStateEnum) (defaults to: nil)

    Optional parameter: TODO:

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/new_store_api/controllers/orders_controller.rb', line 33

def show_order(order_id,
               state: nil,
               transaction_state: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/orders/{orderId}',
                                 Server::API)
               .template_param(new_parameter(order_id, key: 'orderId')
                                .should_encode(true))
               .query_param(new_parameter(state, key: 'state'))
               .query_param(new_parameter(transaction_state, key: 'transaction_state'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SignatureResponseV1Dto.method(:from_hash)))
    .execute
end

#show_return(order_id, return_id, state: nil, transaction_state: nil) ⇒ SignatureResponseV1Dto

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Get fiscal transactions and signatures for an item return. This API covers returns that are not part of an exchange. For getting the return part of the exchange use the GET `/orders/orderId` API here description here type description here

Parameters:

  • order_id (String)

    Required parameter: TODO: type description here

  • return_id (String)

    Required parameter: TODO: type description

  • state (OrderManagementStateEnum) (defaults to: nil)

    Optional parameter: TODO: type

  • transaction_state (TransactionStateEnum) (defaults to: nil)

    Optional parameter: TODO:

Returns:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/new_store_api/controllers/orders_controller.rb', line 72

def show_return(order_id,
                return_id,
                state: nil,
                transaction_state: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/orders/{orderId}/returns/{returnId}',
                                 Server::API)
               .template_param(new_parameter(order_id, key: 'orderId')
                                .should_encode(true))
               .template_param(new_parameter(return_id, key: 'returnId')
                                .should_encode(true))
               .query_param(new_parameter(state, key: 'state'))
               .query_param(new_parameter(transaction_state, key: 'transaction_state'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SignatureResponseV1Dto.method(:from_hash)))
    .execute
end