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 pagination functionality for 'Offers for Account' #102

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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
17 changes: 16 additions & 1 deletion stellar_rust_sdk/src/offers/offers_for_account_request.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::models::*;
use stellar_rust_sdk_derive::Pagination;
use crate::Paginatable;

/// Represents the ID of an account for which the offers are to be retrieved.
#[derive(Default, Clone)]
Expand All @@ -9,9 +11,19 @@ pub struct OfferAccountId(String);
pub struct NoOfferAccountId;
#[derive(Default)]

#[derive(Pagination)]
pub struct OffersForAccountRequest<I> {
/// The ID of the account for which the offers are to be retrieved.
account_id: I,
/// 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>,
tluijken marked this conversation as resolved.
Show resolved Hide resolved
}

impl OffersForAccountRequest<NoOfferAccountId> {
Expand All @@ -29,7 +41,10 @@ impl OffersForAccountRequest<NoOfferAccountId> {
}

Ok(OffersForAccountRequest {
account_id: OfferAccountId(account_id,)
account_id: OfferAccountId(account_id,),
cursor: self.cursor,
limit: self.limit,
order: self.order,
})
}
}
Expand Down