Skip to content

Commit 89487c7

Browse files
feat(client): DoCommand variants
1 parent f16adeb commit 89487c7

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

src/IpfsClient.cs

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,23 @@ WebClient Api()
122122
return api;
123123
}
124124

125-
protected internal string DoCommand(string command, string arg = null, params string[] options)
125+
/// <summary>
126+
/// Perform an <see href="https://ipfs.io/docs/api/">IPFS API command</see> returning a string.
127+
/// </summary>
128+
/// <param name="command">
129+
/// The <see href="https://ipfs.io/docs/api/">IPFS API command</see>, such as
130+
/// <see href="https://ipfs.io/docs/api/#apiv0filels">"file/ls"</see>.
131+
/// </param>
132+
/// <param name="arg">
133+
/// The optional argument to the command.
134+
/// </param>
135+
/// <param name="options">
136+
/// The optional flags to the command.
137+
/// </param>
138+
/// <returns>
139+
/// A string representation of the command's result.
140+
/// </returns>
141+
public string DoCommand(string command, string arg = null, params string[] options)
126142
{
127143
try
128144
{
@@ -140,13 +156,54 @@ protected internal string DoCommand(string command, string arg = null, params st
140156
}
141157
}
142158

143-
protected internal T DoCommand<T>(string command, string arg = null, params string[] options)
159+
/// <summary>
160+
/// Perform an <see href="https://ipfs.io/docs/api/">IPFS API command</see> returning
161+
/// a specific <see cref="Type"/>.
162+
/// </summary>
163+
/// <typeparam name="T">
164+
/// The <see cref="Type"/> of object to return.
165+
/// </typeparam>
166+
/// <param name="command">
167+
/// The <see href="https://ipfs.io/docs/api/">IPFS API command</see>, such as
168+
/// <see href="https://ipfs.io/docs/api/#apiv0filels">"file/ls"</see>.
169+
/// </param>
170+
/// <param name="arg">
171+
/// The optional argument to the command.
172+
/// </param>
173+
/// <param name="options">
174+
/// The optional flags to the command.
175+
/// </param>
176+
/// <returns>
177+
/// A <typeparamref name="T"/>.
178+
/// </returns>
179+
/// <remarks>
180+
/// The command's response is converted to <typeparamref name="T"/> using
181+
/// <c>JsonConvert</c>.
182+
/// </remarks>
183+
public T DoCommand<T>(string command, string arg = null, params string[] options)
144184
{
145185
var json = DoCommand(command, arg, options);
146186
return JsonConvert.DeserializeObject<T>(json);
147187
}
148188

149-
protected internal Stream Download(string command, string arg = null, params string[] options)
189+
/// <summary>
190+
/// Perform an <see href="https://ipfs.io/docs/api/">IPFS API command</see> returning a
191+
/// <see cref="Stream"/>.
192+
/// </summary>
193+
/// <param name="command">
194+
/// The <see href="https://ipfs.io/docs/api/">IPFS API command</see>, such as
195+
/// <see href="https://ipfs.io/docs/api/#apiv0filels">"file/ls"</see>.
196+
/// </param>
197+
/// <param name="arg">
198+
/// The optional argument to the command.
199+
/// </param>
200+
/// <param name="options">
201+
/// The optional flags to the command.
202+
/// </param>
203+
/// <returns>
204+
/// A <see cref="Stream"/> containing the command's result.
205+
/// </returns>
206+
public Stream Download(string command, string arg = null, params string[] options)
150207
{
151208
try
152209
{

0 commit comments

Comments
 (0)