Skip to content

Commit

Permalink
fix: issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunPotti committed Aug 14, 2024
1 parent 6c2db55 commit be05b15
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repository = "https://github.com/VarunPotti/lemonsqueezy.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dotenv="0.15.0"
reqwest = { version = "0.11", features = ["blocking", "json"] }
tokio = { version = "1", features = ["full"] }
serde_json = "1.0"
Expand Down
35 changes: 27 additions & 8 deletions docs/checkouts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Checkouts

The stores endpoint allows you to retrieve information about the stores associated with the API key you are using.
The stores endpoint allows you to retrieve information about the stores associated with the API key you are using.
You can find the LemonSqueezy link [here](https://docs.lemonsqueezy.com/api/checkouts#the-checkout-object)

## Retrieve Checkouts
Expand All @@ -22,17 +22,36 @@ let checkout = checkout.get_all(None).await.unwrap();
```

## Create a Checkout

```rust
use lemonsqueezy::checkout::Checkout;
use lemonsqueezy::types::checkout::*;
let checkout = Checkout::build(lemonsqueezy);
let checkout = checkout.create(CreateCheckout {
store_id: 1,
customer_id: 1,
// ... other fields
}).await;

let checkout = checkout
.create(CreateCheckout {
r#type: String::from("checkouts"),
attributes: CreateCheckoutAttributes {
..Default::default()
},
relationships: Some(CreateCheckoutRelationships {
store: lemonsqueezy::types::Data {
data: CreateCheckoutRelationShipData {
r#type: String::from("stores"),
id: String::from("//store id"),
},
},
variant: lemonsqueezy::types::Data {
data: CreateCheckoutRelationShipData {
r#type: String::from("variants"),
id: String::from("// variant id"),
},
},
}),
}).await;
```

## Quick Links
## Quick Links

- [Back: License Key Instances](license_key_instances.md)
- [Next: Webhooks](webhooks.md)
- [Next: Webhooks](webhooks.md)
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use reqwest::{
};

pub(crate) mod errors;
pub(crate) mod modules;
pub mod modules;
pub mod utils;
pub use crate::modules::*;
pub mod types;
Expand Down
26 changes: 21 additions & 5 deletions src/modules/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,27 @@ impl Checkout {
/// use lemonsqueezy::types::checkout::*;
///
/// let checkout = Checkout::build(lemonsqueezy);
/// let checkout = checkout.create(CreateCheckout {
/// store_id: 1,
/// customer_id: 1,
/// // ... other fields
/// }).await;
// let checkout = checkout
// .create(CreateCheckout {
// r#type: String::from("checkouts"),
// attributes: CreateCheckoutAttributes {
// ..Default::default()
// },
// relationships: Some(CreateCheckoutRelationships {
// store: lemonsqueezy::types::Data {
// data: CreateCheckoutRelationShipData {
// r#type: String::from("stores"),
// id: String::from("//store id"),
// },
// },
// variant: lemonsqueezy::types::Data {
// data: CreateCheckoutRelationShipData {
// r#type: String::from("variants"),
// id: String::from("// variant id"),
// },
// },
// }),
// }).await;
/// ```
pub async fn create(
&self,
Expand Down

0 comments on commit be05b15

Please sign in to comment.