diff --git a/cloudflare-examples/src/main.rs b/cloudflare-examples/src/main.rs index 19d4bac9..a67697fc 100644 --- a/cloudflare-examples/src/main.rs +++ b/cloudflare-examples/src/main.rs @@ -152,6 +152,18 @@ fn list_routes(arg_matches: &ArgMatches, api_client: &HttpApiClient) { print_response_json(response); } +fn account(arg_matches: &ArgMatches, api_client: &HttpApiClient) { + let account_identifier = arg_matches.get_one::("account_identifier"); + let endpoint = account::account_details::AccountDetails { + account_identifier: account_identifier.unwrap(), + }; + if api_client.is_mock() { + add_static_mock(&endpoint); + } + let response = api_client.request(&endpoint); + print_response(response) +} + fn list_accounts(_arg_matches: &ArgMatches, api_client: &HttpApiClient) { let endpoint = account::ListAccounts { params: None }; if api_client.is_mock() { @@ -282,6 +294,14 @@ fn main() -> Result<(), Box> { function: list_routes, }, ), + ( + "account", + Section { + args: vec![Arg::new("account_identifier").required(true)], + description: "Get information about a specific account that you are a member of", + function: account, + }, + ), ( "list_accounts", Section { diff --git a/cloudflare/src/endpoints/account/account_details.rs b/cloudflare/src/endpoints/account/account_details.rs new file mode 100644 index 00000000..7984e7e0 --- /dev/null +++ b/cloudflare/src/endpoints/account/account_details.rs @@ -0,0 +1,19 @@ +use crate::endpoints::account::Account; +use crate::framework::endpoint::{EndpointSpec, Method}; + +/// Account Details +/// +#[derive(Debug)] +pub struct AccountDetails<'a> { + pub account_identifier: &'a str, +} + +impl<'a> EndpointSpec for AccountDetails<'a> { + fn method(&self) -> Method { + Method::GET + } + + fn path(&self) -> String { + format!("accounts/{}", self.account_identifier) + } +} diff --git a/cloudflare/src/endpoints/account/mod.rs b/cloudflare/src/endpoints/account/mod.rs index 2954079c..ea84d47a 100644 --- a/cloudflare/src/endpoints/account/mod.rs +++ b/cloudflare/src/endpoints/account/mod.rs @@ -2,6 +2,7 @@ use crate::framework::response::ApiResult; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; +pub mod account_details; pub mod list_accounts; pub use list_accounts::ListAccounts;