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 retrieve_line_items function for CheckoutSession #541

Merged
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
36 changes: 36 additions & 0 deletions src/resources/checkout_session_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@ use crate::client::{Client, Response};
use crate::ids::CheckoutSessionId;
use crate::params::Expand;
use crate::resources::CheckoutSession;
use crate::{CheckoutSessionItem, List};

/// The parameters for `CheckoutSession::retrieve_line_items`.
#[derive(Clone, Debug, serde::Serialize, Default)]
pub struct RetrieveCheckoutSessionLineItems {
/// A cursor for use in pagination.
///
/// `ending_before` is an object ID that defines your place in the list.
/// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
#[serde(skip_serializing_if = "Option::is_none")]
pub ending_before: Option<CheckoutSessionId>,

/// A limit on the number of objects to be returned.
///
/// Limit can range between 1 and 100, and the default is 10.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u64>,

/// A cursor for use in pagination.
///
/// `starting_after` is an object ID that defines your place in the list.
/// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
#[serde(skip_serializing_if = "Option::is_none")]
pub starting_after: Option<CheckoutSessionId>,
}

impl CheckoutSession {
/// Retrieves a Session object.
Expand All @@ -21,4 +46,15 @@ impl CheckoutSession {
pub fn expire(client: &Client, id: &CheckoutSessionId) -> Response<CheckoutSession> {
client.post(&format!("/checkout/sessions/{}/expire", id))
}

/// Retrieves a Checkout Session's line items
///
/// For more details see <https://docs.stripe.com/api/checkout/sessions/line_items>
pub fn retrieve_line_items(
client: &Client,
id: &CheckoutSessionId,
params: &RetrieveCheckoutSessionLineItems,
) -> Response<List<CheckoutSessionItem>> {
client.get_query(&format!("/checkout/sessions/{}/line_items", id), &params)
}
}