lisk_api_rust_client/api/
transactions.rs

1use http::client::Client;
2use std::borrow::Borrow;
3use std::collections::HashMap;
4
5use api::models::Transaction;
6use api::Result;
7
8pub struct Transactions {
9    client: Client,
10}
11
12impl Transactions {
13    pub fn new(client: Client) -> Transactions {
14        Transactions { client }
15    }
16
17    pub fn all(&self) -> Result<Vec<Transaction>> {
18        self.all_params(Vec::<(String, String)>::new())
19    }
20
21    pub fn all_params<I, K, V>(&self, parameters: I) -> Result<Vec<Transaction>>
22    where
23        I: IntoIterator,
24        I::Item: Borrow<(K, V)>,
25        K: AsRef<str>,
26        V: AsRef<str>,
27    {
28        self.client.get_with_params("transactions", parameters)
29    }
30
31    pub fn create(&self, transactions: Vec<&str>) -> Result<Transaction> {
32        let mut payload = HashMap::<&str, Vec<&str>>::new();
33        payload.insert("transactions", transactions);
34
35        self.client.post("transactions", Some(payload))
36    }
37}