transdirect/
account.rs

1use serde_derive::{Serialize, Deserialize};
2use restson::{Error as RestsonError,RestPath};
3
4/// Enum describing possible authentication objects
5///
6/// OAuth authentication is not yet supported
7/// 
8/// User-Password Basic authentication is supported, as is
9/// API key authentication
10#[non_exhaustive]
11pub enum AuthenticateWith<'a> {
12    Basic(&'a str, &'a str),
13    APIKey(&'a str),
14}
15
16/// Currently authenticated member
17#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
18pub struct Member {
19    id: u8,
20    company_name: String,
21    postcode: u8,
22    active: bool,
23}
24
25impl RestPath<()> for Member {
26    fn get_path(_: ()) -> Result<String, RestsonError> { Ok(String::from("member")) }
27}
28
29/// A user account (sender or receiver)
30/// 
31/// 
32#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
33pub struct Account {
34    pub address: String,
35    pub email: String,
36    pub name: String,
37    pub postcode: String,
38    pub state: String,
39    pub suburb: String,
40    #[serde(alias = "type")]
41    pub kind: String, // "type" is a keyword
42    pub country: String, // two-letter ISO country code
43    pub company_name: String,
44}