[Rust][reqwest] prefix local variables with "local_var" (#7299)

* use local_var prefix in rust variables

* minor fixes
This commit is contained in:
William Cheng
2020-08-27 11:43:35 +08:00
committed by GitHub
parent 8c1f6fcdc1
commit b4edfe477a
8 changed files with 755 additions and 756 deletions

View File

@@ -91,18 +91,18 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> {
{{/vendorExtensions.x-group-parameters}}
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{#isString}}){{/isString}}{{/pathParams}});
let mut req_builder = client.{{{httpMethod}}}(uri_str.as_str());
let local_var_uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{#isString}}){{/isString}}{{/pathParams}});
let mut local_var_req_builder = local_var_client.{{{httpMethod}}}(local_var_uri_str.as_str());
{{#queryParams}}
{{#required}}
req_builder = req_builder.query(&[("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string())]);
{{/required}}
{{^required}}
if let Some(ref s) = {{{paramName}}} {
req_builder = req_builder.query(&[("{{{baseName}}}", &s{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string())]);
if let Some(ref local_var_str) = {{{paramName}}} {
local_var_req_builder = local_var_req_builder.query(&[("{{{baseName}}}", &local_var_str{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string())]);
}
{{/required}}
{{/queryParams}}
@@ -110,37 +110,37 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{#authMethods}}
{{#isApiKey}}
{{#isKeyInQuery}}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
req_builder = req_builder.query(&[("{{{keyParamName}}}", val)]);
local_var_req_builder = local_var_req_builder.query(&[("{{{keyParamName}}}", local_var_value)]);
}
{{/isKeyInQuery}}
{{/isApiKey}}
{{/authMethods}}
{{/hasAuthMethods}}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
{{#hasHeaderParams}}
{{#headerParams}}
{{#required}}
{{^isNullable}}
req_builder = req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { req_builder = req_builder.header("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); },
None => { req_builder = req_builder.header("{{{baseName}}}", ""); },
Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); },
None => { local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", ""); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
req_builder = req_builder.header("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
if let Some(local_var_param_value) = {{{paramName}}} {
local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
}
{{/required}}
{{/headerParams}}
@@ -149,55 +149,55 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{#authMethods}}
{{#isApiKey}}
{{#isKeyInHeader}}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
req_builder = req_builder.header("{{{keyParamName}}}", val);
local_var_req_builder = local_var_req_builder.header("{{{keyParamName}}}", local_var_value);
};
{{/isKeyInHeader}}
{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}
if let Some(ref auth_conf) = configuration.basic_auth {
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
if let Some(ref local_var_auth_conf) = configuration.basic_auth {
local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
};
{{/isBasicBasic}}
{{#isBasicBearer}}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
{{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
{{/isOAuth}}
{{/authMethods}}
{{/hasAuthMethods}}
{{#isMultipart}}
{{#hasFormParams}}
let mut form = reqwest::multipart::Form::new();
let mut local_var_form = reqwest::multipart::Form::new();
{{#formParams}}
{{#isFile}}
{{^supportAsync}}
{{#required}}
{{^isNullable}}
form = form.file("{{{baseName}}}", {{{paramName}}})?;
local_var_form = local_var_form.file("{{{baseName}}}", {{{paramName}}})?;
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { form = form.file("{{{baseName}}}", param_value)?; },
Some(local_var_param_value) => { local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value)?; },
None => { unimplemented!("Required nullable form file param not supported"); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
form = form.file("{{{baseName}}}", param_value)?;
if let Some(local_var_param_value) = {{{paramName}}} {
local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value)?;
}
{{/required}}
{{/supportAsync}}
@@ -208,99 +208,99 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{^isFile}}
{{#required}}
{{^isNullable}}
form = form.text("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
local_var_form = local_var_form.text("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { form = form.text("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); },
None => { form = form.text("{{{baseName}}}", ""); },
Some(local_var_param_value) => { form = form.text("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); },
None => { local_var_form = local_var_form.text("{{{baseName}}}", ""); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
form = form.text("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
if let Some(local_var_param_value) = {{{paramName}}} {
local_var_form = local_var_form.text("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
}
{{/required}}
{{/isFile}}
{{/formParams}}
req_builder = req_builder.multipart(form);
local_var_req_builder = local_var_req_builder.multipart(local_var_form);
{{/hasFormParams}}
{{/isMultipart}}
{{^isMultipart}}
{{#hasFormParams}}
let mut form_params = std::collections::HashMap::new();
let mut local_var_form_params = std::collections::HashMap::new();
{{#formParams}}
{{#isFile}}
{{#required}}
{{^isNullable}}
form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content"));
local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content"));
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); },
Some(local_var_param_value) => { local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); },
None => { unimplemented!("Required nullable file form param not supported with x-www-form-urlencoded content"); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content"));
if let Some(local_var_param_value) = {{{paramName}}} {
local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content"));
}
{{/required}}
{{/isFile}}
{{^isFile}}
{{#required}}
{{^isNullable}}
form_params.insert("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
local_var_form_params.insert("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { form_params.insert("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); },
None => { form_params.insert("{{{baseName}}}", ""); },
Some(local_var_param_value) => { local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); },
None => { local_var_form_params.insert("{{{baseName}}}", ""); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
form_params.insert("{{{baseName}}}", param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
if let Some(local_var_param_value) = {{{paramName}}} {
local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
}
{{/required}}
{{/isFile}}
{{/formParams}}
req_builder = req_builder.form(&form_params);
local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
{{/hasFormParams}}
{{/isMultipart}}
{{#hasBodyParam}}
{{#bodyParams}}
req_builder = req_builder.json(&{{{paramName}}});
local_var_req_builder = local_var_req_builder.json(&{{{paramName}}});
{{/bodyParams}}
{{/hasBodyParam}}
let req = req_builder.build()?;
let {{^supportAsync}}mut {{/supportAsync}}resp = client.execute(req){{#supportAsync}}.await{{/supportAsync}}?;
let local_var_req = local_var_req_builder.build()?;
let {{^supportAsync}}mut {{/supportAsync}}local_var_resp = local_var_client.execute(local_var_req){{#supportAsync}}.await{{/supportAsync}}?;
let status = resp.status();
let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text(){{#supportAsync}}.await{{/supportAsync}}?;
if status.is_success() {
if local_var_status.is_success() {
{{^supportMultipleResponses}}
{{^returnType}}
Ok(())
{{/returnType}}
{{#returnType}}
serde_json::from_str(&content).map_err(Error::from)
serde_json::from_str(&local_var_content).map_err(Error::from)
{{/returnType}}
{{/supportMultipleResponses}}
{{#supportMultipleResponses}}
let entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
let local_var_entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
{{/supportMultipleResponses}}
} else {
let entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

View File

@@ -1 +0,0 @@
4.0.3-SNAPSHOT

View File

@@ -212,33 +212,33 @@ pub async fn add_pet(configuration: &configuration::Configuration, params: AddPe
let body = params.body;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/pet", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<AddPetSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<AddPetSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<AddPetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -248,35 +248,35 @@ pub async fn delete_pet(configuration: &configuration::Configuration, params: De
let api_key = params.api_key;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut req_builder = client.delete(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(param_value) = api_key {
req_builder = req_builder.header("api_key", param_value.to_string());
if let Some(local_var_param_value) = api_key {
local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<DeletePetSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<DeletePetSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<DeletePetError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<DeletePetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -286,33 +286,33 @@ pub async fn find_pets_by_status(configuration: &configuration::Configuration, p
let status = params.status;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/findByStatus", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/findByStatus", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
req_builder = req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
local_var_req_builder = local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<FindPetsByStatusSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<FindPetsByStatusSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<FindPetsByStatusError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -322,33 +322,33 @@ pub async fn find_pets_by_tags(configuration: &configuration::Configuration, par
let tags = params.tags;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/findByTags", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/findByTags", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
req_builder = req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
local_var_req_builder = local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<FindPetsByTagsSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<FindPetsByTagsSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<FindPetsByTagsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -358,37 +358,37 @@ pub async fn get_pet_by_id(configuration: &configuration::Configuration, params:
let pet_id = params.pet_id;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
req_builder = req_builder.header("api_key", val);
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
};
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<GetPetByIdSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<GetPetByIdSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<GetPetByIdError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -397,33 +397,33 @@ pub async fn update_pet(configuration: &configuration::Configuration, params: Up
let body = params.body;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet", configuration.base_path);
let mut req_builder = client.put(uri_str.as_str());
let local_var_uri_str = format!("{}/pet", configuration.base_path);
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<UpdatePetSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<UpdatePetSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<UpdatePetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -434,40 +434,40 @@ pub async fn update_pet_with_form(configuration: &configuration::Configuration,
let status = params.status;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let mut form_params = std::collections::HashMap::new();
if let Some(param_value) = name {
form_params.insert("name", param_value.to_string());
let mut local_var_form_params = std::collections::HashMap::new();
if let Some(local_var_param_value) = name {
local_var_form_params.insert("name", local_var_param_value.to_string());
}
if let Some(param_value) = status {
form_params.insert("status", param_value.to_string());
if let Some(local_var_param_value) = status {
local_var_form_params.insert("status", local_var_param_value.to_string());
}
req_builder = req_builder.form(&form_params);
local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<UpdatePetWithFormSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<UpdatePetWithFormSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<UpdatePetWithFormError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<UpdatePetWithFormError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -478,38 +478,38 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U
let file = params.file;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let mut form = reqwest::multipart::Form::new();
if let Some(param_value) = additional_metadata {
form = form.text("additionalMetadata", param_value.to_string());
let mut local_var_form = reqwest::multipart::Form::new();
if let Some(local_var_param_value) = additional_metadata {
local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string());
}
// TODO: support file upload for 'file' parameter
req_builder = req_builder.multipart(form);
local_var_req_builder = local_var_req_builder.multipart(local_var_form);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<UploadFileSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<UploadFileSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<UploadFileError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

View File

@@ -107,29 +107,29 @@ pub async fn delete_order(configuration: &configuration::Configuration, params:
let order_id = params.order_id;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id));
let mut req_builder = client.delete(uri_str.as_str());
let local_var_uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id));
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<DeleteOrderSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<DeleteOrderSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<DeleteOrderError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<DeleteOrderError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -138,37 +138,37 @@ pub async fn get_inventory(configuration: &configuration::Configuration) -> Resu
// unbox the parameters
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/store/inventory", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/store/inventory", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
req_builder = req_builder.header("api_key", val);
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
};
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<GetInventorySuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<GetInventorySuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<GetInventoryError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -178,29 +178,29 @@ pub async fn get_order_by_id(configuration: &configuration::Configuration, param
let order_id = params.order_id;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<GetOrderByIdSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<GetOrderByIdSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<GetOrderByIdError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -209,30 +209,30 @@ pub async fn place_order(configuration: &configuration::Configuration, params: P
let body = params.body;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/store/order", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/store/order", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<PlaceOrderSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<PlaceOrderSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<PlaceOrderError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

View File

@@ -200,30 +200,30 @@ pub async fn create_user(configuration: &configuration::Configuration, params: C
let body = params.body;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/user", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<CreateUserSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<CreateUserSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<CreateUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<CreateUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -232,30 +232,30 @@ pub async fn create_users_with_array_input(configuration: &configuration::Config
let body = params.body;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/createWithArray", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/user/createWithArray", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<CreateUsersWithArrayInputSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<CreateUsersWithArrayInputSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -264,30 +264,30 @@ pub async fn create_users_with_list_input(configuration: &configuration::Configu
let body = params.body;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/createWithList", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/user/createWithList", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<CreateUsersWithListInputSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<CreateUsersWithListInputSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -297,29 +297,29 @@ pub async fn delete_user(configuration: &configuration::Configuration, params: D
let username = params.username;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut req_builder = client.delete(uri_str.as_str());
let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<DeleteUserSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<DeleteUserSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<DeleteUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<DeleteUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -328,29 +328,29 @@ pub async fn get_user_by_name(configuration: &configuration::Configuration, para
let username = params.username;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<GetUserByNameSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<GetUserByNameSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<GetUserByNameError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -360,31 +360,31 @@ pub async fn login_user(configuration: &configuration::Configuration, params: Lo
let password = params.password;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/login", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/user/login", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
req_builder = req_builder.query(&[("username", &username.to_string())]);
req_builder = req_builder.query(&[("password", &password.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]);
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<LoginUserSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<LoginUserSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<LoginUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -392,29 +392,29 @@ pub async fn logout_user(configuration: &configuration::Configuration) -> Result
// unbox the parameters
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/logout", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/user/logout", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<LogoutUserSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<LogoutUserSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<LogoutUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<LogoutUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
@@ -425,30 +425,30 @@ pub async fn update_user(configuration: &configuration::Configuration, params: U
let body = params.body;
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut req_builder = client.put(uri_str.as_str());
let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let resp = client.execute(req).await?;
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let status = resp.status();
let content = resp.text().await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if status.is_success() {
let entity: Option<UpdateUserSuccess> = serde_json::from_str(&content).ok();
let result = ResponseContent { status, content, entity };
Ok(result)
if local_var_status.is_success() {
let local_var_entity: Option<UpdateUserSuccess> = serde_json::from_str(&local_var_content).ok();
let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Ok(local_var_result)
} else {
let entity: Option<UpdateUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<UpdateUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

View File

@@ -84,264 +84,264 @@ pub enum UploadFileError {
pub fn add_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error<AddPetError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/pet", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<AddPetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error<DeletePetError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut req_builder = client.delete(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(param_value) = api_key {
req_builder = req_builder.header("api_key", param_value.to_string());
if let Some(local_var_param_value) = api_key {
local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<DeletePetError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<DeletePetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Multiple status values can be provided with comma separated strings
pub fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByStatusError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/findByStatus", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/findByStatus", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
req_builder = req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
local_var_req_builder = local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<FindPetsByStatusError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error<FindPetsByTagsError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/findByTags", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/findByTags", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
req_builder = req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
local_var_req_builder = local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<FindPetsByTagsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Returns a single pet
pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result<crate::models::Pet, Error<GetPetByIdError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
req_builder = req_builder.header("api_key", val);
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
};
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<GetPetByIdError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn update_pet(configuration: &configuration::Configuration, body: crate::models::Pet) -> Result<(), Error<UpdatePetError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet", configuration.base_path);
let mut req_builder = client.put(uri_str.as_str());
let local_var_uri_str = format!("{}/pet", configuration.base_path);
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<UpdatePetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error<UpdatePetWithFormError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let mut form_params = std::collections::HashMap::new();
if let Some(param_value) = name {
form_params.insert("name", param_value.to_string());
let mut local_var_form_params = std::collections::HashMap::new();
if let Some(local_var_param_value) = name {
local_var_form_params.insert("name", local_var_param_value.to_string());
}
if let Some(param_value) = status {
form_params.insert("status", param_value.to_string());
if let Some(local_var_param_value) = status {
local_var_form_params.insert("status", local_var_param_value.to_string());
}
req_builder = req_builder.form(&form_params);
local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<UpdatePetWithFormError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<UpdatePetWithFormError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option<std::path::PathBuf>) -> Result<crate::models::ApiResponse, Error<UploadFileError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
if let Some(ref local_var_token) = configuration.oauth_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let mut form = reqwest::multipart::Form::new();
if let Some(param_value) = additional_metadata {
form = form.text("additionalMetadata", param_value.to_string());
let mut local_var_form = reqwest::multipart::Form::new();
if let Some(local_var_param_value) = additional_metadata {
local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string());
}
if let Some(param_value) = file {
form = form.file("file", param_value)?;
if let Some(local_var_param_value) = file {
local_var_form = local_var_form.file("file", local_var_param_value)?;
}
req_builder = req_builder.multipart(form);
local_var_req_builder = local_var_req_builder.multipart(local_var_form);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<UploadFileError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

View File

@@ -52,116 +52,116 @@ pub enum PlaceOrderError {
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
pub fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<DeleteOrderError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id));
let mut req_builder = client.delete(uri_str.as_str());
let local_var_uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id));
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<DeleteOrderError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<DeleteOrderError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Returns a map of status codes to quantities
pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<::std::collections::HashMap<String, i32>, Error<GetInventoryError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/store/inventory", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/store/inventory", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
if let Some(ref local_var_apikey) = configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
req_builder = req_builder.header("api_key", val);
local_var_req_builder = local_var_req_builder.header("api_key", local_var_value);
};
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<GetInventoryError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result<crate::models::Order, Error<GetOrderByIdError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<GetOrderByIdError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn place_order(configuration: &configuration::Configuration, body: crate::models::Order) -> Result<crate::models::Order, Error<PlaceOrderError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/store/order", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/store/order", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<PlaceOrderError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

View File

@@ -86,217 +86,217 @@ pub enum UpdateUserError {
/// This can only be done by the logged in user.
pub fn create_user(configuration: &configuration::Configuration, body: crate::models::User) -> Result<(), Error<CreateUserError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/user", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<CreateUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<CreateUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn create_users_with_array_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithArrayInputError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/createWithArray", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/user/createWithArray", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<CreateUsersWithArrayInputError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn create_users_with_list_input(configuration: &configuration::Configuration, body: Vec<crate::models::User>) -> Result<(), Error<CreateUsersWithListInputError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/createWithList", configuration.base_path);
let mut req_builder = client.post(uri_str.as_str());
let local_var_uri_str = format!("{}/user/createWithList", configuration.base_path);
let mut local_var_req_builder = local_var_client.post(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<CreateUsersWithListInputError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// This can only be done by the logged in user.
pub fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error<DeleteUserError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut req_builder = client.delete(uri_str.as_str());
let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut local_var_req_builder = local_var_client.delete(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<DeleteUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<DeleteUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result<crate::models::User, Error<GetUserByNameError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<GetUserByNameError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result<String, Error<LoginUserError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/login", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/user/login", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
req_builder = req_builder.query(&[("username", &username.to_string())]);
req_builder = req_builder.query(&[("password", &password.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]);
local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]);
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
serde_json::from_str(&content).map_err(Error::from)
if local_var_status.is_success() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<LoginUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error<LogoutUserError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/logout", configuration.base_path);
let mut req_builder = client.get(uri_str.as_str());
let local_var_uri_str = format!("{}/user/logout", configuration.base_path);
let mut local_var_req_builder = local_var_client.get(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<LogoutUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<LogoutUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// This can only be done by the logged in user.
pub fn update_user(configuration: &configuration::Configuration, username: &str, body: crate::models::User) -> Result<(), Error<UpdateUserError>> {
let client = &configuration.client;
let local_var_client = &configuration.client;
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut req_builder = client.put(uri_str.as_str());
let local_var_uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
let mut local_var_req_builder = local_var_client.put(local_var_uri_str.as_str());
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
if let Some(ref local_var_user_agent) = configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
req_builder = req_builder.json(&body);
local_var_req_builder = local_var_req_builder.json(&body);
let req = req_builder.build()?;
let mut resp = client.execute(req)?;
let local_var_req = local_var_req_builder.build()?;
let mut local_var_resp = local_var_client.execute(local_var_req)?;
let status = resp.status();
let content = resp.text()?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text()?;
if status.is_success() {
if local_var_status.is_success() {
Ok(())
} else {
let entity: Option<UpdateUserError> = serde_json::from_str(&content).ok();
let error = ResponseContent { status, content, entity };
Err(Error::ResponseError(error))
let local_var_entity: Option<UpdateUserError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}