Skip to content

v0.32.0

Latest

Choose a tag to compare

@hogan-yuan hogan-yuan released this 27 Nov 07:29
f97adce

Adds the AP account money-movement, reward and coupon APIs on AssetContext and CashInfo.RedemptionCash.

Added

  • CashInfo.RedemptionCash (ports longbridge/openapi CashInfo.redemption_cash) — GET /v1/asset/account returns redemption_cash in every cash_infos entry, and the OpenAPI reference documents it as redeemable cash, but AccountBalance dropped it. It is nil when a response omits it

  • Account money-movement and reward records on AssetContext — all AP accounts only (US sessions get *http.RegionRestrictedError without sending the request; there is no US equivalent), OAuth scope account.read:

    • BankCards(ctx) (GET /v2/account/bank-cards): linked cards (ID is a digit string) with Status (BankCardStatus), WitnessState, BindState and AuthList (eDDA / bank-securities / FPS authorizations; BankCardAuth.IsEDDA() for hk_edda / hk_sdda, Status as AuthorizationStatus, Message = failure reason).
    • EddaApplications(ctx, cardID string, currency) (GET /v1/account/edda-status): cardID is BankCard.ID and must be all digits; accepts both the {list[]} reply and the single-object reply of older builds.
    • StockTransfersIn(ctx, *GetStockTransfers) / StockTransfersOut(ctx, *GetStockTransfers) (GET /v1/account/stock-transfers/in|out): filters Market, State, Start / End (time.Time, sent as unix seconds — pass Hong Kong (UTC+8) day bounds for a user's calendar dates), Page / Size; typed TransferInState / TransferOutState, per-stock StateCode as TransferStockState; UserNotifiedBroker() (the user's own "I have notified the broker" tap); StockTransferOut.Cancellable() (only the submitted state — upstream can_modify is 0 even then).
    • RewardRecords(ctx, *GetRewardRecords) (GET /v1/account/rewards): items flattened from their cash / card / prize object, with RewardType, RewardStatus; CardStatus applies only to coupon rewards and DeliverStatus only to prizes (each is its …Unknown constant otherwise, as in the Rust SDK); the server sends both 9 and 11 for "address filled", so use RewardDeliverStatus.IsAddressFilled(); PrizeType is a pointer, nil except on prizes; a record without a detail object has every status …Unknown.
    • Coupons(ctx, *GetCoupons) (GET /v1/account/cards): TopList / List / BottomList (the pinned sections repeat on every page), CouponStatus, NoExpiry for an end time past 2100, millisecond end times converted, SubscriptionID, and the per-type terms as pointer fields named after the card type, nil when upstream sends null: AiBenefit, Cash, CoffeeCoupon (with StoreList), Commission (with AmountLimit, Superposition, CommissionDuration in seconds and Unlimited as a CommissionUnlimitedType: 0 time-limited free commission, 1 rebate, 2 deduction, 6 per-use fixed amount, 7 per-use discount capped at AmountLimit), Crypto, FinanceInterest, FundDeduct, Fundamental and Quote (both CouponQuote, with QuoteInvestorType), Ipo, IpoCommission (IpoCouponTargetType), IpoInterest, PlatformFeeDeduct, Stock and StockFragment (Amounts as map[string]string). Proto enums (CouponTargetType, IpoCouponTargetType, CommissionUnlimitedType, QuoteInvestorType) decode from either the enum name (e.g. HkStockWarrant) or the number. Decoding is lenient so one odd card never fails the page: a per-type object that is not a JSON object decodes to nil, a nested list that is not an array decodes to empty, and malformed list entries (including unusable bz_types entries) and non-object cards are skipped. The fund_interest object (an arbitrary object in the proto) and app styling are not modelled.
    • CouponOrders(ctx, cardID, CouponOrderTypeLocked|CouponOrderTypeSettled) (GET /v1/account/card-orders).
    • Deposits(ctx, *GetDeposits) (GET /v1/account/deposits): States sent as numeric codes, Currencies, and new Start / End date filters (from_date / to_date); VoucherCount is the number of receipt vouchers uploaded (the receipt images themselves are not modelled); Size is capped at 20 because the endpoint silently returns only 10 records for a size of 21–50; the upstream total follows the page size, so it is not exposed — HasMore reports that a full page (of the size actually sent) came back.
    • Withdrawals(ctx, *GetWithdrawals) (GET /v1/account/withdrawals): new Start / End date filters (begin / end); StateCode is the typed state and StateDescription the text; HasMore reports a full page.
  • One rule for every integer code type (statuses, states and coupon enums): a code upstream omitted, sent as null or sent as something that is neither an integer nor a known enum name decodes to the type's XxxUnknown constant (-1) instead of 0 (a real state in most tables); any integer — including an integral float such as 2.0 — is kept as is, even when the type has no constant for it (e.g. deliver_status 11 stays 11). Page sizes default to 20 and are capped at 50 (20 for Deposits). On deposit, withdrawal and stock transfer records StateCode is the typed code and State / StateDescription the display text.

  • The account routes except CouponOrders send account_channel (as the Longbridge app and CLI do), read from the access token's JWT payload (ac claim, or account_channel in the sub claim), defaulting to lb when the token names none, as the Rust SDK and MCP do; it is left out only when the token is not a decodable JWT. http.Client gains AccountChannelCtx.

  • Timestamps are time.Time (UTC); upstream placeholders (0, "0", negative values, 1906 / 1970 dates, the 9999-12-31 long-term sentinel) decode to the zero time. Upstream fields carrying personal data — account holder names and postal addresses, ID / proof-document storage keys, contact people, deposit receipt images, prize redemption secrets (coupon_secret, cash_card_code), prize delivery details — are not modelled. A coffee coupon's CouponNo is kept: it is the voucher template code (e.g. coffee-50), not a personal redemption code. Account numbers are returned as upstream sends them (not masked).

Fixed

  • CalendarContext.FinanceCalendar docs describe per-date paging (ports longbridge/openapi#633, from longbridge/developers#1339) — count caps the events returned for each date (not per page), offset skips events within a date, a CalendarDateGroup holding fewer Infos than its Count was truncated (call again with start = end = that date and offset = events already received), NextDate moves past truncated dates, and end is not a hard bound, so filter by date on the client. No code or signature changes