From 320353f50b932591c451f5e8e70ff95749c378bf Mon Sep 17 00:00:00 2001 From: Ryan Ruckley Date: Tue, 21 Jan 2025 08:59:26 +1100 Subject: [PATCH] feat: Add TMF629 module --- src/main.rs | 13 ++++++++++++- src/tmf/mod.rs | 1 + src/tmf/tmf629.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/tmf/tmf629.rs diff --git a/src/main.rs b/src/main.rs index 0cffc10..aea171f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,10 @@ use tmf::tmf632::{ TMF632Modules, handle_tmf632, }; +use tmf::tmf629::{ + TMF629Modules, + handle_tmf629, +}; #[derive(Parser,Debug)] #[command(version, about = "CLI tool for interacting with TMF APIs", author = "Ryan Ruckley")] @@ -50,8 +54,12 @@ pub enum TMFModules { #[command(subcommand, help = "Product Order")] module : TMF622Modules, }, + TMF629 { + #[command(subcommand, help = "Customer")] + module : TMF629Modules, + }, TMF632 { - #[command(subcommand, help = "Party Management")] + #[command(subcommand, help = "Party")] module : TMF632Modules, } } @@ -93,6 +101,9 @@ fn main() -> Result<(),TMFError> { TMFModules::TMF622 { module } => { handle_tmf622(&mut client, module, Some(opts)) }, + TMFModules::TMF629 { module } => { + handle_tmf629(&mut client, module, Some(opts)) + }, TMFModules::TMF632 { module } => { handle_tmf632(&mut client, module, Some(opts)) } diff --git a/src/tmf/mod.rs b/src/tmf/mod.rs index 3ef2e26..d0cdbf0 100644 --- a/src/tmf/mod.rs +++ b/src/tmf/mod.rs @@ -8,6 +8,7 @@ use tmflib::{ pub mod tmf620; pub mod tmf622; +pub mod tmf629; pub mod tmf632; #[derive(Clone, Subcommand, Debug)] diff --git a/src/tmf/tmf629.rs b/src/tmf/tmf629.rs new file mode 100644 index 0000000..ae61c98 --- /dev/null +++ b/src/tmf/tmf629.rs @@ -0,0 +1,41 @@ +//! TMF629 CLI Module + +use clap::Subcommand; + +use super::{ + display_name, iterate_name, TMFOperation +}; + +use tmf_client::common::tmf_error::TMFError; +use tmf_client::{Operations, QueryOptions, TMFClient}; + +#[derive(Subcommand, Clone, Debug)] +pub enum TMF629Modules { + Customer { + #[command(subcommand, help = "Customer")] + op : TMFOperation + }, +} + +pub fn handle_tmf629(client : &mut TMFClient, module : TMF629Modules, opts : Option) -> Result<(),TMFError> { + match module { + TMF629Modules::Customer { op } => { + match op { + TMFOperation::List => { + let customers = client.tmf629().customer().list(opts)?; + iterate_name(&customers); + Ok(()) + }, + TMFOperation::Get { id } => { + let customer = client.tmf629().customer().get(id)?; + let the_first = customer.first().unwrap(); + display_name(the_first); + Ok(()) + } + _ => { + Err(TMFError::from("Not implemented")) + } + } + }, + } +} \ No newline at end of file