Extract constructor
This commit is contained in:
parent
f8046e4cd2
commit
499f60266a
|
@ -86,20 +86,22 @@ pub fn create_method_with_params(
|
||||||
let send_builder =
|
let send_builder =
|
||||||
MethodBuilder::new(&util::to_ident("send"), url, quote! { self.group.auth }).with_form();
|
MethodBuilder::new(&util::to_ident("send"), url, quote! { self.group.auth }).with_form();
|
||||||
|
|
||||||
|
let send_new_method = quote! {
|
||||||
|
fn new(group: &'a #group_name, #(#mandatory_param_args),*) -> Self {
|
||||||
|
let form = reqwest::multipart::Form::new();
|
||||||
|
#(#mandatory_param_form_build)*
|
||||||
|
Self { group, form }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let send = match create_return_type(group, method) {
|
let send = match create_return_type(group, method) {
|
||||||
Some((return_type_name, return_type)) => {
|
Some((return_type_name, return_type)) => {
|
||||||
let send_method = send_builder.return_type(&return_type_name).build();
|
let send_method = send_builder.return_type(&return_type_name).build();
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
impl<'a> #parameter_type<'a> {
|
impl<'a> #parameter_type<'a> {
|
||||||
fn new(group: &'a #group_name, #(#mandatory_param_args),*) -> Self {
|
#send_new_method
|
||||||
let form = reqwest::multipart::Form::new();
|
|
||||||
#(#mandatory_param_form_build)*
|
|
||||||
Self { group, form }
|
|
||||||
}
|
|
||||||
|
|
||||||
#(#optional_params)*
|
#(#optional_params)*
|
||||||
|
|
||||||
#send_method
|
#send_method
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,14 +113,8 @@ pub fn create_method_with_params(
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
impl<'a> #parameter_type<'a> {
|
impl<'a> #parameter_type<'a> {
|
||||||
fn new(group: &'a #group_name, #(#mandatory_param_args),*) -> Self {
|
#send_new_method
|
||||||
let form = reqwest::multipart::Form::new();
|
|
||||||
#(#mandatory_param_form_build)*
|
|
||||||
Self { group, form }
|
|
||||||
}
|
|
||||||
|
|
||||||
#(#optional_params)*
|
#(#optional_params)*
|
||||||
|
|
||||||
#send_method
|
#send_method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user