Skip to content

Commit

Permalink
Merge pull request #11 from rruckley/feat-module-tmf648
Browse files Browse the repository at this point in the history
feat: Module tmf648
  • Loading branch information
rruckley authored Jan 21, 2025
2 parents 6e7b3c6 + b5e9166 commit b865006
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
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"))
}
}
},
}
}

0 comments on commit b865006

Please sign in to comment.