Class: SwaggerPetstore::StoreController

Inherits:
BaseController show all
Defined in:
lib/swagger_petstore/controllers/store_controller.rb

Overview

StoreController

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 SwaggerPetstore::BaseController

Instance Method Details

#delete_order(order_id) ⇒ void

This method returns an undefined value.

For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors to be deleted

Parameters:

  • order_id (Integer)

    Required parameter: ID of the order that needs



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/swagger_petstore/controllers/store_controller.rb', line 76

def delete_order(order_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/store/order/{orderId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(order_id, key: 'orderId')
                                .should_encode(true)))
    .response(new_response_handler
               .is_response_void(true)
               .local_error('400',
                            'Invalid ID supplied',
                            APIException)
               .local_error('404',
                            'Order not found',
                            APIException))
    .execute
end

#get_inventoryHash[String, Integer]

Returns a map of status codes to quantities

Returns:

  • (Hash[String, Integer])

    response from the API call



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/swagger_petstore/controllers/store_controller.rb', line 58

def get_inventory
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/store/inventory',
                                 Server::DEFAULT)
               .auth(Single.new('api_key')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_i end)
               .is_primitive_response(true))
    .execute
end

#get_order_by_id(order_id) ⇒ Order

For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions fetched

Parameters:

  • order_id (Integer)

    Required parameter: ID of pet that needs to be

Returns:

  • (Order)

    response from the API call



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/swagger_petstore/controllers/store_controller.rb', line 14

def get_order_by_id(order_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/store/order/{orderId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(order_id, key: 'orderId')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Order.method(:from_hash))
               .local_error('400',
                            'Invalid ID supplied',
                            APIException)
               .local_error('404',
                            'Order not found',
                            APIException))
    .execute
end

#place_order(body) ⇒ Order

Place an order for a pet purchasing the pet

Parameters:

Returns:

  • (Order)

    response from the API call



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/swagger_petstore/controllers/store_controller.rb', line 38

def place_order(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/store/order',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .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(Order.method(:from_hash))
               .local_error('400',
                            'Invalid Order',
                            APIException))
    .execute
end