diff --git a/Cargo.lock b/Cargo.lock index 86c5e8e..f70a12f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1188,6 +1188,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.20" @@ -1397,12 +1408,15 @@ dependencies = [ ] [[package]] +<<<<<<< HEAD name = "typenum" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] +======= +>>>>>>> pxp9/ft_filters name = "unicode-bidi" version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml index 9247a8a..f9a7c9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ thiserror = "1.0" once_cell = "1.18" rand = "0.8" reqwest_cookie_store = "0.6" +<<<<<<< HEAD typed-builder = "0.14" [dependencies.bb8-postgres] @@ -36,4 +37,7 @@ optional = true [dependencies.postgres-types] version = "0.X.X" features = ["derive"] -optional = true \ No newline at end of file +optional = true +======= +typed-builder = "0.14" +>>>>>>> pxp9/ft_filters diff --git a/src/model/filter.rs b/src/model/filter.rs index 60113b3..386ea30 100644 --- a/src/model/filter.rs +++ b/src/model/filter.rs @@ -1,5 +1,6 @@ use typed_builder::TypedBuilder; +<<<<<<< HEAD pub mod brand; pub mod category; pub mod category_tree; @@ -72,4 +73,17 @@ impl From for &str { SortBy::NewestFirst => "newest_first", } } +======= +#[derive(TypedBuilder)] +pub struct Filter { + #[builder(default, setter(strip_option))] + search_text: Option, + #[builder(default, setter(strip_option))] + catalog_id: Option, + #[builder(default, setter(strip_option))] + color_id: Option, + // id 15 es Mango + #[builder(default, setter(strip_option))] + brand_ids: Option>, +>>>>>>> pxp9/ft_filters } diff --git a/src/queries.rs b/src/queries.rs index 720e376..5e36c9a 100644 --- a/src/queries.rs +++ b/src/queries.rs @@ -14,8 +14,11 @@ use crate::model::items::Items; pub enum CookieError { #[error(transparent)] ReqWestError(#[from] reqwest::Error), +<<<<<<< HEAD #[error("Error to get cookies")] GetCookiesError, +======= +>>>>>>> pxp9/ft_filters } const DOMAINS: [&str; 18] = [ @@ -151,6 +154,7 @@ impl<'a> VintedWrapper<'a> { Ok(()) } +<<<<<<< HEAD fn substitute_if_first(first: &mut bool, url: &mut String) { if *first { url.replace_range(0..1, "?"); @@ -217,6 +221,24 @@ impl<'a> VintedWrapper<'a> { self.refresh_cookies().await?; } +======= + pub async fn get_item(&mut self) -> Result<(), CookieError> { + //1. Try request + //2. If fails: get_cookie + //3. Needs client? + //4. Should the host be a parameter? + /* + https://www.vinted.es/api/v2/catalog/items + + */ + + let domain: &str = &format!("vinted.{}", self.host.as_ref().unwrap()); + + if let None = self.cookie_store.clone().lock().unwrap().get(domain, "/", "__cf_bm") { + self.refresh_cookies().await? + } + +>>>>>>> pxp9/ft_filters let client = self.get_client(); let mut first = true; diff --git a/vinted-db-feeder b/vinted-db-feeder index 1cd0c72..990de5c 160000 --- a/vinted-db-feeder +++ b/vinted-db-feeder @@ -1 +1 @@ -Subproject commit 1cd0c72df600b27c1859ca38558f62fac6c01ddc +Subproject commit 990de5c43d489e41d5f29e420b0a5146e167f11c