blob: 4e6a2b04f085a17387d95bfe33a35028ea160c7b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
use serde::Deserialize;
use std::error::Error;
#[derive(Debug, Deserialize)]
pub struct Client {
pub id: u32,
pub name: String,
pub contact: Option<String>,
pub address: Option<String>,
pub email: String,
pub phone: Option<String>,
pub vat: bool,
}
impl Client {
pub fn all() -> Result<Vec<Self>, Box<dyn Error>> {
Ok(ureq::get("http://faktura.ddev.site/api/clients")
.set("Accept", "application/json")
.call()?
.into_json()?)
}
}
|