use shuttle_core::PublicKey;
use error::Result;
use client::{self, InnerClient};
use link::Link;
#[derive(Debug, Clone)]
pub struct FriendbotRequest {
client: InnerClient,
account_id: String,
}
impl FriendbotRequest {
pub fn new(client: InnerClient, public_key: &PublicKey) -> Result<FriendbotRequest> {
let account_id = public_key.account_id()?;
Ok(FriendbotRequest { client, account_id })
}
pub fn send(&self) -> Result<FriendbotResponse> {
client::parse_response(&mut self.client
.get(&["friendbot"])?
.query(&[("addr", &self.account_id)])
.send()?)
}
}
#[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,
}
#[derive(Debug, Clone, Deserialize)]
pub struct FriendbotLinks {
transaction: Link,
}