Struct longbridge::Config
source · pub struct Config { /* private fields */ }Expand description
Configuration options for Longbridge sdk
Implementations§
source§impl Config
impl Config
sourcepub fn new(
app_key: impl Into<String>,
app_secret: impl Into<String>,
access_token: impl Into<String>
) -> Self
pub fn new( app_key: impl Into<String>, app_secret: impl Into<String>, access_token: impl Into<String> ) -> Self
Create a new Config
sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create a new Config from the given environment variables
It first gets the environment variables from the .env file in the
current directory.
Variables
LONGBRIDGE_APP_KEY- App keyLONGBRIDGE_APP_SECRET- App secretLONGBRIDGE_ACCESS_TOKEN- Access tokenLONGBRIDGE_HTTP_URL- HTTP endpoint url (Default:https://openapi.longbridgeapp.com)LONGBRIDGE_QUOTE_WS_URL- Quote websocket endpoint url (Default:wss://openapi-quote.longbridgeapp.com/v2)LONGBRIDGE_TRADE_WS_URL- Trade websocket endpoint url (Default:wss://openapi-trade.longbridgeapp.com/v2)
sourcepub fn http_url(self, url: impl Into<String>) -> Self
pub fn http_url(self, url: impl Into<String>) -> Self
Specifies the url of the OpenAPI server.
Default: https://openapi.longbridgeapp.com
NOTE: Usually you don’t need to change it.
sourcepub fn quote_ws_url(self, url: impl Into<String>) -> Self
pub fn quote_ws_url(self, url: impl Into<String>) -> Self
Specifies the url of the OpenAPI quote websocket server.
Default: wss://openapi-quote.longbridgeapp.com
NOTE: Usually you don’t need to change it.
sourcepub fn trade_ws_url(self, url: impl Into<String>) -> Self
pub fn trade_ws_url(self, url: impl Into<String>) -> Self
Specifies the url of the OpenAPI trade websocket server.
Default: wss://openapi-trade.longbridgeapp.com/v2
NOTE: Usually you don’t need to change it.
sourcepub async fn refresh_access_token(
&self,
expired_at: Option<OffsetDateTime>
) -> Result<String>
pub async fn refresh_access_token( &self, expired_at: Option<OffsetDateTime> ) -> Result<String>
Gets a new access_token
expired_at - The expiration time of the access token, defaults to 90
days.
Reference: https://open.longbridgeapp.com/en/docs/refresh-token-api
sourcepub fn refresh_access_token_blocking(
&self,
expired_at: Option<OffsetDateTime>
) -> Result<String>
Available on crate feature blocking only.
pub fn refresh_access_token_blocking( &self, expired_at: Option<OffsetDateTime> ) -> Result<String>
blocking only.Gets a new access_token, and also replaces the access_token in
Config.
expired_at - The expiration time of the access token, defaults to 90
days.
Reference: https://open.longbridgeapp.com/en/docs/refresh-token-api