renegade_sdk/renegade_wallet_client/actions/
get_order.rs

1//! Looks up an order by its ID in the relayer
2
3use renegade_external_api::{
4    http::order::{GET_ORDER_BY_ID_ROUTE, GetOrderByIdResponse},
5    types::{ApiOrder, OrderAuth},
6};
7use uuid::Uuid;
8
9use crate::{RenegadeClientError, actions::construct_http_path, client::RenegadeClient};
10
11// --- Public Actions --- //
12impl RenegadeClient {
13    /// Look up an order by its ID
14    pub async fn get_order(&self, order_id: Uuid) -> Result<ApiOrder, RenegadeClientError> {
15        let (order, _auth) = self.get_order_with_auth(order_id).await?;
16        Ok(order)
17    }
18}
19
20// --- Private Helpers --- //
21impl RenegadeClient {
22    /// Gets the order and its auth from the relayer
23    pub(crate) async fn get_order_with_auth(
24        &self,
25        order_id: Uuid,
26    ) -> Result<(ApiOrder, OrderAuth), RenegadeClientError> {
27        let path = construct_http_path!(GET_ORDER_BY_ID_ROUTE, "account_id" => self.get_account_id(), "order_id" => order_id);
28        let GetOrderByIdResponse { order, auth } = self.relayer_client.get(&path).await?;
29        Ok((order, auth))
30    }
31}