melvin_ob/http_handler/http_request/
modify_slot_put.rs

1use super::modify_slot::ModifySlotResponse;
2use super::request_common::{
3    HTTPRequestMethod, HTTPRequestType, NoBodyHTTPRequestType, bool_to_string,
4};
5use std::collections::HashMap;
6
7/// Request type for the /slots endpoint -> PUT.
8#[derive(Debug)]
9pub(crate) struct ModifySlotRequest {
10    /// The id of the slot.
11    pub(crate) slot_id: usize,
12    /// The status of the slot.
13    pub(crate) enabled: bool,
14}
15
16impl NoBodyHTTPRequestType for ModifySlotRequest {}
17
18impl HTTPRequestType for ModifySlotRequest {
19    /// Type of the expected response.
20    type Response = ModifySlotResponse;
21    /// `str` object representing the specific endpoint.
22    fn endpoint(&self) -> &'static str { "/slots" }
23    /// The corresponding HTTP Request Method.
24    fn request_method(&self) -> HTTPRequestMethod { HTTPRequestMethod::Put }
25    /// A `HashMap` containing the query param key value pairs.
26    fn query_params(&self) -> HashMap<&str, String> {
27        let mut query = HashMap::new();
28        query.insert("slot_id", self.slot_id.to_string());
29        query.insert("enabled", bool_to_string(self.enabled).to_string());
30        query
31    }
32}