mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Added with-http-info API methods to Ruby client
to allow accessing response status code and headers, and removed the methods of recording last response info from ApiClient.
This commit is contained in:
parent
d1361ab529
commit
66112d9eb5
@ -17,6 +17,17 @@ module {{moduleName}}
|
||||
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
|
||||
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
|
||||
def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
||||
{{#returnType}}status_code, headers, data = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
|
||||
{{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}}
|
||||
end
|
||||
|
||||
# {{summary}}
|
||||
# {{notes}}
|
||||
{{#allParams}}{{#required}} # @param {{paramName}} {{description}}
|
||||
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
|
||||
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
|
||||
{{/required}}{{/allParams}} # @return [Array<Fixnum, Hash, {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}>] response status code, response headers and {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}
|
||||
def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: {{classname}}#{{operationId}} ..."
|
||||
end
|
||||
@ -63,26 +74,17 @@ module {{moduleName}}
|
||||
{{/bodyParam}}
|
||||
|
||||
auth_names = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
|
||||
{{#returnType}}result = @api_client.call_api(:{{httpMethod}}, path,
|
||||
status_code, headers, data = @api_client.call_api(:{{httpMethod}}, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => '{{{returnType}}}')
|
||||
:auth_names => auth_names{{#returnType}},
|
||||
:return_type => '{{{returnType}}}'{{/returnType}})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: {{classname}}#{{operationId}}. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: {{classname}}#{{operationId}}\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result{{/returnType}}{{^returnType}}@api_client.call_api(:{{httpMethod}}, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: {{classname}}#{{operationId}}"
|
||||
end
|
||||
return nil{{/returnType}}
|
||||
return status_code, headers, data
|
||||
end
|
||||
{{/operation}}
|
||||
end
|
||||
|
@ -15,9 +15,6 @@ module {{moduleName}}
|
||||
# @return [Hash]
|
||||
attr_accessor :default_headers
|
||||
|
||||
# Stores the HTTP response from the last API call using this API client.
|
||||
attr_accessor :last_response
|
||||
|
||||
def initialize(host = nil)
|
||||
@host = host || Configuration.base_url
|
||||
@format = 'json'
|
||||
@ -28,13 +25,12 @@ module {{moduleName}}
|
||||
}
|
||||
end
|
||||
|
||||
# Call an API with given options and an array of 3 elements:
|
||||
# response status code, response headers and the data deserialized from response body (could be nil).
|
||||
def call_api(http_method, path, opts = {})
|
||||
request = build_request(http_method, path, opts)
|
||||
response = request.run
|
||||
|
||||
# record as last response
|
||||
@last_response = response
|
||||
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
||||
end
|
||||
@ -47,10 +43,11 @@ module {{moduleName}}
|
||||
end
|
||||
|
||||
if opts[:return_type]
|
||||
deserialize(response, opts[:return_type])
|
||||
data = deserialize(response, opts[:return_type])
|
||||
else
|
||||
nil
|
||||
data = nil
|
||||
end
|
||||
return response.code, response.headers, data
|
||||
end
|
||||
|
||||
def build_request(http_method, path, opts = {})
|
||||
|
@ -14,6 +14,16 @@ module Petstore
|
||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||
# @return [nil]
|
||||
def update_pet(opts = {})
|
||||
update_pet_with_http_info(opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Update an existing pet
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def update_pet_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: PetApi#update_pet ..."
|
||||
end
|
||||
@ -43,16 +53,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['petstore_auth']
|
||||
@api_client.call_api(:PUT, path,
|
||||
status_code, headers, data = @api_client.call_api(:PUT, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: PetApi#update_pet"
|
||||
Configuration.logger.debug "API called: PetApi#update_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Add a new pet to the store
|
||||
@ -61,6 +71,16 @@ module Petstore
|
||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||
# @return [nil]
|
||||
def add_pet(opts = {})
|
||||
add_pet_with_http_info(opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Add a new pet to the store
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def add_pet_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: PetApi#add_pet ..."
|
||||
end
|
||||
@ -90,16 +110,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['petstore_auth']
|
||||
@api_client.call_api(:POST, path,
|
||||
status_code, headers, data = @api_client.call_api(:POST, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: PetApi#add_pet"
|
||||
Configuration.logger.debug "API called: PetApi#add_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Finds Pets by status
|
||||
@ -108,6 +128,16 @@ module Petstore
|
||||
# @option opts [Array<String>] :status Status values that need to be considered for filter
|
||||
# @return [Array<Pet>]
|
||||
def find_pets_by_status(opts = {})
|
||||
status_code, headers, data = find_pets_by_status_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# Finds Pets by status
|
||||
# Multiple status values can be provided with comma seperated strings
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [Array<String>] :status Status values that need to be considered for filter
|
||||
# @return [Array<Fixnum, Hash, Array<Pet>>] response status code, response headers and Array<Pet> data
|
||||
def find_pets_by_status_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: PetApi#find_pets_by_status ..."
|
||||
end
|
||||
@ -138,7 +168,7 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['petstore_auth']
|
||||
result = @api_client.call_api(:GET, path,
|
||||
status_code, headers, data = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@ -146,9 +176,9 @@ module Petstore
|
||||
:auth_names => auth_names,
|
||||
:return_type => 'Array<Pet>')
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: PetApi#find_pets_by_status. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: PetApi#find_pets_by_status\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Finds Pets by tags
|
||||
@ -157,6 +187,16 @@ module Petstore
|
||||
# @option opts [Array<String>] :tags Tags to filter by
|
||||
# @return [Array<Pet>]
|
||||
def find_pets_by_tags(opts = {})
|
||||
status_code, headers, data = find_pets_by_tags_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# Finds Pets by tags
|
||||
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [Array<String>] :tags Tags to filter by
|
||||
# @return [Array<Fixnum, Hash, Array<Pet>>] response status code, response headers and Array<Pet> data
|
||||
def find_pets_by_tags_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: PetApi#find_pets_by_tags ..."
|
||||
end
|
||||
@ -187,7 +227,7 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['petstore_auth']
|
||||
result = @api_client.call_api(:GET, path,
|
||||
status_code, headers, data = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@ -195,9 +235,9 @@ module Petstore
|
||||
:auth_names => auth_names,
|
||||
:return_type => 'Array<Pet>')
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: PetApi#find_pets_by_tags. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: PetApi#find_pets_by_tags\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Find pet by ID
|
||||
@ -206,6 +246,16 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Pet]
|
||||
def get_pet_by_id(pet_id, opts = {})
|
||||
status_code, headers, data = get_pet_by_id_with_http_info(pet_id, opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# Find pet by ID
|
||||
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
# @param pet_id ID of pet that needs to be fetched
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Fixnum, Hash, Pet>] response status code, response headers and Pet data
|
||||
def get_pet_by_id_with_http_info(pet_id, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: PetApi#get_pet_by_id ..."
|
||||
end
|
||||
@ -238,7 +288,7 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['api_key']
|
||||
result = @api_client.call_api(:GET, path,
|
||||
status_code, headers, data = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@ -246,9 +296,9 @@ module Petstore
|
||||
:auth_names => auth_names,
|
||||
:return_type => 'Pet')
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: PetApi#get_pet_by_id. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: PetApi#get_pet_by_id\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Updates a pet in the store with form data
|
||||
@ -259,6 +309,18 @@ module Petstore
|
||||
# @option opts [String] :status Updated status of the pet
|
||||
# @return [nil]
|
||||
def update_pet_with_form(pet_id, opts = {})
|
||||
update_pet_with_form_with_http_info(pet_id, opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Updates a pet in the store with form data
|
||||
#
|
||||
# @param pet_id ID of pet that needs to be updated
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :name Updated name of the pet
|
||||
# @option opts [String] :status Updated status of the pet
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def update_pet_with_form_with_http_info(pet_id, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: PetApi#update_pet_with_form ..."
|
||||
end
|
||||
@ -293,16 +355,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['petstore_auth']
|
||||
@api_client.call_api(:POST, path,
|
||||
status_code, headers, data = @api_client.call_api(:POST, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: PetApi#update_pet_with_form"
|
||||
Configuration.logger.debug "API called: PetApi#update_pet_with_form\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Deletes a pet
|
||||
@ -312,6 +374,17 @@ module Petstore
|
||||
# @option opts [String] :api_key
|
||||
# @return [nil]
|
||||
def delete_pet(pet_id, opts = {})
|
||||
delete_pet_with_http_info(pet_id, opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Deletes a pet
|
||||
#
|
||||
# @param pet_id Pet id to delete
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :api_key
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def delete_pet_with_http_info(pet_id, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: PetApi#delete_pet ..."
|
||||
end
|
||||
@ -345,16 +418,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['petstore_auth']
|
||||
@api_client.call_api(:DELETE, path,
|
||||
status_code, headers, data = @api_client.call_api(:DELETE, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: PetApi#delete_pet"
|
||||
Configuration.logger.debug "API called: PetApi#delete_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# uploads an image
|
||||
@ -365,6 +438,18 @@ module Petstore
|
||||
# @option opts [File] :file file to upload
|
||||
# @return [nil]
|
||||
def upload_file(pet_id, opts = {})
|
||||
upload_file_with_http_info(pet_id, opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# uploads an image
|
||||
#
|
||||
# @param pet_id ID of pet to update
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :additional_metadata Additional data to pass to server
|
||||
# @option opts [File] :file file to upload
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def upload_file_with_http_info(pet_id, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: PetApi#upload_file ..."
|
||||
end
|
||||
@ -399,16 +484,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['petstore_auth']
|
||||
@api_client.call_api(:POST, path,
|
||||
status_code, headers, data = @api_client.call_api(:POST, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: PetApi#upload_file"
|
||||
Configuration.logger.debug "API called: PetApi#upload_file\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -13,6 +13,15 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Hash<String, Integer>]
|
||||
def get_inventory(opts = {})
|
||||
status_code, headers, data = get_inventory_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# Returns pet inventories by status
|
||||
# Returns a map of status codes to quantities
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Fixnum, Hash, Hash<String, Integer>>] response status code, response headers and Hash<String, Integer> data
|
||||
def get_inventory_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: StoreApi#get_inventory ..."
|
||||
end
|
||||
@ -42,7 +51,7 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = ['api_key']
|
||||
result = @api_client.call_api(:GET, path,
|
||||
status_code, headers, data = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@ -50,9 +59,9 @@ module Petstore
|
||||
:auth_names => auth_names,
|
||||
:return_type => 'Hash<String, Integer>')
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: StoreApi#get_inventory. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: StoreApi#get_inventory\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Place an order for a pet
|
||||
@ -61,6 +70,16 @@ module Petstore
|
||||
# @option opts [Order] :body order placed for purchasing the pet
|
||||
# @return [Order]
|
||||
def place_order(opts = {})
|
||||
status_code, headers, data = place_order_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# Place an order for a pet
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [Order] :body order placed for purchasing the pet
|
||||
# @return [Array<Fixnum, Hash, Order>] response status code, response headers and Order data
|
||||
def place_order_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: StoreApi#place_order ..."
|
||||
end
|
||||
@ -90,7 +109,7 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
result = @api_client.call_api(:POST, path,
|
||||
status_code, headers, data = @api_client.call_api(:POST, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@ -98,9 +117,9 @@ module Petstore
|
||||
:auth_names => auth_names,
|
||||
:return_type => 'Order')
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: StoreApi#place_order. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: StoreApi#place_order\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Find purchase order by ID
|
||||
@ -109,6 +128,16 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Order]
|
||||
def get_order_by_id(order_id, opts = {})
|
||||
status_code, headers, data = get_order_by_id_with_http_info(order_id, opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# Find purchase order by ID
|
||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
# @param order_id ID of pet that needs to be fetched
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Fixnum, Hash, Order>] response status code, response headers and Order data
|
||||
def get_order_by_id_with_http_info(order_id, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: StoreApi#get_order_by_id ..."
|
||||
end
|
||||
@ -141,7 +170,7 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
result = @api_client.call_api(:GET, path,
|
||||
status_code, headers, data = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@ -149,9 +178,9 @@ module Petstore
|
||||
:auth_names => auth_names,
|
||||
:return_type => 'Order')
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: StoreApi#get_order_by_id. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: StoreApi#get_order_by_id\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Delete purchase order by ID
|
||||
@ -160,6 +189,16 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def delete_order(order_id, opts = {})
|
||||
delete_order_with_http_info(order_id, opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Delete purchase order by ID
|
||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
# @param order_id ID of the order that needs to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def delete_order_with_http_info(order_id, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: StoreApi#delete_order ..."
|
||||
end
|
||||
@ -192,16 +231,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
@api_client.call_api(:DELETE, path,
|
||||
status_code, headers, data = @api_client.call_api(:DELETE, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: StoreApi#delete_order"
|
||||
Configuration.logger.debug "API called: StoreApi#delete_order\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -14,6 +14,16 @@ module Petstore
|
||||
# @option opts [User] :body Created user object
|
||||
# @return [nil]
|
||||
def create_user(opts = {})
|
||||
create_user_with_http_info(opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Create user
|
||||
# This can only be done by the logged in user.
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [User] :body Created user object
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def create_user_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: UserApi#create_user ..."
|
||||
end
|
||||
@ -43,16 +53,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
@api_client.call_api(:POST, path,
|
||||
status_code, headers, data = @api_client.call_api(:POST, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: UserApi#create_user"
|
||||
Configuration.logger.debug "API called: UserApi#create_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
@ -61,6 +71,16 @@ module Petstore
|
||||
# @option opts [Array<User>] :body List of user object
|
||||
# @return [nil]
|
||||
def create_users_with_array_input(opts = {})
|
||||
create_users_with_array_input_with_http_info(opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [Array<User>] :body List of user object
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def create_users_with_array_input_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: UserApi#create_users_with_array_input ..."
|
||||
end
|
||||
@ -90,16 +110,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
@api_client.call_api(:POST, path,
|
||||
status_code, headers, data = @api_client.call_api(:POST, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: UserApi#create_users_with_array_input"
|
||||
Configuration.logger.debug "API called: UserApi#create_users_with_array_input\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
@ -108,6 +128,16 @@ module Petstore
|
||||
# @option opts [Array<User>] :body List of user object
|
||||
# @return [nil]
|
||||
def create_users_with_list_input(opts = {})
|
||||
create_users_with_list_input_with_http_info(opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [Array<User>] :body List of user object
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def create_users_with_list_input_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: UserApi#create_users_with_list_input ..."
|
||||
end
|
||||
@ -137,16 +167,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
@api_client.call_api(:POST, path,
|
||||
status_code, headers, data = @api_client.call_api(:POST, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: UserApi#create_users_with_list_input"
|
||||
Configuration.logger.debug "API called: UserApi#create_users_with_list_input\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Logs user into the system
|
||||
@ -156,6 +186,17 @@ module Petstore
|
||||
# @option opts [String] :password The password for login in clear text
|
||||
# @return [String]
|
||||
def login_user(opts = {})
|
||||
status_code, headers, data = login_user_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# Logs user into the system
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :username The user name for login
|
||||
# @option opts [String] :password The password for login in clear text
|
||||
# @return [Array<Fixnum, Hash, String>] response status code, response headers and String data
|
||||
def login_user_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: UserApi#login_user ..."
|
||||
end
|
||||
@ -187,7 +228,7 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
result = @api_client.call_api(:GET, path,
|
||||
status_code, headers, data = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@ -195,9 +236,9 @@ module Petstore
|
||||
:auth_names => auth_names,
|
||||
:return_type => 'String')
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: UserApi#login_user. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: UserApi#login_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Logs out current logged in user session
|
||||
@ -205,6 +246,15 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def logout_user(opts = {})
|
||||
logout_user_with_http_info(opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def logout_user_with_http_info(opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: UserApi#logout_user ..."
|
||||
end
|
||||
@ -234,16 +284,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
@api_client.call_api(:GET, path,
|
||||
status_code, headers, data = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: UserApi#logout_user"
|
||||
Configuration.logger.debug "API called: UserApi#logout_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Get user by user name
|
||||
@ -252,6 +302,16 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [User]
|
||||
def get_user_by_name(username, opts = {})
|
||||
status_code, headers, data = get_user_by_name_with_http_info(username, opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# Get user by user name
|
||||
#
|
||||
# @param username The name that needs to be fetched. Use user1 for testing.
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Fixnum, Hash, User>] response status code, response headers and User data
|
||||
def get_user_by_name_with_http_info(username, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: UserApi#get_user_by_name ..."
|
||||
end
|
||||
@ -284,7 +344,7 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
result = @api_client.call_api(:GET, path,
|
||||
status_code, headers, data = @api_client.call_api(:GET, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
@ -292,9 +352,9 @@ module Petstore
|
||||
:auth_names => auth_names,
|
||||
:return_type => 'User')
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: UserApi#get_user_by_name. Result: #{result.inspect}"
|
||||
Configuration.logger.debug "API called: UserApi#get_user_by_name\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return result
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Updated user
|
||||
@ -304,6 +364,17 @@ module Petstore
|
||||
# @option opts [User] :body Updated user object
|
||||
# @return [nil]
|
||||
def update_user(username, opts = {})
|
||||
update_user_with_http_info(username, opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Updated user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username name that need to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [User] :body Updated user object
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def update_user_with_http_info(username, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: UserApi#update_user ..."
|
||||
end
|
||||
@ -336,16 +407,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
@api_client.call_api(:PUT, path,
|
||||
status_code, headers, data = @api_client.call_api(:PUT, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: UserApi#update_user"
|
||||
Configuration.logger.debug "API called: UserApi#update_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
|
||||
# Delete user
|
||||
@ -354,6 +425,16 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def delete_user(username, opts = {})
|
||||
delete_user_with_http_info(username, opts)
|
||||
return nil
|
||||
end
|
||||
|
||||
# Delete user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username The name that needs to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
|
||||
def delete_user_with_http_info(username, opts = {})
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "Calling API: UserApi#delete_user ..."
|
||||
end
|
||||
@ -386,16 +467,16 @@ module Petstore
|
||||
|
||||
|
||||
auth_names = []
|
||||
@api_client.call_api(:DELETE, path,
|
||||
status_code, headers, data = @api_client.call_api(:DELETE, path,
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names)
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "API called: UserApi#delete_user"
|
||||
Configuration.logger.debug "API called: UserApi#delete_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
|
||||
end
|
||||
return nil
|
||||
return status_code, headers, data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -15,9 +15,6 @@ module Petstore
|
||||
# @return [Hash]
|
||||
attr_accessor :default_headers
|
||||
|
||||
# Stores the HTTP response from the last API call using this API client.
|
||||
attr_accessor :last_response
|
||||
|
||||
def initialize(host = nil)
|
||||
@host = host || Configuration.base_url
|
||||
@format = 'json'
|
||||
@ -28,13 +25,12 @@ module Petstore
|
||||
}
|
||||
end
|
||||
|
||||
# Call an API with given options and an array of 3 elements:
|
||||
# response status code, response headers and the data deserialized from response body (could be nil).
|
||||
def call_api(http_method, path, opts = {})
|
||||
request = build_request(http_method, path, opts)
|
||||
response = request.run
|
||||
|
||||
# record as last response
|
||||
@last_response = response
|
||||
|
||||
if Configuration.debugging
|
||||
Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
||||
end
|
||||
@ -47,10 +43,11 @@ module Petstore
|
||||
end
|
||||
|
||||
if opts[:return_type]
|
||||
deserialize(response, opts[:return_type])
|
||||
data = deserialize(response, opts[:return_type])
|
||||
else
|
||||
nil
|
||||
data = nil
|
||||
end
|
||||
return response.code, response.headers, data
|
||||
end
|
||||
|
||||
def build_request(http_method, path, opts = {})
|
||||
|
@ -50,6 +50,17 @@ describe "Pet" do
|
||||
pet.category.name.should == "category test"
|
||||
end
|
||||
|
||||
it "should fetch a pet object with http info" do
|
||||
status_code, headers, pet = @pet_api.get_pet_by_id_with_http_info(10002)
|
||||
status_code.should == 200
|
||||
headers['Content-Type'].should == 'application/json'
|
||||
pet.should be_a(Petstore::Pet)
|
||||
pet.id.should == 10002
|
||||
pet.name.should == "RUBY UNIT TESTING"
|
||||
pet.tags[0].name.should == "tag test"
|
||||
pet.category.name.should == "category test"
|
||||
end
|
||||
|
||||
it "should not find a pet that does not exist" do
|
||||
begin
|
||||
@pet_api.get_pet_by_id(-10002)
|
||||
|
Loading…
Reference in New Issue
Block a user