helloasso-paheko-adapter/src/paheko.rs

62 lines
1.4 KiB
Rust

use anyhow::{Context, Result, anyhow};
use url::Url;
use serde::{Serialize, Deserialize};
use fully_pub::fully_pub;
use crate::utils::Id;
use chrono::prelude::{NaiveDate, DateTime, Utc, Datelike};
#[derive(Debug, Serialize, Deserialize, Clone)]
#[fully_pub]
struct HelloassoReferences {
answer_id: u64,
order_id: u64
// payment_id: u64,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[fully_pub]
struct ExternalReferences {
helloasso_ref: HelloassoReferences
}
/// for now we include the custom fields into the paheko user
/// we don't have time to implement user settings to change the custom fields mapping
/// for now, manual mapping
#[derive(Debug, Serialize, Deserialize, Clone)]
#[fully_pub]
struct User {
id: Id,
first_name: String,
last_name: String,
email: Option<String>,
phone: Option<String>,
address: String,
city: String,
postal_code: String,
country: String,
skills: Option<String>,
job: Option<String>,
birthday: Option<u32>,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[fully_pub]
enum MembershipMode {
Individual,
Couple,
BenefactorIndividual,
BenefactorCouple,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[fully_pub]
struct Membership {
id: Id,
users: Vec<Id>,
campaign: String,
mode: MembershipMode,
inception_datum: DateTime<Utc>,
external_references: ExternalReferences
}