feat(config): add ha org slug, ha form name, pk activity name config
This commit is contained in:
parent
40c41fd930
commit
91f74a8a34
2 changed files with 27 additions and 12 deletions
18
.env.example
18
.env.example
|
@ -1,3 +1,17 @@
|
||||||
HELLOASSO_EMAIL=contact@etoiledebethleem.fr
|
HELLOASSO_EMAIL=user@example.org
|
||||||
HELLOASSO_PASSWORD=XXX
|
HELLOASSO_PASSWORD=example
|
||||||
|
|
||||||
|
HELLOASSO_ORGANIZATION_SLUG="my-organization"
|
||||||
|
HELLOASSO_FORM_NAME="2023-2024"
|
||||||
|
|
||||||
|
PAHEKO_BASE_URL=http://paheko.example.org/api/
|
||||||
|
PAHEKO_CLIENT_ID=XXX
|
||||||
|
PAHEKO_CLIENT_SECRET=XXX
|
||||||
|
|
||||||
|
PAHEKO_TARGET_SUBSCRIPTION_NAME="Cotisation 2023-2024"
|
||||||
|
|
||||||
|
PAHEKO_ACCOUNTING_YEAR_ID=1
|
||||||
|
|
||||||
|
PAHEKO_PROXY=http://paheko.example.org
|
||||||
|
HELLOASSO_PROXY=https://localhost:8802
|
||||||
|
|
||||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -18,10 +18,16 @@ struct Config {
|
||||||
helloasso_proxy: Option<String>,
|
helloasso_proxy: Option<String>,
|
||||||
helloasso_email: String,
|
helloasso_email: String,
|
||||||
helloasso_password: String,
|
helloasso_password: String,
|
||||||
|
|
||||||
|
helloasso_organization_slug: String,
|
||||||
|
helloasso_form_name: String,
|
||||||
|
|
||||||
paheko_proxy: Option<String>,
|
paheko_proxy: Option<String>,
|
||||||
paheko_base_url: String,
|
paheko_base_url: String,
|
||||||
paheko_client_id: String,
|
paheko_client_id: String,
|
||||||
paheko_client_secret: String,
|
paheko_client_secret: String,
|
||||||
|
|
||||||
|
paheko_target_activity_name: String,
|
||||||
paheko_accounting_year_id: u64,
|
paheko_accounting_year_id: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,16 +227,11 @@ async fn launch_adapter() -> Result<()> {
|
||||||
email: config.helloasso_email,
|
email: config.helloasso_email,
|
||||||
password: config.helloasso_password
|
password: config.helloasso_password
|
||||||
};
|
};
|
||||||
let auth_client: helloasso::AuthentifiedClient = get_auth_client_from_cache(&mut user_cache, &mut ha_client, login_payload).await?;
|
let auth_client: helloasso::AuthentifiedClient =
|
||||||
|
get_auth_client_from_cache(&mut user_cache, &mut ha_client, login_payload).await?;
|
||||||
|
|
||||||
// FIXME: make it configurable
|
let org = auth_client.organization(&config.helloasso_organization_slug);
|
||||||
let ha_org_slug = "l-etoile-de-bethleem-association-des-amis-de-la-chapelle-de-bethleem-d-aubevoye";
|
let answers = org.get_form_answers(&config.helloasso_form_name).await?;
|
||||||
// FIXME: make it configurable
|
|
||||||
let pk_target_campaign_name = "Cotisation 2023-2024";
|
|
||||||
let ha_form_name = "2023-2024";
|
|
||||||
|
|
||||||
let org: helloasso::Organization = auth_client.organization(ha_org_slug);
|
|
||||||
let answers = org.get_form_answers(ha_form_name).await?;
|
|
||||||
|
|
||||||
// dbg!(&answers);
|
// dbg!(&answers);
|
||||||
println!("Got {} answers to the membership form. Processing...", &answers.len());
|
println!("Got {} answers to the membership form. Processing...", &answers.len());
|
||||||
|
@ -327,7 +328,7 @@ async fn launch_adapter() -> Result<()> {
|
||||||
|
|
||||||
let mut pk_membership = paheko::Membership {
|
let mut pk_membership = paheko::Membership {
|
||||||
id: generate_id(),
|
id: generate_id(),
|
||||||
campaign_name: pk_target_campaign_name.to_string(),
|
campaign_name: config.paheko_target_activity_name.clone(),
|
||||||
// FIXME: handle errors
|
// FIXME: handle errors
|
||||||
mode_name: serde_json::to_value(answer.mode.clone())
|
mode_name: serde_json::to_value(answer.mode.clone())
|
||||||
.unwrap().as_str().unwrap().to_string(),
|
.unwrap().as_str().unwrap().to_string(),
|
||||||
|
|
Loading…
Reference in a new issue