melvin_ob/http_handler/http_request/
beacon_position_put.rs

1use super::beacon_position::BeaconPositionResponse;
2use super::request_common::{HTTPRequestMethod, HTTPRequestType, NoBodyHTTPRequestType};
3use std::collections::HashMap;
4
5/// Request type for the /beacon endpoint -> PUT.
6#[derive(Debug)]
7pub(crate) struct BeaconPositionRequest {
8    /// The id of the associated beacon objective.
9    pub(crate) beacon_id: u16,
10    /// The y-coordinate of the guess.
11    pub(crate) height: u32,
12    /// The x-coordinate of the guess.
13    pub(crate) width: u32,
14}
15
16impl NoBodyHTTPRequestType for BeaconPositionRequest {}
17
18impl HTTPRequestType for BeaconPositionRequest {
19    /// Type of the expected response.
20    type Response = BeaconPositionResponse;
21    /// `str` object representing the specific endpoint.
22    fn endpoint(&self) -> &'static str { "/beacon" }
23    /// The corresponding HTTP Request Method.
24    fn request_method(&self) -> HTTPRequestMethod { HTTPRequestMethod::Put }
25    /// A `HasMap` containing the query param key value pairs.
26    fn query_params(&self) -> HashMap<&str, String> {
27        let mut query = HashMap::new();
28        query.insert("beacon_id", self.beacon_id.to_string());
29        query.insert("height", self.height.to_string());
30        query.insert("width", self.width.to_string());
31        query
32    }
33}