// SPDX-FileCopyrightText: 2024 Eilertsens Kodeknekkeri // SPDX-FileCopyrightText: 2024 Harald Eilertsen // // SPDX-License-Identifier: AGPL-3.0-or-later use serde::{Deserialize, Serialize}; use std::error::Error; use super::Connection; #[derive(Debug, Default, Deserialize, Serialize)] pub struct Client { #[serde(default)] pub id: u32, pub name: String, pub contact: Option, pub address: Option, pub email: String, pub phone: Option, #[serde(default)] pub vat: bool, } impl Client { pub fn all(conn: Connection) -> Result, Box> { Ok(conn.get("clients")?) } pub fn save(&self, conn: Connection) -> Result<(), Box> { let resp = conn.post("clients", &self)?; println!("{}", resp); Ok(()) } }