arkecosystem_client/api/
mod.rs1pub mod blocks;
2pub mod delegates;
3pub mod models;
4pub mod node;
5pub mod peers;
6pub mod transactions;
7pub mod votes;
8pub mod wallets;
9
10use self::blocks::Blocks;
11use self::delegates::Delegates;
12use self::models::Response;
13use self::node::Node;
14use self::peers::Peers;
15use self::transactions::Transactions;
16use self::votes::Votes;
17use self::wallets::Wallets;
18
19use super::error::Error;
20use http::client::Client;
21
22pub type Result<T> = std::result::Result<Response<T>, Error>;
23
24pub struct Api {
25 pub blocks: Blocks,
26 pub delegates: Delegates,
27 pub node: Node,
28 pub peers: Peers,
29 pub transactions: Transactions,
30 pub votes: Votes,
31 pub wallets: Wallets,
32 pub client: Client,
33}
34
35impl Api {
36 fn version() -> &'static str {
37 "2"
38 }
39
40 pub fn new(host: &str) -> Api {
41 Api::new_with_client(&Client::new(host))
42 }
43
44 pub fn new_with_client(client: &Client) -> Api {
45 let mut client = client.clone();
46 client.set_version(&Api::version());
47
48 Api {
49 blocks: Blocks::new(client.clone()),
50 delegates: Delegates::new(client.clone()),
51 node: Node::new(client.clone()),
52 peers: Peers::new(client.clone()),
53 transactions: Transactions::new(client.clone()),
54 votes: Votes::new(client.clone()),
55 wallets: Wallets::new(client.clone()),
56 client,
57 }
58 }
59}