@@ -34,6 +34,10 @@ public class Conversation : IWatsonService
3434 {
3535 #region Public Types
3636 /// <summary>
37+ /// The callback for GetWorkspaces().
38+ /// </summary>
39+ public delegate void OnGetWorkspaces ( DataModels . Workspaces workspaces ) ;
40+ /// <summary>
3741 /// The callback for Message().
3842 /// </summary>
3943 /// <param name="success"></param>
@@ -43,6 +47,7 @@ public class Conversation : IWatsonService
4347 /// </summary>
4448 /// <param name="resp">The response object to a call to Converse().</param>
4549 public delegate void OnMessage ( DataModels . MessageResponse resp ) ;
50+
4651 #endregion
4752
4853 #region Public Properties
@@ -53,6 +58,62 @@ public class Conversation : IWatsonService
5358 private static fsSerializer sm_Serializer = new fsSerializer ( ) ;
5459 #endregion
5560
61+ #region Workspaces
62+ /// <summary>
63+ /// Gets the available workspaces for the Conversation service
64+ /// </summary>
65+ /// <returns>Returns true if request has been sent.</returns>
66+ /// <param name="callback">Callback.</param>
67+ public bool GetWorkspaces ( OnGetWorkspaces callback )
68+ {
69+ if ( callback == null )
70+ throw new ArgumentNullException ( "callback" ) ;
71+
72+ RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , "/v2/rest/workspaces" ) ;
73+ if ( connector == null )
74+ return false ;
75+
76+ GetWorkspacesReq req = new GetWorkspacesReq ( ) ;
77+ req . Callback = callback ;
78+ req . OnResponse = OnGetWorkspacesResp ;
79+
80+ return connector . Send ( req ) ;
81+ }
82+
83+ private class GetWorkspacesReq : RESTConnector . Request
84+ {
85+ public OnGetWorkspaces Callback { get ; set ; }
86+ }
87+
88+ private void OnGetWorkspacesResp ( RESTConnector . Request req , RESTConnector . Response resp )
89+ {
90+ DataModels . Workspaces workspaces = new DataModels . Workspaces ( ) ;
91+ if ( resp . Success )
92+ {
93+ try
94+ {
95+ fsData data = null ;
96+ fsResult r = fsJsonParser . Parse ( Encoding . UTF8 . GetString ( resp . Data ) , out data ) ;
97+ if ( ! r . Succeeded )
98+ throw new WatsonException ( r . FormattedMessages ) ;
99+
100+ object obj = workspaces ;
101+ r = sm_Serializer . TryDeserialize ( data , obj . GetType ( ) , ref obj ) ;
102+ if ( ! r . Succeeded )
103+ throw new WatsonException ( r . FormattedMessages ) ;
104+ }
105+ catch ( Exception e )
106+ {
107+ Log . Error ( "Conversation" , "GetWorkspaces Exception: {0}" , e . ToString ( ) ) ;
108+ resp . Success = false ;
109+ }
110+ }
111+
112+ if ( ( ( GetWorkspacesReq ) req ) . Callback != null )
113+ ( ( GetWorkspacesReq ) req ) . Callback ( resp . Success ? workspaces : null ) ;
114+ }
115+ #endregion
116+
56117 #region Message
57118 /// <summary>
58119 /// Message the specified workspaceId, input and callback.
@@ -120,6 +181,15 @@ private void MessageResp(RESTConnector.Request req, RESTConnector.Response resp)
120181 }
121182 #endregion
122183
184+ #region Intents
185+ #endregion
186+
187+ #region Entities
188+ #endregion
189+
190+ #region Dialog Nodes
191+ #endregion
192+
123193 #region IWatsonService implementation
124194
125195 public string GetServiceID ( )
0 commit comments