-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcoupon_get.rs
28 lines (23 loc) · 880 Bytes
/
coupon_get.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Dependencies
use dotenv::dotenv;
use sellix_rs::Client;
use std::env;
// Entrypoint
#[tokio::test]
async fn coupon_get() {
dotenv().ok();
// Grab our environment variables
let api_key = env::var("API_KEY").expect("API_KEY not provided");
let merchant = env::var("MERCHANT").ok();
let coupon_uniqid = env::var("COUPON_UNIQID").expect("COUPON_UNIQID not provided");
// Warn if we do not have a merchant
if merchant.is_none() {
println!("warning: MERCHANT environment variable is not present. Defaulting to first merchant.");
}
// Build the client that would send out requests to the coupon API
let client = Client::new( &api_key, merchant.as_deref() );
let coupon_client = client.coupon;
// Get the coupon
let coupon = coupon_client.get(&coupon_uniqid).await;
assert!(coupon.is_ok(), "unable to get coupon");
}