From 9c45e4fd70ed83bd2c203da225777ad670c2c15c Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 22 Apr 2024 18:48:16 +0200 Subject: Initial commit --- cli/src/api/client.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 cli/src/api/client.rs (limited to 'cli/src/api/client.rs') diff --git a/cli/src/api/client.rs b/cli/src/api/client.rs new file mode 100644 index 0000000..4e6a2b0 --- /dev/null +++ b/cli/src/api/client.rs @@ -0,0 +1,23 @@ + +use serde::Deserialize; +use std::error::Error; + +#[derive(Debug, Deserialize)] +pub struct Client { + pub id: u32, + pub name: String, + pub contact: Option, + pub address: Option, + pub email: String, + pub phone: Option, + pub vat: bool, +} + +impl Client { + pub fn all() -> Result, Box> { + Ok(ureq::get("http://faktura.ddev.site/api/clients") + .set("Accept", "application/json") + .call()? + .into_json()?) + } +} -- cgit v1.2.3