Skip to content

Commit

Permalink
v.0.3.0 (#34)
Browse files Browse the repository at this point in the history
* Pxp9/ft filters url (#14)

* tenemos las tallas gracias a la cortesía de ChatGPT beautiful soup y una buena feature del navegador xd, subimos el JSON donde están todas las categorías (falta parsear) y empezamos con las marcas

* script de python que te saca todos los nombres de marcas de la pagina brands/byLetter/Letra

* nombres de marcas y tallas extraidas

* script que hace requests a la api y obtiene el ID de la marca

* Got brands_ids :D

* formatting catalogs ids

* organizando los recursos de los filtros

* materiales

* arreglillos de ultima hora

* arreglillos de ultima hora

* Added scrappers as submodule

* Refactor completed

* Fmt formatted

* actualizando el submodulo del scrapper

* primera migration sizes complete

* get_catalogs , alvaro y README

* Finished catalogs

* Fix README

* Fix both Readme

* Fix dependency for Diesel

* Created more migrations

* Brands needs a fix

* fix migrations and brands

* migracion de countries y query de la BBDD de una marca

* fix clippy

* arreglando un bug con las cookies, haciendo un test y limitando get_item a 1 elemento

* fix fmt

* mejorando la API del wrapper , implementando FROM de Brand

* fix fmt

* fix clippy on test

* review API and model types

* fix fmt

* Db tests

* fix workflow

* empezando a procesar los filtros en la URI

* Finished db-feeder

* Added some tests

* Added query

* Added optional num field in get_items

* Added Get_category_by_name tested

* Converted vec<i32> to String

Co-authored-by: Pmarquez <[email protected]>

* Finished filters

* Fix doctest

* Added get-host

* Cargo clippy fix

* Small changes big steps

* Fix languages

* fuck cargo fmt

---------

Co-authored-by: alvarocabo <[email protected]>
Co-authored-by: Pmarquez <[email protected]>

* Fix cargo lock

* countries , price from and price to filter done (#25)

* countries , price from and price to filter done

* fix typo docs

* Improved README

* Fixing doc tests

* Small fix

* Added search by country

* Como no el fmt

* Added material and size filters

* Removed debug element

* Attemp of testing item by color

* Ignoring the test for now

* Fix clippy

* Ignore test for now

* Removed main.rs

* Updated .gitignore

* tests de filtros

* fix clippy and fmt

---------

Co-authored-by: alvarocabo <[email protected]>

* bump the version to 0.2

* fix conflict

* merge (#31)

* Develop (#26)

* Pxp9/ft filters url (#14)

* tenemos las tallas gracias a la cortesía de ChatGPT beautiful soup y una buena feature del navegador xd, subimos el JSON donde están todas las categorías (falta parsear) y empezamos con las marcas

* script de python que te saca todos los nombres de marcas de la pagina brands/byLetter/Letra

* nombres de marcas y tallas extraidas

* script que hace requests a la api y obtiene el ID de la marca

* Got brands_ids :D

* formatting catalogs ids

* organizando los recursos de los filtros

* materiales

* arreglillos de ultima hora

* arreglillos de ultima hora

* Added scrappers as submodule

* Refactor completed

* Fmt formatted

* actualizando el submodulo del scrapper

* primera migration sizes complete

* get_catalogs , alvaro y README

* Finished catalogs

* Fix README

* Fix both Readme

* Fix dependency for Diesel

* Created more migrations

* Brands needs a fix

* fix migrations and brands

* migracion de countries y query de la BBDD de una marca

* fix clippy

* arreglando un bug con las cookies, haciendo un test y limitando get_item a 1 elemento

* fix fmt

* mejorando la API del wrapper , implementando FROM de Brand

* fix fmt

* fix clippy on test

* review API and model types

* fix fmt

* Db tests

* fix workflow

* empezando a procesar los filtros en la URI

* Finished db-feeder

* Added some tests

* Added query

* Added optional num field in get_items

* Added Get_category_by_name tested

* Converted vec<i32> to String

Co-authored-by: Pmarquez <[email protected]>

* Finished filters

* Fix doctest

* Added get-host

* Cargo clippy fix

* Small changes big steps

* Fix languages

* fuck cargo fmt

---------

Co-authored-by: alvarocabo <[email protected]>
Co-authored-by: Pmarquez <[email protected]>

* Fix cargo lock

* countries , price from and price to filter done (#25)

* countries , price from and price to filter done

* fix typo docs

* Improved README

* Fixing doc tests

* Small fix

* Added search by country

* Como no el fmt

* Added material and size filters

* Removed debug element

* Attemp of testing item by color

* Ignoring the test for now

* Fix clippy

* Ignore test for now

* Removed main.rs

* Updated .gitignore

* tests de filtros

* fix clippy and fmt

---------

Co-authored-by: alvarocabo <[email protected]>

---------

Co-authored-by: alvarocabo <[email protected]>
Co-authored-by: Pmarquez <[email protected]>

* chore(cargo): bump serde from 1.0.167 to 1.0.168 (#27)

Bumps [serde](https://github.com/serde-rs/serde) from 1.0.167 to 1.0.168.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](serde-rs/serde@v1.0.167...v1.0.168)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update README.md (#28)

* delete Cargo.lock (#29)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: alvarocabo <[email protected]>
Co-authored-by: Pmarquez <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* currency config (#32)

* currency config

* fix fmt

* currency constructor

* Added test

* cargo fmt

---------

Co-authored-by: alvarocabo <[email protected]>

* example filter (#33)

* fix fmt

* Added pretty nice documentation (#35)

* Added pretty nice documentation

* Fmt fixxx

* Fix typeBuilder typo

* Las comillas :<

* Bump to version 0.3

* Init CHANGELOG

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Pmarquez <[email protected]>
Co-authored-by: Pmarquez <[email protected]>
Co-authored-by: pxp9 <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Jul 15, 2023
1 parent 8b5351a commit af74e5a
Show file tree
Hide file tree
Showing 17 changed files with 286 additions and 43 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/target
**/main.rs
/**/target
Cargo.lock
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## 0.3.0 (2023-07-15) #34

### Added

- Filter by Currency implemented - #32
- Example project using advanced filters feature - #33
- CHANGELOG file

### Improved

- Documentation for `filter` module - #35
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vinted-rs"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
repository = "https://github.com/TuTarea/vinted-rs"
authors = ["Pepe Márquez <[email protected]>" , "Álvaro Cabo <[email protected]>"]
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Vinted-rs: A Vinted API wrapper

[![github]](https://github.com/TuTarea/vinted-rs/)&ensp;[![crates-io]](https://crates.io/crates/vinted-rs)&ensp;[![docs-rs]](https://docs.rs/vinted-rs/latest/vinted_rs/)
[![github]](https://github.com/TuTarea/vinted-rs/)&ensp;[![crates-io]](https://crates.io/crates/vinted-rs)&ensp;[![docs-rs]](https://docs.rs/vinted-rs/latest/vinted_rs/)

[github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
[crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
[docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs
[github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
[crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
[docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs

## Table of Contents

Expand All @@ -24,7 +24,7 @@ Via `cargo` you can add the library to your project's `Cargo.toml`

```toml
[dependencies]
vinted-rs = "0.2"
vinted-rs = "0.3"
```

## DB setup
Expand Down
11 changes: 11 additions & 0 deletions examples/filter_example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "filter_example"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
vinted-rs = { path = "../../", features = ["advanced_filters"]}
bb8-postgres = {version = "0.8", features = ["with-serde_json-1" , "with-uuid-1" , "with-chrono-0_4"]}
tokio = { version = "1", features = ["full"] }
26 changes: 26 additions & 0 deletions examples/filter_example/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use bb8_postgres::tokio_postgres::NoTls;
use vinted_rs::{db::DbController, Filter, VintedWrapper};

#[tokio::main]
async fn main() {
let db = DbController::new("postgres://postgres:postgres@localhost/vinted-rs", 5, NoTls)
.await
.unwrap();

let adidas = db.get_brand_by_name(&"Adidas").await.unwrap();
let nike = db.get_brand_by_name(&"Nike").await.unwrap();

let brands = format!("{},{}", adidas.id, nike.id);

let filter = Filter::builder()
.brand_ids(brands)
.price_from(15)
.price_to(20)
.build();

let vinted = VintedWrapper::new();

let items = vinted.get_items(&filter, 10).await.unwrap();

println!("{:?}", items);
}
8 changes: 0 additions & 8 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@

/// The `filter` module provides structures and enums for filtering items in the Vinted API.
///
/// It contains the following modules:
/// - `brand`: Provides functionality related to filtering by brand.
/// - `category`: Provides functionality related to filtering by category.
/// - `category_tree`: Provides functionality for retrieving the category tree.
/// - `colors`: Provides functionality related to filtering by color.
/// - `country`: Provides functionality related to filtering by country.
/// - `material`: Provides functionality related to filtering by material.
/// - `size`: Provides functionality related to filtering by size.
pub mod filter;

/// The `item` module provides the `Item` struct representing an item in the Vinted API.
Expand Down
103 changes: 83 additions & 20 deletions src/model/filter.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
use typed_builder::TypedBuilder;

use crate::queries::Host;

/// Provides functionality related to filtering by brand.
pub mod brand;
/// Provides functionality related to filtering by category.
pub mod category;
/// Provides functionality for retrieving the category tree.
pub mod category_tree;
/// Provides functionality related to filtering by color.
pub mod colors;
/// Provides functionality related to filtering by country.
pub mod country;
/// Provides functionality related to filtering by material.
pub mod material;
/// Provides functionality related to filtering by size.
pub mod size;

/// Represents a filter for querying items.
Expand Down Expand Up @@ -224,25 +233,83 @@ pub struct Filter {
#[builder(default, setter(strip_option))]
pub price_to: Option<u32>,
}
/**
Represents the currency for filtering items
/*
Represents the article status for filtering items.
*/
// GBP => Host uk
// EUR => Pais de Europa sera el default
// USD => Host com
// CSK => Host cz
// PLN => Host pl
// SEK => Host se
// RON => Host ro
// HUF => Host hu
#[derive(Debug, Clone)]
pub enum Currency {
/// Euro
EUR,
/// US Dollar
USD,
/// Great Britain Pound
GBP,
/// Czech korona
CZK,
/// Polish złoty
PLN,
/// Swedish krona
SEK,
/// Romanian leu
RON,
/// Hungarian forint
HUF,
}

impl From<Currency> for Host {
fn from(currency: Currency) -> Self {
match currency {
Currency::USD => Host::Com,
Currency::GBP => Host::Uk,
Currency::CZK => Host::Cz,
Currency::PLN => Host::Pl,
Currency::SEK => Host::Se,
Currency::RON => Host::Ro,
Currency::HUF => Host::Hu,
Currency::EUR => Host::random_euro_host(),
}
}
}

Variants:
- `NewTags`: The article status for new items with tags.
- `NewNoTags`: The article status for new items without tags.
- `VeryGood`: The article status for items in very good condition.
- `Good`: The article status for items in good condition.
- `Satisfactory`: The article status for items in satisfactory condition.
impl From<Currency> for &str {
fn from(currency: Currency) -> Self {
match currency {
Currency::USD => "USD",
Currency::GBP => "GBP",
Currency::CZK => "CZK",
Currency::PLN => "PLN",
Currency::SEK => "SEK",
Currency::RON => "RON",
Currency::HUF => "HUF",
Currency::EUR => "EUR",
}
}
}

/**
Represents the article status for filtering items.
Trait Implementations:
- `From<&ArticleStatus> for &str>`: Converts an `ArticleStatus` variant to a string slice. */
*/
#[derive(Debug, Clone)]
pub enum ArticleStatus {
/// The article status for new items with tags.
NewTags,
/// The article status for new items without tags.
NewNoTags,
/// The article status for items in very good condition.
VeryGood,
/// Good`: The article status for items in good condition.
Good,
/// The article status for items in satisfactory condition.
Satisfactory,
}

Expand All @@ -258,23 +325,19 @@ impl From<&ArticleStatus> for &str {
}
}
}
/*
/**
Represents the sort order for the retrieved items.
Variants:
- `Relevance`: Sort items by relevance.
- `PriceDescendant`: Sort items by price in descending order.
- `PriceAscendant`: Sort items by price in ascending order.
- `NewestFirst`: Sort items by newest first.
Trait Implementations:
- `From<&SortBy> for &str>`: Converts a `SortBy` variant to a string slice.
*/

#[derive(Debug, Clone)]
pub enum SortBy {
/// Sort items by relevance.
Relevance,
/// Sort items by price in descending order.
PriceDescendant,
/// Sort items by price in ascending order.
PriceAscendant,
/// Sort items by newest first.
NewestFirst,
}

Expand Down
3 changes: 3 additions & 0 deletions src/model/filter/brand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ use typed_builder::TypedBuilder;

#[derive(Debug, Clone, TypedBuilder, PartialEq, Eq)]
pub struct Brand {
/// Brand id given by Vinted
pub id: i32,
/// Brand name
pub title: String,
/// Brand URl in vinted
pub url: String,
}

Expand Down
7 changes: 6 additions & 1 deletion src/model/filter/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ use typed_builder::TypedBuilder;

#[derive(Debug, Clone, TypedBuilder, PartialEq, Eq)]
pub struct Category {
/// Category id given by Vinted
pub id: i32,
// TODO creo que estos titulos solo estan en ingles
/// Category name
pub title: String,
/// Category Vinted iso code
pub code: String,
/// Category's father id
pub parent_id: i32,
/// Category URL in Vinted
pub url: String,
/// Category URL in Vinted in English
pub url_en: String,
}

Expand Down
3 changes: 3 additions & 0 deletions src/model/filter/category_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ use typed_builder::TypedBuilder;

#[derive(Debug, Clone, TypedBuilder, PartialEq, Eq)]
pub struct CategoryTree {
/// Vinted-rs autogenerated id
pub id: i32,
/// Father Category id
pub parent_id: i32,
/// Child Category id
pub child_id: i32,
}

Expand Down
3 changes: 3 additions & 0 deletions src/model/filter/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ use typed_builder::TypedBuilder;

#[derive(Debug, Clone, TypedBuilder, PartialEq, Eq)]
pub struct Color {
/// Color id given by Vinted
pub id: i32,
/// Color name in French
pub title: String,
/// Color hex representation with format `\#[0-9A-Fa-f]{6}`
pub hex: String,
}

Expand Down
5 changes: 5 additions & 0 deletions src/model/filter/country.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ use typed_builder::TypedBuilder;

#[derive(Debug, Clone, TypedBuilder, PartialEq, Eq)]
pub struct Country {
/// Country id given by Vinted
pub id: i32,
/// Country's name in French
pub name: String,
/// Country's name in the local language
pub local_name: String,
/// Country ISO code
pub iso_code: String,
/// Country's unicode flag emoji
pub flag: String,
}

Expand Down
4 changes: 4 additions & 0 deletions src/model/filter/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ use typed_builder::TypedBuilder;

#[derive(Debug, Clone, TypedBuilder, PartialEq, Eq)]
pub struct Material {
/// Material id given by Vinted
pub id: i32,
/// Material name in Spanish
pub material_es: String,
/// Material name in French
pub material_fr: String,
/// Material name in English
pub material_en: String,
}

Expand Down
18 changes: 13 additions & 5 deletions src/model/filter/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@
use bb8_postgres::tokio_postgres::Row;
use typed_builder::TypedBuilder;

// TODO las tallas y las categorias de tallas están solo en Castellano
/**
Size structs are differenciated by parent categories
XL for Men is not the same as XL for children
*/
#[derive(Debug, Clone, TypedBuilder, PartialEq, Eq)]
pub struct Size {
id: i32,
id_vinted: i32,
// TODO las tallas y las categorias de tallas están solo en Castellano
size: String,
category: String,
/// Vinted-rs autogenerated id
pub id: i32,
/// Size id given by Vinted (non-unique)
pub id_vinted: i32,
/// Size name in Spanish
pub size: String,
/// Parent category associated with the size type
pub category: String,
}

#[cfg(feature = "advanced_filters")]
Expand Down
Loading

0 comments on commit af74e5a

Please sign in to comment.