Skip to content

Commit

Permalink
Merge pull request #8 from rruckley/feat-module-tmf632-3
Browse files Browse the repository at this point in the history
feat: New Module TMF632
  • Loading branch information
rruckley authored Jan 20, 2025
2 parents 8d1a40c + aeb0a3e commit 921205d
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions individual
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"685a88ff2be142b89fcabd0ec553c758","href":"/tmf-api/partyManagement/v4/individual/685a88ff2be142b89fcabd0ec553c758","familyName":"Citizen","fullName":"John Quarry Citizen","gender":"Male","givenName":"John","legalName":"John Quarry Citizen","middleName":"Quarry","preferredGivenName":"John","title":"Master","contactMedium":[{"characteristic":{"contactType":"email","emailAddress":"[email protected]","phoneNumber":null},"mediumType":"email","preferred":false}],"relatedParty":[],"partyCharacteristic":[{"name":"code","nameType":"String","value":"I-MVSQUG","baseType":null,"schemaLocation":null,"@type":null},{"name":"hash","nameType":"String","value":"MVSQUGDVWWBSOKBELSPVYISDSRRRR7YSGJ2DXVLJFJCWA7I5S5MQ","baseType":null,"schemaLocation":null,"@type":null}]}]
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ use tmf::tmf622::{
TMF622Modules,
handle_tmf622,
};
use tmf::tmf632::{
TMF632Modules,
handle_tmf632,
};

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

Expand Down Expand Up @@ -85,5 +93,8 @@ fn main() -> Result<(),TMFError> {
TMFModules::TMF622 { module } => {
handle_tmf622(&mut client, module, Some(opts))
},
TMFModules::TMF632 { module } => {
handle_tmf632(&mut client, module, Some(opts))
}
}
}
8 changes: 8 additions & 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 tmf632;

#[derive(Clone, Subcommand, Debug)]
pub enum TMFOperation {
Expand Down Expand Up @@ -46,4 +47,11 @@ pub fn display_name<T: HasId + HasName>(item : &T) {
pub fn display_desc<T : HasId + HasDescription>(item : &T) {
display_id(item);
println!("Desc:\t{}",item.get_description());
}

pub fn display_opt(label : &str, field : &Option<String>) {
match field {
Some(v) => println!("{}:\t{}",label,v),
None => println!("{}:\tNot Set",label),
}
}
72 changes: 72 additions & 0 deletions src/tmf/tmf632.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//! TMF632 CLI Module
use clap::Subcommand;

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

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

#[derive(Subcommand, Clone, Debug)]
pub enum TMF632Modules {
Individual {
#[command(subcommand, help = "Operations on Individuals")]
op : TMFOperation
},
Organization {
#[command(subcommand, help = "Organization Operations")]
op : TMFOperation
},
}

pub fn handle_tmf632(client : &mut TMFClient, module : TMF632Modules, opts : Option<QueryOptions>) -> Result<(),TMFError> {
match module {
TMF632Modules::Individual { op } => {
match op {
TMFOperation::List => {
let individuals = client.tmf632().individual().list(opts)?;
iterate_name(&individuals);
Ok(())
},
TMFOperation::Get { id } => {
let individual = client.tmf632().individual().get(id)?;
let the_first = individual.first().unwrap();
display_name(the_first);
display_opt("DOB", &the_first.birth_date);
display_opt("Title", &the_first.title);
display_opt("Gender", &the_first.gender);
display_opt("email:",&the_first.get_email());
// display_opt("Code", &the_first.c);
display_opt("Mobile", &the_first.get_mobile());
Ok(())
}
_ => {
Err(TMFError::from("Not implemented"))
}
}
},
TMF632Modules::Organization { op } => {
match op {
TMFOperation::List => {
let organization = client.tmf632().organization().list(opts)?;
iterate_name(&organization);
Ok(())
},
TMFOperation::Get { id } => {
let organization = client.tmf632().organization().get(id)?;
let the_first = organization.first().unwrap();
display_name(the_first);
display_opt("Trading Name",&the_first.trading_name);
display_opt("Org. Type", &the_first.organization_type);
// display_opt("Status", &the_first.status);
Ok(())
}
_ => {
Err(TMFError::from("Not implemented"))
}
}
}
}
}

0 comments on commit 921205d

Please sign in to comment.