rango_sdk/client/
swap.rs

1use crate::{
2    error::SdkErr,
3    swap::{SwapRequest, SwapResponse},
4};
5
6impl super::Client {
7    /// After getting a quote, you will call swap. it includes the route and required transaction to be singed by user.
8    pub async fn swap(&self, request: SwapRequest) -> Result<SwapResponse, SdkErr> {
9        let qs = request.into_qs()?;
10
11        let url = format!(
12            "{}/{}?apiKey={}&{}",
13            self.config.api_url, "basic/swap", self.config.api_key, qs
14        );
15
16        let body: SwapResponse = ureq::get(&url).call()?.into_json()?;
17        Ok(body)
18    }
19}