Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Module tmf648 #11

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ use tmf::tmf629::{
TMF629Modules,
handle_tmf629,
};
use tmf::tmf648::{
TMF648Modules,
handle_tmf648,
};

#[derive(Parser,Debug)]
#[command(version, about = "CLI tool for interacting with TMF APIs", author = "Ryan Ruckley")]
Expand Down Expand Up @@ -61,6 +65,10 @@ pub enum TMFModules {
TMF632 {
#[command(subcommand, help = "Party")]
module : TMF632Modules,
},
TMF648 {
#[command(subcommand, help = "Product Quote")]
module : TMF648Modules,
}
}

Expand Down Expand Up @@ -106,6 +114,9 @@ fn main() -> Result<(),TMFError> {
},
TMFModules::TMF632 { module } => {
handle_tmf632(&mut client, module, Some(opts))
},
TMFModules::TMF648 { module } => {
handle_tmf648(&mut client, module, Some(opts))
}
}
}
1 change: 1 addition & 0 deletions src/tmf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod tmf620;
pub mod tmf622;
pub mod tmf629;
pub mod tmf632;
pub mod tmf648;

#[derive(Clone, Subcommand, Debug)]
pub enum TMFOperation {
Expand Down
49 changes: 49 additions & 0 deletions src/tmf/tmf648.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! TMF648 CLI Module

//! TMF629 CLI Module

use clap::Subcommand;

use super::{
display_desc,
display_opt,
iterate_name,
TMFOperation
};

use tmf_client::common::tmf_error::TMFError;
use tmf_client::{Operations, QueryOptions, TMFClient};

#[derive(Subcommand, Clone, Debug)]
pub enum TMF648Modules {
Quote {
#[command(subcommand, help = "Product Quote")]
op : TMFOperation
},
}

pub fn handle_tmf648(client : &mut TMFClient, module : TMF648Modules, opts : Option<QueryOptions>) -> Result<(),TMFError> {
match module {
TMF648Modules::Quote { op } => {
match op {
TMFOperation::List => {
let quotes = client.tmf648().quote().list(opts)?;
iterate_name(&quotes);
Ok(())
},
TMFOperation::Get { id } => {
let quote = client.tmf648().quote().get(id)?;
let the_first = quote.first().unwrap();
display_desc(the_first);
display_opt("Category",&the_first.category);
display_opt("Version",&the_first.version);
// display_opt("External Id",&the_f)
Ok(())
}
_ => {
Err(TMFError::from("Not implemented"))
}
}
},
}
}
Loading