tutorlib/dto/
search_nearby_tutor_request.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SearchNearbyTutorRequest {
    pub subject: Option<String>,
    pub price_from: Option<i32>,
    pub price_to: Option<i32>,
}

impl SearchNearbyTutorRequest {
    pub fn to_search_tutor(&self) -> SearchNearbyTutorRequest {
        SearchNearbyTutorRequest {
            subject: if self.subject.is_none() {
                Option::from(String::from(""))
            } else {
                self.subject.clone()
            },
            price_from: if self.price_from.is_none() {
                Some(0)
            } else {
                self.price_from
            },
            price_to: if self.price_to.is_none() {
                Some(i32::MAX)
            } else {
                self.price_to
            },
        }
    }
}