one_inch 0.1.1

Rusty API wrapper for the 1inch
Documentation
use core::fmt;
use strum_macros::{Display, FromRepr};

/// Struct to work with 1inch api
pub struct OneInchClient {
    /// reqwest::Client does not need to be Rc/Arc because it already uses an Arc internally.
    pub http_client: reqwest::Client,

    /// An authorization token for interacting with API.
    /// There you can get your own token : <https://portal.1inch.dev/applications>
    pub(crate) token: String,

    /// The ID of the network on which you want to work.
    /// You can interact only with 1 specified network with your client.
    pub(crate) network_id: SupportedNetworks,
}

/// Function creates a OneInchClient instance with default http settings.
pub fn new_with_default_http(token: String, network_id: SupportedNetworks) -> OneInchClient {
    OneInchClient {
        http_client: reqwest::Client::default(),
        token,
        network_id,
    }
}

/// List of all supported Networks/Chains with their IDs.
#[derive(FromRepr, Debug, Copy, Clone)]
#[repr(u32)]
pub enum SupportedNetworks {
    Ethereum = 1,
    Optimism = 10,
    BSC = 56,
    Gnosis = 100,
    Polygon = 137,
    Fantom = 250,
    ZkSync = 324,
    Klaytn = 8217,
    Base = 8453,
    Arbitrum = 42161,
    Avalanche = 43114,
    Aurora = 1313161554,
}

impl fmt::Display for SupportedNetworks {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", *self as u32)
    }
}


/// List of all supported currencies in 1inch.
#[derive(Debug, Display, Clone)]
pub enum SupportedCurrencies {
    USD, AED, ARS, AUD, BDT, BHD, BMD, BRL, CAD, CHF, CLP, CNY, CZK, DKK, EUR, GBP,
    HKD, HUF, IDR, ILS, INR, JPY, KRW, KWD, LKR, MMK, MXN, MYR, NGN, NOK, NZD,
    PHP, PKR, PLN, RUB, SAR, SEK, SGD, THB, TRY, TWD, UAH, VEF, VND, ZAR
}