diff --git a/README.md b/README.md index f2528b8..70fa726 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,10 @@ assert_eq!(res.unwrap(), [Price { internalid: "24".into(), unitprice: "95.49".in Get all prices via SuiteQL. ```bash -export ACCOUNT_ID=<6 chars>; +export ACCOUNT=<6 chars>; export CONSUMER_KEY=<64 chars>; export CONSUMER_SECRET=<64 chars>; -export TOKEN_KEY=<64 chars>; +export TOKEN_ID=<64 chars>; export TOKEN_SECRET=<64 chars>; netsuite suiteql 'SELECT * FROM pricing' ``` diff --git a/src/cli.rs b/src/cli.rs index b08f127..ff55e68 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -7,13 +7,13 @@ use clap::Parser; #[clap(name = "netsuite", version = "abc123")] struct Opts { #[clap(short, long, env)] - account_id: String, + account: String, #[clap(short = 'c', long, env)] consumer_key: String, #[clap(short = 'C', long, env)] consumer_secret: String, #[clap(short = 't', long, env)] - token_key: String, + token_id: String, #[clap(short = 'T', long, env)] token_secret: String, #[clap(subcommand)] @@ -36,17 +36,17 @@ enum SubCommand { pub fn run() -> Result<(), Error> { env_logger::init(); - let opts = Opts::parse(); + let cli_opts = Opts::parse(); let config = Config::new( - &opts.account_id, - &opts.consumer_key, - &opts.consumer_secret, - &opts.token_key, - &opts.token_secret, + &cli_opts.account, + &cli_opts.consumer_key, + &cli_opts.consumer_secret, + &cli_opts.token_id, + &cli_opts.token_secret, ); let api = RestApi::new(&config); - match &opts.subcmd { + match &cli_opts.subcmd { SubCommand::SuiteQl { query, limit, diff --git a/src/config.rs b/src/config.rs index 8678b24..9727a1f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,23 +1,23 @@ use crate::oauth1; pub struct Config<'a> { - pub account_id: &'a str, + pub account: &'a str, pub consumer: oauth1::Token<'a>, pub token: oauth1::Token<'a>, } impl<'a> Config<'a> { pub fn new( - account_id: &'a str, + account: &'a str, consumer_key: &'a str, consumer_secret: &'a str, - token_key: &'a str, + token_id: &'a str, token_secret: &'a str, ) -> Self { Self { - account_id, + account, consumer: oauth1::Token::new(consumer_key, consumer_secret), - token: oauth1::Token::new(token_key, token_secret), + token: oauth1::Token::new(token_id, token_secret), } } } diff --git a/src/requester.rs b/src/requester.rs index 25362bb..f55e388 100644 --- a/src/requester.rs +++ b/src/requester.rs @@ -26,7 +26,7 @@ impl<'a> Requester<'a> { &self.config.consumer, Some(&self.config.token), params.clone().map(|p| p.into()), - Some(self.config.account_id), + Some(self.config.account), ) } diff --git a/src/rest_api.rs b/src/rest_api.rs index 242204d..a0867ad 100644 --- a/src/rest_api.rs +++ b/src/rest_api.rs @@ -10,7 +10,7 @@ pub struct RestApi<'a> { impl<'a> RestApi<'a> { pub fn new(config: &'a Config) -> Self { - let base_url = DEFAULT_BASE_URL.replace("{}", config.account_id); + let base_url = DEFAULT_BASE_URL.replace("{}", config.account); let requester = Requester::new(config, base_url); let suiteql = SuiteQl::new(requester); Self { suiteql }