Repository navigation
Adds the AP account money-movement, reward and coupon APIs on AssetContext and CashInfo.RedemptionCash.
Added
-
CashInfo.RedemptionCash(ports longbridge/openapiCashInfo.redemption_cash) —GET /v1/asset/accountreturnsredemption_cashin everycash_infosentry, and the OpenAPI reference documents it as redeemable cash, butAccountBalancedropped it. It isnilwhen a response omits it -
Account money-movement and reward records on
AssetContext— all AP accounts only (US sessions get*http.RegionRestrictedErrorwithout sending the request; there is no US equivalent), OAuth scopeaccount.read:BankCards(ctx)(GET /v2/account/bank-cards): linked cards (IDis a digit string) withStatus(BankCardStatus),WitnessState,BindStateandAuthList(eDDA / bank-securities / FPS authorizations;BankCardAuth.IsEDDA()forhk_edda/hk_sdda,StatusasAuthorizationStatus,Message= failure reason).EddaApplications(ctx, cardID string, currency)(GET /v1/account/edda-status):cardIDisBankCard.IDand 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): filtersMarket,State,Start/End(time.Time, sent as unix seconds — pass Hong Kong (UTC+8) day bounds for a user's calendar dates),Page/Size; typedTransferInState/TransferOutState, per-stockStateCodeasTransferStockState;UserNotifiedBroker()(the user's own "I have notified the broker" tap);StockTransferOut.Cancellable()(only the submitted state — upstreamcan_modifyis 0 even then).RewardRecords(ctx, *GetRewardRecords)(GET /v1/account/rewards): items flattened from theircash/card/prizeobject, withRewardType,RewardStatus;CardStatusapplies only to coupon rewards andDeliverStatusonly to prizes (each is its…Unknownconstant otherwise, as in the Rust SDK); the server sends both 9 and 11 for "address filled", so useRewardDeliverStatus.IsAddressFilled();PrizeTypeis 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,NoExpiryfor 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 sendsnull:AiBenefit,Cash,CoffeeCoupon(withStoreList),Commission(withAmountLimit,Superposition,CommissionDurationin seconds andUnlimitedas aCommissionUnlimitedType: 0 time-limited free commission, 1 rebate, 2 deduction, 6 per-use fixed amount, 7 per-use discount capped atAmountLimit),Crypto,FinanceInterest,FundDeduct,FundamentalandQuote(bothCouponQuote, withQuoteInvestorType),Ipo,IpoCommission(IpoCouponTargetType),IpoInterest,PlatformFeeDeduct,StockandStockFragment(Amountsasmap[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 unusablebz_typesentries) and non-object cards are skipped. Thefund_interestobject (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):Statessent as numeric codes,Currencies, and newStart/Enddate filters (from_date/to_date);VoucherCountis the number of receipt vouchers uploaded (the receipt images themselves are not modelled);Sizeis capped at 20 because the endpoint silently returns only 10 records for a size of 21–50; the upstreamtotalfollows the page size, so it is not exposed —HasMorereports that a full page (of the size actually sent) came back.Withdrawals(ctx, *GetWithdrawals)(GET /v1/account/withdrawals): newStart/Enddate filters (begin/end);StateCodeis the typed state andStateDescriptionthe text;HasMorereports 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
XxxUnknownconstant (-1) instead of 0 (a real state in most tables); any integer — including an integral float such as2.0— is kept as is, even when the type has no constant for it (e.g.deliver_status11 stays 11). Page sizes default to 20 and are capped at 50 (20 forDeposits). On deposit, withdrawal and stock transfer recordsStateCodeis the typed code andState/StateDescriptionthe display text. -
The account routes except
CouponOrderssendaccount_channel(as the Longbridge app and CLI do), read from the access token's JWT payload (acclaim, oraccount_channelin thesubclaim), defaulting tolbwhen 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.ClientgainsAccountChannelCtx. -
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'sCouponNois 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.FinanceCalendardocs describe per-date paging (ports longbridge/openapi#633, from longbridge/developers#1339) —countcaps the events returned for each date (not per page),offsetskips events within a date, aCalendarDateGroupholding fewerInfosthan itsCountwas truncated (call again withstart=end= that date andoffset= events already received),NextDatemoves past truncated dates, andendis not a hard bound, so filter by date on the client. No code or signature changes