SharphConduit is a C# library which implements the Phabricator API.
While still in development, certain areas are mostly complete:
* Maniphest
* Projects
* Paste
Other areas have barely any functionality yet.
== Usage
Firstly, grab yourself an API token from https://phabricator.example.com/conduit/token/
Then, create a new instance of ConduitClient:
``` lang=csharp
using Stwalkerster.SharphConduit;
private static void Main()
{
string phabUrl = "https://phabricator.example.com/";
string token = "api-xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var client = new ConduitClient(phabUrl, token);
}
```
This client implements the underlying protocol of Conduit, allowing you to do things like this:
``` lang=csharp
dynamic result = client.CallMethod("user.whoami", new Dictionary<string, dynamic>());
```
Or something more complex:
``` lang=csharp
dynamic response = client.CallMethod(
"phid.lookup",
new Dictionary<string, dynamic> { { "names", new[] { "T112", "T439" } } });
```
However, that's boring. For some applications, these API calls have already been wrapped up for you!
== ApplicationEditor-capable APIs (including Maniphest) ==
Take your `client` from earlier, and use it to create a new instance of `Maniphest`:
``` lang=csharp
using Stwalkerster.SharphConduit.Applications.Maniphest;
```
``` lang=csharp
var maniphest = new Maniphest(client);
```
Application editor APIs provide two methods to call: `Edit(...)` and `Search(...)`
=== Search ===
Search requests can pass in a base query to start the search with, or a set of constraints to apply.
To add a constraint, construct an instance of `ApplicationEditorSearchConstraint` like this:
``` lang=csharp
var constraint = ManiphestSearchConstraintFactory.Statuses(new List<string> { "open" });
```
Or, if that doesn't provide you with the flexibility you need:
``` lang=csharp
var constraint = new ApplicationEditorSearchConstraint {Type = "fulltext", Value = "foo bar"};
```
You can consult the relevant API documentation to find the constraint types you can use at https://phabricator.example.com/conduit/method/maniphest.search/ .
NOTE: Some constraints expect PHIDs rather than actual names or IDs. You can find these easily by using PHIDLookup.
Once you have your constraints, you can pass the collection of them to the Search method:
``` lang=csharp
var constraint = ManiphestSearchConstraintFactory.Statuses(new List<string> { "open" });
var searchConstraints = new List<ApplicationEditorSearchConstraint> { constraint };
IEnumerable<ManiphestTask> response = maniphest.Search(constraints: searchConstraints);
```
=== Edit ===
Editing is much simpler.
Either get yourself an instance of a ManiphestTask from the client (by search) if you want to edit, or create a new instance of ManiphestTask if you want to create a new task.
``` lang=csharp
var task = new ManiphestTask();
```
Then, just set the properties you want to set:
``` lang=csharp
task.Title = "Example task";
task.Description = "Example description";
```
Finally, pass your task to Maniphest:
``` lang=csharp
maniphest.Edit(task);
```