Skip to content

Commit

Permalink
Add generate-invoice and sync-unpaid-invoices command
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Jan 15, 2025
1 parent a573a81 commit 82cebfe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/command/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,24 @@ pub fn remove_admin_action(args: &RemoveAdminActionArgs) -> Result<()> {
)?
.print()
}

#[derive(Args)]
pub struct GenerateInvoiceArgs {
pub amount_sats: i64,
pub description: String,
}

pub fn generate_invoice(args: &GenerateInvoiceArgs) -> Result<()> {
rpc::call(
"generate_invoice",
json!({"amount_sats": args.amount_sats, "description": args.description}),
)?
.print()
}

#[derive(Args)]
pub struct SyncUnpaidInvoicesArgs {}

pub fn sync_unpaid_invoices(args: &SyncUnpaidInvoicesArgs) -> Result<()> {
rpc::call("sync_unpaid_invoices", json!({}))?.print()
}
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ enum Commands {
AddAdminAction(command::admin::AddAdminActionArgs),
/// Block other admin from using a certain action. You must be super admin to use this command
RemoveAdminAction(command::admin::RemoveAdminActionArgs),
/// Generate invoice
GenerateInvoice(command::admin::GenerateInvoiceArgs),
/// Sync unpaid invoices
SyncUnpaidInvoices(command::admin::SyncUnpaidInvoicesArgs),
/// Return all entities matching provided search query. Currently, only areas are returned
Search(command::common::SearchArgs),
/// Fetch element by a numeric or OSM (node:12345) id. You can also use node=12345 format
Expand Down Expand Up @@ -117,6 +121,8 @@ fn main() -> Result<()> {
Commands::AddAdmin(args) => command::admin::add_admin(args),
Commands::AddAdminAction(args) => command::admin::add_admin_action(args),
Commands::RemoveAdminAction(args) => command::admin::remove_admin_action(args),
Commands::GenerateInvoice(args) => command::admin::generate_invoice(args),
Commands::SyncUnpaidInvoices(args) => command::admin::sync_unpaid_invoices(args),
// Common
Commands::Search(args) => command::common::search(args),
// Element
Expand Down

0 comments on commit 82cebfe

Please sign in to comment.