Skip to content

Commit

Permalink
fail early payment creation if there any of the required arguments ar…
Browse files Browse the repository at this point in the history
…e missing
  • Loading branch information
pgoodjohn committed Dec 12, 2023
1 parent 868dad7 commit 8254759
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions crates/mollie_cli/src/payments/create.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::config::MollieConfig;
use colored::Colorize;
use crate::{config::MollieConfig, payments::create};
use log::{debug, info, warn};
use mollie_api::Mollie;
use requestty::Question;
Expand Down Expand Up @@ -39,8 +38,14 @@ pub async fn command(
ask_confirmation();
}

let token = config.bearer_token()?;
debug!("{:?}", create_payment_request);

if with_request {
let pretty_json = jsonxf::pretty_print(&serde_json::to_string(&create_payment_request).unwrap()).unwrap();
info!("{}", pretty_json.to_colored_json_auto().unwrap());
}

let token = config.bearer_token()?;
let response = Mollie::build(&token.as_str())
.payments()
.create_payment(&create_payment_request)
Expand Down
10 changes: 5 additions & 5 deletions crates/mollie_cli/src/payments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ pub enum PaymentsCommands {
#[clap(short, long)]
interactive: bool,

#[clap(long)]
#[clap(long, required_unless_present("interactive"))]
currency: Option<String>,

#[clap(long)]
#[clap(long, required_unless_present("interactive"))]
amount: Option<String>,

#[clap(long)]
#[clap(long, required_unless_present("interactive"))]
description: Option<String>,

#[clap(long)]
#[clap(long, required_unless_present("interactive"))]
redirect_url: Option<String>,

#[clap(long)]
#[clap(long, required_unless_present("interactive"))]
profile_id: Option<String>,

#[clap(long = "withRequest", global = true)]
Expand Down

0 comments on commit 8254759

Please sign in to comment.