shuttle-sdk 0.1.0

Stellar Horizon Server client.
Documentation
use shuttle_core::PublicKey;
use error::Result;
use client::{self, InnerClient};
use link::Link;

/// Request to fund a new account.
#[derive(Debug, Clone)]
pub struct FriendbotRequest {
    client: InnerClient,
    account_id: String,
}

impl FriendbotRequest {
    /// Create a new `FriendbotRequest`.
    pub fn new(client: InnerClient, public_key: &PublicKey) -> Result<FriendbotRequest> {
        let account_id = public_key.account_id()?;
        Ok(FriendbotRequest { client, account_id })
    }

    /// Send the request to the server.
    pub fn send(&self) -> Result<FriendbotResponse> {
        client::parse_response(&mut self.client
            .get(&["friendbot"])?
            .query(&[("addr", &self.account_id)])
            .send()?)
    }
}

/// Response to a `FriendbotRequest`.
#[derive(Debug, Clone, Deserialize)]
pub struct FriendbotResponse {
    #[serde(rename = "_links")] links: FriendbotLinks,
    hash: String,
    ledger: u64,
    envelope_xdr: String,
    result_xdr: String,
    result_meta_xdr: String,
}

/// Links for `FriendbotResponse`.
#[derive(Debug, Clone, Deserialize)]
pub struct FriendbotLinks {
    transaction: Link,
}