-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): add email and billing management to CLI (#155)
Introduced commands for setting email and enabling billing. Updated GraphQL schema to support these actions.
- Loading branch information
Showing
6 changed files
with
544 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use anyhow::Result; | ||
use clap::Args; | ||
use slot::graphql::auth::{update_me::*, UpdateMe}; | ||
use slot::graphql::GraphQLQuery; | ||
use slot::{api::Client, credential::Credentials}; | ||
|
||
#[derive(Debug, Args)] | ||
#[command(next_help_heading = "Set billing options")] | ||
pub struct BillingArgs { | ||
#[arg(help = "Enable slot billing for the authenticated user.")] | ||
#[clap(long, short, action)] | ||
pub enabled: bool, | ||
} | ||
|
||
impl BillingArgs { | ||
pub async fn run(&self) -> Result<()> { | ||
let credentials = Credentials::load()?; | ||
let client = Client::new_with_token(credentials.access_token); | ||
|
||
let request_body = UpdateMe::build_query(Variables { | ||
email: None, | ||
slot_billing: Some(self.enabled), | ||
}); | ||
let res: ResponseData = client.query(&request_body).await?; | ||
print!("{:?}", res); | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use anyhow::Result; | ||
use clap::Args; | ||
use slot::graphql::auth::{update_me::*, UpdateMe}; | ||
use slot::graphql::GraphQLQuery; | ||
use slot::{api::Client, credential::Credentials}; | ||
|
||
#[derive(Debug, Args)] | ||
#[command(next_help_heading = "Set email options")] | ||
pub struct EmailArgs { | ||
#[arg(help = "The email address of the user.")] | ||
pub email: String, | ||
} | ||
|
||
impl EmailArgs { | ||
pub async fn run(&self) -> Result<()> { | ||
let credentials = Credentials::load()?; | ||
let client = Client::new_with_token(credentials.access_token); | ||
|
||
let request_body = UpdateMe::build_query(Variables { | ||
email: Some(self.email.clone()), | ||
slot_billing: None, | ||
}); | ||
let res: ResponseData = client.query(&request_body).await?; | ||
print!("{:?}", res); | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.