diff --git a/.env.example b/.env.example index 9f156ac..d9d3c80 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,17 @@ -HELLOASSO_EMAIL=contact@etoiledebethleem.fr -HELLOASSO_PASSWORD=XXX +HELLOASSO_EMAIL=user@example.org +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 diff --git a/src/main.rs b/src/main.rs index 2b2c824..d8bf772 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,10 +18,16 @@ struct Config { helloasso_proxy: Option, helloasso_email: String, helloasso_password: String, + + helloasso_organization_slug: String, + helloasso_form_name: String, + paheko_proxy: Option, paheko_base_url: String, paheko_client_id: String, paheko_client_secret: String, + + paheko_target_activity_name: String, paheko_accounting_year_id: u64, } @@ -221,16 +227,11 @@ async fn launch_adapter() -> Result<()> { email: config.helloasso_email, 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 ha_org_slug = "l-etoile-de-bethleem-association-des-amis-de-la-chapelle-de-bethleem-d-aubevoye"; - // 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?; + let org = auth_client.organization(&config.helloasso_organization_slug); + let answers = org.get_form_answers(&config.helloasso_form_name).await?; // dbg!(&answers); 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 { id: generate_id(), - campaign_name: pk_target_campaign_name.to_string(), + campaign_name: config.paheko_target_activity_name.clone(), // FIXME: handle errors mode_name: serde_json::to_value(answer.mode.clone()) .unwrap().as_str().unwrap().to_string(),