@@ -3,7 +3,10 @@ use std::sync::Arc;
33use longbridge_httpcli:: { HttpClient , Json , Method } ;
44use serde:: Deserialize ;
55
6- use super :: types:: { CreateTopicOptions , MyTopicsOptions , NewsItem , OwnedTopic , TopicItem } ;
6+ use super :: types:: {
7+ CreateReplyOptions , CreateTopicOptions , ListTopicRepliesOptions , MyTopicsOptions , NewsItem ,
8+ OwnedTopic , TopicItem , TopicReply ,
9+ } ;
710use crate :: { Config , Result } ;
811
912struct InnerContentContext {
@@ -22,9 +25,9 @@ impl ContentContext {
2225 } ) )
2326 }
2427
25- /// Get topics created by the current authenticated user
28+ /// Get topics created by the current authenticated user.
2629 ///
27- /// Path: GET /v1/content/topics/mine
30+ /// See: <https://open.longbridge.com/docs/api?op=list_my_topics>
2831 pub async fn my_topics ( & self , opts : MyTopicsOptions ) -> Result < Vec < OwnedTopic > > {
2932 #[ derive( Debug , Deserialize ) ]
3033 struct Response {
@@ -43,9 +46,9 @@ impl ContentContext {
4346 . items )
4447 }
4548
46- /// Create a new topic
49+ /// Create a new community topic.
4750 ///
48- /// Path: POST /v1/content/topics
51+ /// See: <https://open.longbridge.com/docs/api?op=create_topic>
4952 pub async fn create_topic ( & self , opts : CreateTopicOptions ) -> Result < String > {
5053 #[ derive( Debug , Deserialize ) ]
5154 struct TopicId {
@@ -89,6 +92,85 @@ impl ContentContext {
8992 . items )
9093 }
9194
95+ /// Get full details of a topic by its ID.
96+ ///
97+ /// See: <https://open.longbridge.com/docs/api?op=topic_detail>
98+ pub async fn topic_detail ( & self , id : impl Into < String > ) -> Result < OwnedTopic > {
99+ #[ derive( Debug , Deserialize ) ]
100+ struct Response {
101+ item : OwnedTopic ,
102+ }
103+
104+ let id = id. into ( ) ;
105+ Ok ( self
106+ . 0
107+ . http_cli
108+ . request ( Method :: GET , format ! ( "/v1/content/topics/{id}" ) )
109+ . response :: < Json < Response > > ( )
110+ . send ( )
111+ . await ?
112+ . 0
113+ . item )
114+ }
115+
116+ /// List replies on a topic.
117+ ///
118+ /// See: <https://open.longbridge.com/docs/api?op=list_topic_replies>
119+ pub async fn list_topic_replies (
120+ & self ,
121+ topic_id : impl Into < String > ,
122+ opts : ListTopicRepliesOptions ,
123+ ) -> Result < Vec < TopicReply > > {
124+ #[ derive( Debug , Deserialize ) ]
125+ struct Response {
126+ items : Vec < TopicReply > ,
127+ }
128+
129+ let topic_id = topic_id. into ( ) ;
130+ Ok ( self
131+ . 0
132+ . http_cli
133+ . request (
134+ Method :: GET ,
135+ format ! ( "/v1/content/topics/{topic_id}/comments" ) ,
136+ )
137+ . query_params ( opts)
138+ . response :: < Json < Response > > ( )
139+ . send ( )
140+ . await ?
141+ . 0
142+ . items )
143+ }
144+
145+ /// Post a reply to a community topic.
146+ ///
147+ /// See: <https://open.longbridge.com/docs/api?op=create_topic_reply>
148+ pub async fn create_topic_reply (
149+ & self ,
150+ topic_id : impl Into < String > ,
151+ opts : CreateReplyOptions ,
152+ ) -> Result < TopicReply > {
153+ #[ derive( Debug , Deserialize ) ]
154+ struct Response {
155+ item : TopicReply ,
156+ }
157+
158+ let topic_id = topic_id. into ( ) ;
159+ Ok ( self
160+ . 0
161+ . http_cli
162+ . request (
163+ Method :: POST ,
164+ format ! ( "/v1/content/topics/{topic_id}/comments" ) ,
165+ )
166+ . body ( Json ( opts) )
167+ . response :: < Json < Response > > ( )
168+ . send ( )
169+ . await ?
170+ . 0
171+ . item )
172+ }
173+
92174 /// Get news list
93175 pub async fn news ( & self , symbol : impl Into < String > ) -> Result < Vec < NewsItem > > {
94176 #[ derive( Debug , Deserialize ) ]
0 commit comments