Skip to content

Commit

Permalink
Merge branch 'develop' into feature/0xCAB0/add-cargo-publish-wf
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCAB0 committed Apr 2, 2024
2 parents 6c6b977 + 40b8084 commit 0542823
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/model/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub mod size;
/// let filter: Filter = Filter::builder()
/// .catalog_ids(Some(String::from("4,16")))
/// .brand_ids(Some(String::from("14,53")))
/// .build();
/// .build();
///
/// // Women shoes and Women clothes that are only from brands Adidas and Nike.
///
Expand Down
21 changes: 18 additions & 3 deletions src/model/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,31 @@ impl fmt::Display for Item {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Hash, Eq)]
#[cfg_attr(feature = "redis", derive(FromRedisValue, ToRedisArgs,))]
pub struct AdvancedItem {
// Products filter info
/// Vinted item ID
pub id: i64,
/// Item title
pub title: String,
/// Item description
pub description: String,
/// See [`Size`](crate::model::filter::size::Size)
#[serde(rename = "size")]
pub size_title: String,
/// See [`Brand`](crate::model::filter::brand::Brand)
#[serde(rename = "brand")]
pub brand_title: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub composition: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub extra_conditions: Option<String>,
/// See [`Brand`](crate::model::filter::brand::Brand)
#[serde(skip_serializing_if = "Option::is_none")]
pub brand_id: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub size_id: Option<i32>,
/// See [`ArticleStatus`](crate::model::filter::ArticleStatus)
#[serde(skip_serializing_if = "Option::is_none")]
pub status_id: Option<i32>,
/// Status of the item in French 🇫🇷
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status_fr: Option<String>,
Expand All @@ -78,25 +85,33 @@ pub struct AdvancedItem {
#[serde(skip_serializing_if = "Option::is_none")]
pub color2: Option<String>,
pub package_size_id: i32,
//Location
/// See [`Country`](crate::model::filter::country::Country)
pub country_id: i32,
#[serde(skip_serializing_if = "Option::is_none")]
pub city_id: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub city: Option<String>,

//Stats
/// Number of bids on the item
pub active_bid_count: i32,
/// Number of times the item was added to favourites
pub favourite_count: i32,
/// Number of times the item was viewed
pub view_count: i32,
/// Moderation status of the item (Vinted internal use only)
pub moderation_status: i32,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_push_up_at: Option<String>,
/// Related ['Brand'](crate::model::filter::brand::Brand) IDs
pub related_catalog_ids: Vec<i32>,

// Pricing
/// Original price of the item
pub original_price_numeric: String,
/// Currency the item was posted with. See [`Currency`](crate::model::filter::Currency) for valid currencies on Vinted
pub currency: String,
/// Current valid price of the item
pub price_numeric: String,

// Order by stats
Expand All @@ -106,7 +121,7 @@ pub struct AdvancedItem {
#[serde(skip_serializing_if = "Option::is_none")]
pub user_updated_at_ts: Option<String>,

// Asets
// Assets
pub photos: Vec<Photo>,
pub url: String,
pub user: AdvancedUser,
Expand Down
21 changes: 12 additions & 9 deletions src/model/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ use redis_macros::{FromRedisValue, ToRedisArgs};
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Hash, Eq)]
#[cfg_attr(feature = "redis", derive(FromRedisValue, ToRedisArgs,))]
pub struct PayInMethod {
id: i32,
code: String,
requires_credit_card: bool,
pub id: i32,
/// Code of the payment method given by Vinted
pub code: String,
/// If the payment method requires a credit card
pub requires_credit_card: bool,
#[serde(skip_serializing_if = "Option::is_none")]
event_tracking_code: Option<String>,
pub event_tracking_code: Option<String>,
/// Icon of the payment method
#[serde(skip_serializing_if = "Option::is_none")]
icon: Option<String>,
enabled: bool,
pub icon: Option<String>,
pub enabled: bool,
#[serde(skip_serializing_if = "Option::is_none")]
translated_name: Option<String>,
pub translated_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
note: Option<String>,
method_change_possible: bool,
pub note: Option<String>,
pub method_change_possible: bool,
}

impl fmt::Display for PayInMethod {
Expand Down
59 changes: 34 additions & 25 deletions src/model/user.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,60 @@
use std::fmt;

use crate::model::{Deserialize, Serialize};
#[cfg(feature = "redis")]
use crate::model::{FromRedisValue, ToRedisArgs};
use std::fmt;

use super::{payment_method::PayInMethod, photo::Photo};

#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "redis", derive(FromRedisValue, ToRedisArgs,))]
pub struct User {
id: i64,
login: String, //usernameredis_macros
photo: Photo,
/// Vinted user ID
pub id: i64,
// Username
pub login: String,
/// User's profile picture URL
pub photo: Photo,
}

/// All avalible fields for a user
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Hash, Eq)]
#[cfg_attr(feature = "redis", derive(FromRedisValue, ToRedisArgs,))]
pub struct AdvancedUser {
id: i64,
login: String, //username
/// Vinted user ID
pub id: i64,
/// Username
pub login: String,
/// User's profile picture URL
#[serde(skip_serializing_if = "Option::is_none")]
photo: Option<Photo>,

pub photo: Option<Photo>,
/// User's real name
#[serde(skip_serializing_if = "Option::is_none")]
real_name: Option<String>,
pub real_name: Option<String>,
/// User's email
#[serde(skip_serializing_if = "Option::is_none")]
email: Option<String>,
pub email: Option<String>,
/// User's birthday
#[serde(skip_serializing_if = "Option::is_none")]
birthday: Option<String>,
pub birthday: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
gender: Option<String>,

pub gender: Option<String>,
/// Last time the user logged in
#[serde(skip_serializing_if = "Option::is_none")]
last_loged_on_ts: Option<String>,
expose_location: bool,
country_id: i32,
pub last_loged_on_ts: Option<String>,
/// If the user wants to expose his location
pub expose_location: bool,
/// See [`Country`](crate::model::filter::country::Country)
pub country_id: i32,
#[serde(skip_serializing_if = "Option::is_none")]
city_id: Option<i32>,
pub city_id: Option<i32>,
/// City name
#[serde(skip_serializing_if = "Option::is_none")]
city: Option<String>,

pub city: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
path: Option<String>,
pub path: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
about: Option<String>,

accepted_pay_in_methods: Vec<PayInMethod>,
pub about: Option<String>,
/// Payment methods accepted by the user
pub accepted_pay_in_methods: Vec<PayInMethod>,
}

impl fmt::Display for AdvancedUser {
Expand Down
6 changes: 2 additions & 4 deletions src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,12 @@ impl<'a> VintedWrapper<'a> {
pub fn get_id(&self) -> &usize {
&self.id
}
/**
After changing host is always necessary to refresh cookies
*/
/// After changing host is always necessary to refresh cookies
pub fn set_new_random_host(&mut self) {
self.host = random_host();
}

/// After changing host is always necessary to refresh cookies
pub fn set_new_host(&mut self, host: Host) {
self.host = host.into();
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn test_get_item_brands() {
match vinted.get_items(&filter, 1, None, None, None).await {
// Limitado el numero de elementos a 1
Ok(items) => {
assert_eq!(items.items.get(0).unwrap().brand_title, brand.title);
assert_eq!(items.items.first().unwrap().brand_title, brand.title);
}
Err(err) => match err {
VintedWrapperError::ItemNumberError => unreachable!(),
Expand Down

0 comments on commit 0542823

Please sign in to comment.