Skip to main content

AssetContext

Struct AssetContext 

Source
pub struct AssetContext(/* private fields */);
Expand description

Asset context

Implementations§

Source§

impl AssetContext

Source

pub fn new(config: Arc<Config>) -> Self

Create a AssetContext

Source

pub fn log_subscriber(&self) -> Arc<dyn Subscriber + Send + Sync> ⓘ

Returns the log subscriber

Source

pub async fn statements( &self, options: GetStatementListOptions, ) -> Result<GetStatementListResponse>

Get statement data list

Path: GET /v1/statement/list

Source

pub async fn statement_download_url( &self, options: GetStatementOptions, ) -> Result<GetStatementResponse>

Get statement data download url

Path: GET /v1/statement/download

Source

pub async fn bank_cards(&self) -> Result<Vec<BankCard>>

Get the linked bank cards, with their verification, binding and authorization (eDDA, bank securities account, FPS) status

AP accounts only: US data-center accounts get a region error.

Path: GET /v2/account/bank-cards

§Examples
use std::sync::Arc;

use longbridge::{Config, asset::AssetContext, oauth::OAuthBuilder};

let oauth = OAuthBuilder::new("your-client-id")
    .build(|url| println!("Visit: {url}"))
    .await?;
let config = Arc::new(Config::from_oauth(oauth));
let ctx = AssetContext::new(config);

for card in ctx.bank_cards().await? {
    println!("{} {:?}", card.bank, card.status);
}
Source

pub async fn edda_applications( &self, card_id: impl Into<String>, currency: impl Into<String>, ) -> Result<Vec<EddaApplication>>

Get the eDDA authorization applications of a bank card in one currency

card_id is BankCard::id; currency is e.g. HKD or USD.

AP accounts only: US data-center accounts get a region error.

Path: GET /v1/account/edda-status

Source

pub async fn stock_transfers_in( &self, options: impl Into<Option<GetStockTransfersInOptions>>, ) -> Result<StockTransferInResponse>

Get stock transfer-in applications (another broker → this account)

AP accounts only: US data-center accounts get a region error.

Path: GET /v1/account/stock-transfers/in

Source

pub async fn stock_transfers_out( &self, options: impl Into<Option<GetStockTransfersOutOptions>>, ) -> Result<Vec<StockTransferOut>>

Get stock transfer-out applications (this account → another broker)

AP accounts only: US data-center accounts get a region error.

Path: GET /v1/account/stock-transfers/out

Source

pub async fn reward_records( &self, options: impl Into<Option<GetRewardRecordsOptions>>, ) -> Result<RewardRecordsResponse>

Get reward records from the reward center (cash, gifts, coupons, task rewards)

The route has no date filter: to find rewards in a time range, page through the records and filter on their times.

AP accounts only: US data-center accounts get a region error.

Path: GET /v1/account/rewards

Source

pub async fn coupons( &self, options: impl Into<Option<GetCouponsOptions>>, ) -> Result<CouponsResponse>

Get coupons (reward cards)

By default lists the coupons that have not expired; see GetCouponsOptions::expired. The pinned top_list / bottom_list are repeated on every page.

AP accounts only: US data-center accounts get a region error.

Path: GET /v1/account/cards

Source

pub async fn coupon_orders( &self, card_id: impl Into<String>, order_type: CouponOrderType, ) -> Result<Vec<CouponOrder>>

Get the orders a coupon was applied to

card_id is crate::asset::Coupon::card_id (32 hex characters, not a bank card ID). The gateway rate-limits this route tightly per member, so avoid calling it concurrently.

AP accounts only: US data-center accounts get a region error.

Path: GET /v1/account/card-orders

Source

pub async fn deposits( &self, options: impl Into<Option<GetDepositsOptions>>, ) -> Result<DepositsResponse>

Get deposit records

The server’s total follows the page size rather than the record count, so it is not returned; DepositsResponse::has_more reports a full page instead. The page size is at most 20 and defaults to 20 (see GetDepositsOptions::size); it is always sent.

AP accounts only: US data-center accounts get a region error.

Path: GET /v1/account/deposits

Source

pub async fn withdrawals( &self, options: impl Into<Option<GetWithdrawalsOptions>>, ) -> Result<WithdrawalsResponse>

Get withdrawal records

WithdrawalsResponse::has_more reports a full page. The page size is at most 50 and defaults to 20 (see GetWithdrawalsOptions::size); it is always sent.

AP accounts only: US data-center accounts get a region error.

Path: GET /v1/account/withdrawals

Trait Implementations§

Source§

impl Clone for AssetContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more