Skip to content

Commit

Permalink
Merge branch 'pxp9/ft_filters' into ft/Vec<i32>-to-String
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCAB0 committed Jul 8, 2023
2 parents 5d4e151 + eac8a10 commit 1826dcd
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -36,4 +37,7 @@ optional = true
[dependencies.postgres-types]
version = "0.X.X"
features = ["derive"]
optional = true
optional = true
=======
typed-builder = "0.14"
>>>>>>> pxp9/ft_filters
14 changes: 14 additions & 0 deletions src/model/filter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use typed_builder::TypedBuilder;

<<<<<<< HEAD
pub mod brand;
pub mod category;
pub mod category_tree;
Expand Down Expand Up @@ -72,4 +73,17 @@ impl From<SortBy> for &str {
SortBy::NewestFirst => "newest_first",
}
}
=======
#[derive(TypedBuilder)]
pub struct Filter {
#[builder(default, setter(strip_option))]
search_text: Option<String>,
#[builder(default, setter(strip_option))]
catalog_id: Option<i32>,
#[builder(default, setter(strip_option))]
color_id: Option<i32>,
// id 15 es Mango
#[builder(default, setter(strip_option))]
brand_ids: Option<Vec<i32>>,
>>>>>>> pxp9/ft_filters
}
22 changes: 22 additions & 0 deletions src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Expand Down Expand Up @@ -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, "?");
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion vinted-db-feeder

0 comments on commit 1826dcd

Please sign in to comment.