mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-26 11:36:20 +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 std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use futures::TryFutureExt;
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use simple_error::bail;
|
use simple_error::bail;
|
||||||
|
|
||||||
use crate::sites::common;
|
use crate::sites::common;
|
||||||
use crate::PrecioPoint;
|
use crate::{do_request, get_retry_policy, PrecioPoint};
|
||||||
|
|
||||||
use super::vtex;
|
use super::vtex;
|
||||||
|
|
||||||
|
@ -23,17 +24,15 @@ async fn get_ean_from_search(
|
||||||
client: &reqwest::Client,
|
client: &reqwest::Client,
|
||||||
retailer_sku: String,
|
retailer_sku: String,
|
||||||
) -> anyhow::Result<String> {
|
) -> anyhow::Result<String> {
|
||||||
let s = client
|
let url = {
|
||||||
.get({
|
|
||||||
let mut url =
|
let mut url =
|
||||||
Url::from_str("https://www.jumbo.com.ar/api/catalog_system/pub/products/search")
|
Url::from_str("https://www.jumbo.com.ar/api/catalog_system/pub/products/search")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
url.set_query(Some(&format!("fq=skuId:{}", retailer_sku)));
|
url.set_query(Some(&format!("fq=skuId:{}", retailer_sku)));
|
||||||
url
|
url
|
||||||
})
|
};
|
||||||
.send()
|
let s = get_retry_policy()
|
||||||
.await?
|
.retry(|| do_request(client, url.as_str()).and_then(|r| r.text()))
|
||||||
.text()
|
|
||||||
.await?;
|
.await?;
|
||||||
let ean = {
|
let ean = {
|
||||||
let search: Vec<JumboSearch> = serde_json::from_str(&s)?;
|
let search: Vec<JumboSearch> = serde_json::from_str(&s)?;
|
||||||
|
|
Loading…
Reference in a new issue