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

Idempotency notes #363

Merged
merged 2 commits into from
Apr 6, 2023
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
2 changes: 2 additions & 0 deletions openapi/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fn format_doc_comment(doc: &str) -> String {
static ref AMOUNT_CLOSE_TAG: Regex = Regex::new("</amount>").unwrap();
static ref CURRENCY_OPEN_TAG: Regex = Regex::new("<currency>").unwrap();
static ref CURRENCY_CLOSE_TAG: Regex = Regex::new("</currency>").unwrap();
static ref HYPERLINK: Regex = Regex::new(r#"([^\(])(https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))([^\)])"#).unwrap();
}
let doc = P_TAG.replace_all(doc, "");
let doc = BR_TAG.replace_all(&doc, "\n");
Expand All @@ -99,6 +100,7 @@ fn format_doc_comment(doc: &str) -> String {
let doc = AMOUNT_CLOSE_TAG.replace_all(&doc, "00"); // add cents to get correct "integer" argument
let doc = CURRENCY_OPEN_TAG.replace_all(&doc, "$"); // add locale formatting (we can only support one easily in our rust docs...)
let doc = CURRENCY_CLOSE_TAG.replace_all(&doc, "");
let doc = HYPERLINK.replace_all(&doc, "$1<$2>$5"); // replace all hyperlinks that are not already in markdown with rust doc links
doc.trim().into()
}

Expand Down
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@
//! the documentation. Any time an API is used in an example it is highlighted in the
//! docs for that item. You can also find all the raw examples in the `examples` directory.
//! Please have a look at those for inspiration or ideas on how to get started.
//!
//! ## Idempotency / Request Strategies
//!
//! This library provides a few basic request strategies for making requests to the Stripe API.
//! This is currently implemented as an enum with the following variants:
//!
//! - [`RequestStrategy::Once`]: This is the default strategy. It will make a request to the Stripe API and,
//! whether the request fails or not, will simply return the response.
//! - [`RequestStrategy::Idempotent`]: This strategy will make a request to stripe api, passing the provided
//! key to Stripe as the `Idempotency-Key` header, ensuring that the request
//! is idempotent. If the request fails, you may retry it.
//! - [`RequestStrategy::Retry`]: Make a request to the Stripe API and, if the request fails, retry it up to n
//! times with a timeout. The idempotency key is generated automatically and is
//! stable across retries.
//! - [`RequestStrategy::ExponentialBackoff`]: Make a request to the Stripe API and, if the request fails, retry
//! it up to n times with exponential backoff. The idempotency key is
//! generated automatically and is stable across retries.
//!
//! > Want to implement your own? If it is a common strategy, please consider opening a PR to add it to the library.
//! Otherwise, we are open to turning this into an open trait so that you can implement your own strategy.

#![allow(clippy::map_clone, clippy::large_enum_variant)]
#![warn(clippy::unwrap_used, clippy::missing_errors_doc, clippy::missing_panics_doc)]
Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub struct AccountCapabilityRequirements {
/// If the capability is disabled, this string describes why.
///
/// Can be `requirements.past_due`, `requirements.pending_verification`, `listed`, `platform_paused`, `rejected.fraud`, `rejected.listed`, `rejected.terms_of_service`, `rejected.other`, `under_review`, or `other`. `rejected.unsupported_business` means that the account's business is not supported by the capability.
/// For example, payment methods may restrict the businesses they support in their terms of service: - [Afterpay Clearpay's terms of service](/afterpay-clearpay/legal#restricted-businesses) If you believe that the rejection is in error, please contact support at https://support.stripe.com/contact/ for assistance.
/// For example, payment methods may restrict the businesses they support in their terms of service: - [Afterpay Clearpay's terms of service](/afterpay-clearpay/legal#restricted-businesses) If you believe that the rejection is in error, please contact support at <https://support.stripe.com/contact/> for assistance.
pub disabled_reason: Option<String>,

/// Fields that are `currently_due` and need to be collected again because validation or verification failed.
Expand Down
2 changes: 1 addition & 1 deletion src/resources/generated/issuing_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub struct IssuingCardShipping {
pub struct IssuingCardShippingCustoms {
/// A registration number used for customs in Europe.
///
/// See https://www.gov.uk/eori and https://ec.europa.eu/taxation_customs/business/customs-procedures-import-and-export/customs-procedures/economic-operators-registration-and-identification-number-eori_en.
/// See <https://www.gov.uk/eori> and <https://ec.europa.eu/taxation_customs/business/customs-procedures-import-and-export/customs-procedures/economic-operators-registration-and-identification-number-eori_en>.
pub eori_number: Option<String>,
}

Expand Down