Skip to content

Commit

Permalink
Add new paywall commands
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Jan 25, 2025
1 parent 2373386 commit d907042
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/command/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ pub fn add_element_comment(args: &AddElementCommentArgs) -> Result<()> {
.print()
}

#[derive(Args)]
pub struct AddPaidElementCommentArgs {
pub id: String,
pub comment: String,
}

pub fn add_paid_element_comment(args: &AddPaidElementCommentArgs) -> Result<()> {
rpc::call(
"add_paid_element_comment",
json!({"element_id": args.id,"comment": args.comment}),
)?
.print()
}

#[derive(Args)]
pub struct BoostElementArgs {
pub id: String,
Expand Down
1 change: 1 addition & 0 deletions src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod admin;
pub mod area;
pub mod common;
pub mod element;
pub mod paywall;
pub mod report;
pub mod setup;
pub mod user;
39 changes: 39 additions & 0 deletions src/command/paywall.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use crate::{rpc, Result};
use clap::Args;
use serde_json::json;

pub fn paywall_get_add_element_comment_quote() -> Result<()> {
rpc::call("paywall_get_add_element_comment_quote", json!({}))?.print()
}

#[derive(Args)]
pub struct PaywallAddElementCommentArgs {
pub element_id: String,
pub comment: String,
}

pub fn paywall_add_element_comment(args: &PaywallAddElementCommentArgs) -> Result<()> {
rpc::call(
"paywall_add_element_comment",
json!({"element_id": args.element_id,"comment": args.comment}),
)?
.print()
}

pub fn paywall_get_boost_element_quote() -> Result<()> {
rpc::call("paywall_get_boost_element_quote", json!({}))?.print()
}

#[derive(Args)]
pub struct PaywallBoostElementArgs {
pub element_id: String,
pub days: i64,
}

pub fn paywall_boost_element(args: &PaywallBoostElementArgs) -> Result<()> {
rpc::call(
"paywall_boost_element",
json!({"element_id": args.element_id, "days": args.days}),
)?
.print()
}

0 comments on commit d907042

Please sign in to comment.