Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for effects endpoint #86

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions stellar_rust_sdk/src/effects/all_effects_request.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{models::*, BuildQueryParametersExt, Paginatable};
use stellar_rust_sdk_derive::Pagination;

/// Represents a request to fetch effect data from the Stellar Horizon API.
///
/// `AllEffectsRequest` is a struct used to construct queries for retrieving information about effects
Expand Down Expand Up @@ -31,11 +32,9 @@ pub struct AllEffectsRequest {
/// A pointer to a specific location in a collection of responses, derived from the
/// `paging_token` value of a record. Used for pagination control in the API response.
cursor: Option<u32>,

/// Specifies the maximum number of records to be returned in a single response.
/// The range for this parameter is from 1 to 200. The default value is set to 10.
limit: Option<u8>,

/// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending)
/// and [`Order::Desc`] (descending). If not specified, it defaults to ascending.
order: Option<Order>,
Expand Down Expand Up @@ -89,4 +88,4 @@ mod tests {

assert!(request.is_err());
}
}
}
3 changes: 0 additions & 3 deletions stellar_rust_sdk/src/effects/effects_for_account_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@ use stellar_rust_sdk_derive::Pagination;
pub struct EffectsForAccountRequest {
/// The accounts public id
account_id: Option<String>,

/// A pointer to a specific location in a collection of responses, derived from the
/// `paging_token` value of a record. Used for pagination control in the API response.
cursor: Option<u32>,

/// Specifies the maximum number of records to be returned in a single response.
/// The range for this parameter is from 1 to 200. The default value is set to 10.
limit: Option<u8>,

/// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending)
/// and [`Order::Desc`] (descending). If not specified, it defaults to ascending.
order: Option<Order>,
Expand Down
3 changes: 0 additions & 3 deletions stellar_rust_sdk/src/effects/effects_for_ledger_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@ use stellar_rust_sdk_derive::Pagination;
pub struct EffectsForLedgerRequest {
/// The ledger's sequence number for which effects are to be retrieved.
sequence: Option<u32>,

/// A pointer to a specific location in a collection of responses, derived from the
/// `paging_token` value of a record. Used for pagination control in the API response.
cursor: Option<u32>,

/// Specifies the maximum number of records to be returned in a single response.
/// The range for this parameter is from 1 to 200. The default value is set to 10.
limit: Option<u8>,

/// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending)
/// and [`Order::Desc`] (descending). If not specified, it defaults to ascending.
order: Option<Order>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@ use stellar_rust_sdk_derive::Pagination;
pub struct EffectsForLiquidityPoolRequest {
/// The liquidity pool id
liquidity_pool_id: Option<String>,

/// A pointer to a specific location in a collection of responses, derived from the
/// `paging_token` value of a record. Used for pagination control in the API response.
cursor: Option<u32>,

/// Specifies the maximum number of records to be returned in a single response.
/// The range for this parameter is from 1 to 200. The default value is set to 10.
limit: Option<u8>,

/// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending)
/// and [`Order::Desc`] (descending). If not specified, it defaults to ascending.
order: Option<Order>,
Expand Down
3 changes: 0 additions & 3 deletions stellar_rust_sdk/src/effects/effects_for_operation_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,12 @@ use stellar_rust_sdk_derive::Pagination;
pub struct EffectsForOperationRequest {
/// The operation id to filter effects.
operation_id: Option<String>,

/// A pointer to a specific location in a collection of responses, derived from the
/// `paging_token` value of a record. Used for pagination control in the API response.
cursor: Option<u32>,

/// Specifies the maximum number of records to be returned in a single response.
/// The range for this parameter is from 1 to 200. The default value is set to 10.
limit: Option<u8>,

/// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending)
/// and [`Order::Desc`] (descending). If not specified, it defaults to ascending.
order: Option<Order>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ use stellar_rust_sdk_derive::Pagination;
pub struct EffectForTransactionRequest {
/// The transaction hash of the transaction of the effect
transaction_hash: Option<String>,

/// A pointer to a specific location in a collection of responses, derived from the
/// `paging_token` value of a record. Used for pagination control in the API response.
cursor: Option<u32>,

/// Specifies the maximum number of records to be returned in a single response.
/// The range for this parameter is from 1 to 200. The default value is set to 10.
limit: Option<u8>,

/// Determines the [`Order`] of the records in the response. Valid options are [`Order::Asc`] (ascending)
/// and [`Order::Desc`] (descending). If not specified, it defaults to ascending.
order: Option<Order>,
Expand Down
98 changes: 98 additions & 0 deletions stellar_rust_sdk/src/effects/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,111 @@
/// Provides the `AllEffectsRequest` struct.
///
/// This module contains the `AllEffectsRequest` struct, which is designed to create requests
/// for querying comprehensive lists of effects from the Horizon server.
///
/// The `AllEffectsRequest` struct is meant to be used in conjunction with the [`HorizonClient`](crate::horizon_client::HorizonClient)
/// to perform the actual API calls and fetch asset data. It adheres to the structure
/// and requirements of the Horizon API for asset queries.
///
pub mod all_effects_request;

/// Provides the `EffectsForAccountRequest`.
///
/// This module provides the `EffectsForAccountRequest` struct, specifically designed for
/// constructing requests to query information about effects of a specific account from the Horizon
/// server. It is tailored for use with the [`HorizonClient::get_effects_for_account`](crate::horizon_client::HorizonClient::get_effects_for_account)
/// method.
///
pub mod effects_for_account_request;

/// Provides the `EffectsForLedgerRequest`.
///
/// This module provides the `EffectsForLedgerRequest` struct, specifically designed for
/// constructing requests to query information about effects of a ledger from the Horizon
/// server. It is tailored for use with the [`HorizonClient::get_effects_for_ledger`](crate::horizon_client::HorizonClient::get_effects_for_ledger)
/// method.
///
pub mod effects_for_ledger_request;

/// Provides the `EffectsForLiquidityPoolRequest`.
///
/// This module provides the `EffectsForLiquidityPoolRequest` struct, specifically designed for
/// constructing requests to query information about effects referencing a given liquidity pool from the Horizon
/// server. It is tailored for use with the [`HorizonClient::get_effects_for_liquidity_pools`](crate::horizon_client::HorizonClient::get_effects_for_liquidity_pools)
/// method.
///
pub mod effects_for_liquidity_pools_request;

/// Provides the `EffectsForOperationRequest`.
///
/// This module provides the `EffectsForOperationRequest` struct, specifically designed for
/// constructing requests to query information about effects of a specific operation from the Horizon
/// server. It is tailored for use with the [`HorizonClient::get_effects_for_operation`](crate::horizon_client::HorizonClient::get_effects_for_operation)
/// method.
///
pub mod effects_for_operation_request;

/// Provides the `EffectsForTransactionRequest`.
///
/// This module provides the `EffectsForTransactionRequest` struct, specifically designed for
/// constructing requests to query information about effects of a specific transaction from the Horizon
/// server. It is tailored for use with the [`HorizonClient::get_effects_for_transaction`](crate::horizon_client::HorizonClient::get_effects_for_transaction)
/// method.
///
pub mod effects_for_transaction_request;

/// Provides the responses.
///
/// This module defines structures representing the response from the Horizon API when querying
/// for effects. The structures are designed to deserialize the JSON response into Rust
/// objects, enabling straightforward access to various details of a single Stellar account.
///
/// These structures are equipped with serialization capabilities to handle the JSON data from the
/// Horizon server and with getter methods for easy field access.
///
pub mod response;

/// The base path for effect-related endpoints in the Horizon API.
///
/// # Usage
/// This variable is intended to be used internally by the request-building logic
/// to ensure consistent and accurate path construction for effect-related API calls.
///
static EFFECTS_PATH: &str = "effects";

/// The `prelude` module of the `effects` module.
///
/// This module serves as a convenience for users of the Horizon Rust SDK, allowing for easy and
/// ergonomic import of the most commonly used items across various modules. It re-exports
/// key structs and traits from the sibling modules, simplifying access to these components
/// when using the library.
///
/// By importing the contents of `prelude`, users can conveniently access the primary
/// functionalities of the effect-related modules without needing to import each item
/// individually.
///
/// # Contents
///
/// The `prelude` includes the following re-exports:
///
/// * From `all_effects_request`: All items (e.g. `AllEffectsRequest`).
/// * From `effects_for_account_request`: All items (e.g. `EffectsForAccountRequest`).
/// * From `effects_for_ledger_request`: All items (e.g. `EffectsForLedgerRequest`).
/// * From `effects_for_liquidity_pools_request`: All items (e.g. `EffectsForLiquidityPoolRequest`).
/// * From `effects_for_operation_request`: All items (e.g. `EffectsForOperationRequest`).
/// * From `effects_for_transaction_request`: All items (e.g. `EffectForTransactionRequest`).
/// * From `response`: All items (e.g. `EffectsResponse`, `Effect`, `EffectLink`).
///
/// # Example
/// ```
/// # use crate::stellar_rs::models::*;
/// // Import the contents of the effects prelude.
/// use stellar_rs::effects::prelude::*;
///
/// // Now you can directly use AllEffectsRequest, EffectsForAccountRequest, etc.
/// let all_effects_request = AllEffectsRequest::new();
/// ```
///
pub mod prelude {
pub use super::all_effects_request::*;
pub use super::effects_for_account_request::*;
Expand Down
6 changes: 3 additions & 3 deletions stellar_rust_sdk/src/offers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ pub mod test {
const BUYING_ASSET_TYPE: &str = "credit_alphanum12";
const BUYING_ASSET_CODE: &str = "EURCAllow";
const BUYING_ASSET_ISSUER: &str = "GA6HVGLFUF3BHHGR5CMYXIVZ3RYVUH5EUYAOAY4T3OKI5OQVIWVRK24R";
const AMOUNT: &str = "922278138224.9775807";
const AMOUNT: &str = "922274722883.0675807";
const PRICE_R_N: &u32 = &1;
const PRICE_R_D: &u32 = &1;
const PRICE: &str = "1.0000000";
const LAST_MODIFIED_LEDGER: &u32 = &1762248;
const LAST_MODIFIED_TIME: &str = "2024-05-23T22:12:07Z";
const LAST_MODIFIED_LEDGER: &u32 = &1938375;
const LAST_MODIFIED_TIME: &str = "2024-06-03T15:21:13Z";

let horizon_client =
HorizonClient::new("https://horizon-testnet.stellar.org"
Expand Down