Skip to content

Commit

Permalink
feat: Add TMF629 module
Browse files Browse the repository at this point in the history
  • Loading branch information
rruckley committed Jan 20, 2025
1 parent 921205d commit 320353f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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))
}
Expand Down
1 change: 1 addition & 0 deletions src/tmf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use tmflib::{

pub mod tmf620;
pub mod tmf622;
pub mod tmf629;
pub mod tmf632;

#[derive(Clone, Subcommand, Debug)]
Expand Down
41 changes: 41 additions & 0 deletions src/tmf/tmf629.rs
Original file line number Diff line number Diff line change
@@ -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<QueryOptions>) -> 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"))
}
}
},
}
}

0 comments on commit 320353f

Please sign in to comment.