From b5e9166f09dff17a60f44b49630d5e463a3bfaf9 Mon Sep 17 00:00:00 2001 From: Ryan Ruckley Date: Tue, 21 Jan 2025 11:27:09 +1100 Subject: [PATCH] feat: Module tmf648 --- src/main.rs | 11 +++++++++++ src/tmf/mod.rs | 1 + src/tmf/tmf648.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/tmf/tmf648.rs diff --git a/src/main.rs b/src/main.rs index aea171f..8c29be1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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")] @@ -61,6 +65,10 @@ pub enum TMFModules { TMF632 { #[command(subcommand, help = "Party")] module : TMF632Modules, + }, + TMF648 { + #[command(subcommand, help = "Product Quote")] + module : TMF648Modules, } } @@ -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)) } } } \ No newline at end of file diff --git a/src/tmf/mod.rs b/src/tmf/mod.rs index d0cdbf0..8a2260a 100644 --- a/src/tmf/mod.rs +++ b/src/tmf/mod.rs @@ -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 { diff --git a/src/tmf/tmf648.rs b/src/tmf/tmf648.rs new file mode 100644 index 0000000..a63eeb9 --- /dev/null +++ b/src/tmf/tmf648.rs @@ -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) -> Result<(),TMFError> { + match module { + TMF648Modules::Quote { op } => { + match op { + TMFOperation::List => { + let quotes = client.tmf648().quote().list(opts)?; + iterate_name("es); + 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")) + } + } + }, + } +} \ No newline at end of file