shuttle-sdk 0.1.0

Stellar Horizon Server client.
Documentation
#![deny(warnings)]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]

//! # shuttle-sdk
//!
//! The `shuttle-sdk` crate provides a way to communicate with a
//! [Stellar Horizon Server](https://github.com/stellar/go/tree/master/services/horizon).
//!
//! It provides a way to submit requests to the Horizon instance, and to build,
//! sign, and submit transactions to the network.
//!
//! ## Example Usage
//!
//! ### Create and fund a new account
//!
//! ```rust
//! # use shuttle_sdk::Result;
//! use shuttle_sdk::{KeyPair, Server};
//!
//! const TESTNET_URL: &'static str = "https://horizon-testnet.stellar.org";
//!
//! # fn run() -> Result<()> {
//! let keypair = KeyPair::random()?;
//! let account_id = keypair.public_key();
//!
//! let server = Server::new(TESTNET_URL)?;
//! let response = server.friendbot(&account_id)?.send()?;
//! println!("response = {:?}", response);
//! # Ok(())
//! # }
//! ```
//!
//! ### Get a list of available assets
//!
//! ```rust
//! # use shuttle_sdk::Result;
//! use shuttle_sdk::{KeyPair, Server};
//!
//! const TESTNET_URL: &'static str = "https://horizon-testnet.stellar.org";
//!
//! # fn run() -> Result<()> {
//! let keypair = KeyPair::random()?;
//! let account_id = keypair.public_key();
//!
//! let server = Server::new(TESTNET_URL)?;
//! let response = server.assets().for_code("MOBI").send()?;
//! println!("response = {:?}", response);
//! # Ok(())
//! # }
//! ```
//!
//!
//! ### Create and Submit transaction
//!
//! ```rust
//! # use shuttle_sdk::Result;
//! use std::str::FromStr;
//! use shuttle_sdk::{Account, KeyPair, Network, Server};
//! use shuttle_sdk::{Amount, OperationBuilder, TransactionBuilder};
//!
//! const TESTNET_URL: &'static str = "https://horizon-testnet.stellar.org";
//!
//! # fn run() -> Result<()> {
//! let keypair = KeyPair::random()?;
//! let account_id = keypair.public_key();
//! let new_keypair = KeyPair::random()?;
//!
//! let server = Server::new(TESTNET_URL)?;
//! let network = Network::test_network();
//!
//! let account_details = server.accounts().account_id(&account_id)?.send()?;
//! let mut account = Account::new(account_id.clone(), account_details.sequence);
//! let tx = TransactionBuilder::new(&mut account)
//!     .operation(
//!         OperationBuilder::create_account(
//!             new_keypair.public_key().clone(),
//!             Amount::from_str("20.0")?,
//!         ).build(),
//!     ).build();
//! let signed_tx = tx.sign(&keypair, &network)?;
//! let response = server.submit_transaction(&signed_tx)?.send()?;
//! println!("response = {:?}", response);
//! # Ok(())
//! # }
//! ```

extern crate reqwest;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate shuttle_core;

mod error;
mod client;
mod deserialize;
mod server;
mod request;
mod pagination;

mod link;
mod accounts;
mod assets;
mod effects;
mod ledgers;
mod offers;
mod operations;
mod orderbook;
mod paths;
mod payments;
mod trade_aggregations;
mod trades;
mod submit_transaction;
mod transactions;
mod friendbot;

pub use self::error::{Error, Result};
pub use self::server::Server;

pub use self::friendbot::{FriendbotRequest, FriendbotResponse};

// re-export shuttle_core structs
pub use shuttle_core::{KeyPair, PublicKey, SecretKey, SignedTransaction};
pub use shuttle_core::{Operation, OperationBuilder, Transaction, TransactionBuilder};
pub use shuttle_core::{Account, Amount, Network};