-
Notifications
You must be signed in to change notification settings - Fork 1
/
business_search.rs
36 lines (33 loc) · 1.26 KB
/
business_search.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
29
30
31
32
33
34
35
36
use std::collections::HashSet;
use std::env;
use yelp_fusion_rs::endpoints::{BusinessSearchPayload, BusinessSearchResponse};
use yelp_fusion_rs::error::Error;
use yelp_fusion_rs::models::{Coordinates, PriceType};
use yelp_fusion_rs::yelp_fusion::YelpFusionClient;
#[tokio::main]
async fn main() -> Result<(), Error> {
let yelp_fusion_api_key = env::var("YELP_FUSION_API_KEY").expect("no Yelp Fusion API key");
let yelp_fusion_client: YelpFusionClient = YelpFusionClient::new(yelp_fusion_api_key, None);
let business_search_payload: BusinessSearchPayload = BusinessSearchPayload::builder()
.coordinates(Coordinates::new(37.772_484, -122.396_68))
.radius(1609)
.categories(vec![String::from("mexican"), String::from("sandwiches")])
.limit(50)
.price(HashSet::from([
PriceType::OneDollar,
PriceType::TwoDollar,
PriceType::ThreeDollar,
PriceType::FourDollar,
]))
.open_now(true)
.build()
.unwrap();
let business_search_response: BusinessSearchResponse = yelp_fusion_client
.business_search(&business_search_payload)
.await?;
println!(
"{}",
serde_json::to_string(&business_search_response).unwrap()
);
Ok(())
}