Class: SwaggerPetstore::UserController

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

Overview

UserController

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

#create_user(body) ⇒ void

This method returns an undefined value.

This can only be done by the logged in user.

Parameters:

  • body (UserRequest)

    Required parameter: Created user object



130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/swagger_petstore/controllers/user_controller.rb', line 130

def create_user(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/user',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
               .is_response_void(true))
    .execute
end

#create_users_with_array_input(body) ⇒ void

This method returns an undefined value.

Creates list of users with given input array

Parameters:

  • body (Array[User])

    Required parameter: List of user object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/swagger_petstore/controllers/user_controller.rb', line 12

def create_users_with_array_input(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/user/createWithArray',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
               .is_response_void(true))
    .execute
end

#create_users_with_list_input(body) ⇒ void

This method returns an undefined value.

Creates list of users with given input array

Parameters:

  • body (Array[User])

    Required parameter: List of user object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/swagger_petstore/controllers/user_controller.rb', line 55

def create_users_with_list_input(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/user/createWithList',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
               .is_response_void(true))
    .execute
end

#delete_user(username) ⇒ void

This method returns an undefined value.

This can only be done by the logged in user. deleted

Parameters:

  • username (String)

    Required parameter: The name that needs to be



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/swagger_petstore/controllers/user_controller.rb', line 147

def delete_user(username)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/user/{username}',
                                 Server::DEFAULT)
               .template_param(new_parameter(username, key: 'username')
                                .should_encode(true)))
    .response(new_response_handler
               .is_response_void(true)
               .local_error('400',
                            'Invalid username supplied',
                            APIException)
               .local_error('404',
                            'User not found',
                            APIException))
    .execute
end

#get_user_by_name(username) ⇒ User

Get user by user name fetched. Use user1 for testing.

Parameters:

  • username (String)

    Required parameter: The name that needs to be

Returns:

  • (User)

    response from the API call



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

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

#login_user(username, password) ⇒ String

Logs user into the system clear text

Parameters:

  • username (String)

    Required parameter: The user name for login

  • password (String)

    Required parameter: The password for login in

Returns:

  • (String)

    response from the API call



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/swagger_petstore/controllers/user_controller.rb', line 85

def (username,
               password)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/user/login',
                                 Server::DEFAULT)
               .query_param(new_parameter(username, key: 'username'))
               .query_param(new_parameter(password, key: 'password')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:deserialize_primitive_types))
               .deserialize_into(proc do |response| response.to_s end)
               .is_primitive_response(true)
               .local_error('400',
                            'Invalid username/password supplied',
                            APIException))
    .execute
end

#logout_uservoid

This method returns an undefined value.

Logs out current logged in user session



70
71
72
73
74
75
76
77
78
# File 'lib/swagger_petstore/controllers/user_controller.rb', line 70

def logout_user
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/user/logout',
                                 Server::DEFAULT))
    .response(new_response_handler
               .is_response_void(true))
    .execute
end

#update_user(username, body) ⇒ void

This method returns an undefined value.

This can only be done by the logged in user. updated

Parameters:

  • username (String)

    Required parameter: name that need to be

  • body (UserRequest)

    Required parameter: Updated user object



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

def update_user(username,
                body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/user/{username}',
                                 Server::DEFAULT)
               .template_param(new_parameter(username, key: 'username')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
               .is_response_void(true)
               .local_error('400',
                            'Invalid user supplied',
                            APIException)
               .local_error('404',
                            'User not found',
                            APIException))
    .execute
end