mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 14:16:19 +00:00
reintentar pedidos de API a Jumbo
This commit is contained in:
parent
e97b355715
commit
3396a433e5
1 changed files with 11 additions and 12 deletions
|
@ -1,12 +1,13 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Context;
|
||||
use futures::TryFutureExt;
|
||||
use reqwest::Url;
|
||||
use serde::Deserialize;
|
||||
use simple_error::bail;
|
||||
|
||||
use crate::sites::common;
|
||||
use crate::PrecioPoint;
|
||||
use crate::{do_request, get_retry_policy, PrecioPoint};
|
||||
|
||||
use super::vtex;
|
||||
|
||||
|
@ -23,17 +24,15 @@ async fn get_ean_from_search(
|
|||
client: &reqwest::Client,
|
||||
retailer_sku: String,
|
||||
) -> anyhow::Result<String> {
|
||||
let s = client
|
||||
.get({
|
||||
let url = {
|
||||
let mut url =
|
||||
Url::from_str("https://www.jumbo.com.ar/api/catalog_system/pub/products/search")
|
||||
.unwrap();
|
||||
url.set_query(Some(&format!("fq=skuId:{}", retailer_sku)));
|
||||
url
|
||||
})
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
};
|
||||
let s = get_retry_policy()
|
||||
.retry(|| do_request(client, url.as_str()).and_then(|r| r.text()))
|
||||
.await?;
|
||||
let ean = {
|
||||
let search: Vec<JumboSearch> = serde_json::from_str(&s)?;
|
||||
|
|
Loading…
Reference in a new issue