Skip to content

Earthware/hull-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hull C# client

Installation

Using NuGet:

Install-Package Hull.CSharp

Usage

Configuration

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.

HullClient: Making API Calls

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;

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

C# API for calling the Hull.io service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages