summaryrefslogtreecommitdiffstats
path: root/cli/src/api/client.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-04-22 18:48:16 +0200
committerHarald Eilertsen <haraldei@anduin.net>2024-04-22 18:48:16 +0200
commit9c45e4fd70ed83bd2c203da225777ad670c2c15c (patch)
tree7f1be79d99b3e806094fc89622802063b98d7f8e /cli/src/api/client.rs
downloadfaktura-9c45e4fd70ed83bd2c203da225777ad670c2c15c.tar.gz
faktura-9c45e4fd70ed83bd2c203da225777ad670c2c15c.tar.bz2
faktura-9c45e4fd70ed83bd2c203da225777ad670c2c15c.zip
Initial commit
Diffstat (limited to 'cli/src/api/client.rs')
-rw-r--r--cli/src/api/client.rs23
1 files changed, 23 insertions, 0 deletions
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<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()?)
+ }
+}