Skip to content

Commit 1615a38

Browse files
committed
declare types for search response
1 parent 35cf68d commit 1615a38

File tree

6 files changed

+100
-1
lines changed

6 files changed

+100
-1
lines changed

rust/price-rs/mercado-rs/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/price-rs/mercado-rs/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
mod types;
2+
13
#[cfg(test)]
24
mod tests {
35
#[test]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
struct Paging {
2+
total: u64,
3+
primary_results: u32,
4+
offset: u32,
5+
limit: u32,
6+
}
7+
8+
struct Seller {
9+
id: String,
10+
permalink: String,
11+
registration_date: String,
12+
}
13+
14+
struct Installments {
15+
quantity: u8,
16+
amount: u32,
17+
rate: f32,
18+
currency_id: String,
19+
}
20+
21+
struct Address {
22+
state_id: String,
23+
state_name: String,
24+
city_id: String,
25+
city_name: String,
26+
}
27+
28+
struct Shipping {
29+
free_shipping: bool,
30+
mode: String,
31+
tags: Vec<String>,
32+
logistic_type: String,
33+
store_pick_up: bool
34+
}
35+
36+
struct Attribute {
37+
id: String,
38+
attribute_group_id: String,
39+
name: String,
40+
value_name: String,
41+
attribute_group_name: String,
42+
}
43+
44+
struct SearchResult {
45+
id: String,
46+
title: String,
47+
seller: Seller,
48+
price: u64,
49+
available_quantity: u32,
50+
sold_quantity: u32,
51+
condition: String, // should be enum
52+
permalink: String,
53+
thumbnail: String,
54+
accepts_mercadopago: bool,
55+
installments: Installments,
56+
address: Address,
57+
shipping: Shipping,
58+
category_id: String,
59+
tags: Vec<String>,
60+
domain_id: Option<String>,
61+
attributes: Vec<Attribute>
62+
}
63+
64+
struct Sort {
65+
id: String,
66+
name: String
67+
}
68+
69+
struct SearchResults {
70+
query: String,
71+
paging: Paging,
72+
results: Vec<SearchResult>,
73+
sort: Sort,
74+
available_sorts: Vec<Sort>
75+
}

rust/price-rs/price-watch-cli/Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[package]
2-
name = "price-rs"
2+
name = "price-watch-cli"
33
version = "0.1.0"
44
edition = "2021"
55

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

88
[dependencies]
9+
"mercado-rs" = {version = "0.1.0", path = "../mercado-rs"}

0 commit comments

Comments
 (0)