Using NuGet:
Install-Package Hull.CSharp
Add entries to your Web.config or App.config:
<appSettings>
<add key="Hull.AppId" value="YOUR_APP_ID" />
<add key="Hull.AppSecret" value="YOUR_APP_SECRET" />
<add key="Hull.OrgUrl" value="YOUR_ORG_URL" />
</appSettings>
Use the HullClient class to make API calls. If you are using an IoC container to manage HullClient instances in web applications, you should use a Per Request lifestyle. The HullConfiguration class can be configured as a Singleton.
get
, put
, post
and delete
methods are directly available on HullClient.
You can call each by providing an endpoint path:
hullClient.get('app');
To include parameters, include a Dictionary<string, string> as an argument:
// Will convert to request params for GET/DELETEs
var params = new Dictionary<string, string>();
params.Add("limit", 10);
params.Add("page", 2);
hullClient.Get("app/comments", params);
// Will convert to body params for POST/PUTs
var params = new Dictionary<string, string>();
params.Add("name", "My new name");
hullClient.Put('app', params);
To use Hull entities :
var params = new Dictionary<string, string>();
params.Add("uid", "http://example.com");
// Retrieve entity
hullClient.Get("entity", params);
// Update entity
params.Add("name", "My new name");
hullClient.Put("entity", params);
When you wish to make the call in the context of a different user, pass the User ID as an additional parameter:
var responseString = hullClient.Get("me", null, USER_ID);
For methods that accept a type constraint, the library will attempt to deserialize the Hull response into a new instance of the type you specify:
var deserializedResponse = hullClient.Get<MyUserType>("me", null, USER_ID);
###Utility methods for accessing the Hull cookie
If you need to access the Hull cookie server-side, you can use the HullCookie class to validate the cookie and extract the data.
// Grab cookie in whatever format your framework uses
string cookieVal = Request.Cookies["hull_51acbcd12345667"].Content; // make sure you're using your appId for the cookie name
var cookie = new HullCookie(cookieVal);
var userIsAuthenticated = cookie.IsValid;
var authenticatedUserId = cookie.UserId;
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request