Skip to content

Commit

Permalink
Merge pull request tarr11#10 from durop/master
Browse files Browse the repository at this point in the history
Added Companies post.
  • Loading branch information
mgoodfellow committed Aug 27, 2015
2 parents 726cb52 + 0218ddc commit 22bbed2
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
9 changes: 6 additions & 3 deletions IntercomDotnet/IntercomClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using IntercomDotNet.Resources;
using IntercomDotNet.Resources;

namespace IntercomDotNet
{
Expand All @@ -20,22 +20,25 @@ public static IntercomClient GetClient(string appid, string apiKey)
new Notes(client),
new Tags(client),
new Events(client),
new Segments(client));
new Segments(client),
new Companies(client));
}

private IntercomClient(Users users, Notes notes, Tags tags, Events events, Segments segments)
private IntercomClient(Users users, Notes notes, Tags tags, Events events, Segments segments, Companies companies)
{
Users = users;
Notes = notes;
Tags = tags;
Events = events;
Segments = segments;
Companies = companies;
}

public Users Users { get; private set; }
public Notes Notes { get; private set; }
public Tags Tags { get; private set; }
public Events Events { get; private set; }
public Segments Segments { get; private set; }
public Companies Companies { get; private set; }
}
}
61 changes: 61 additions & 0 deletions IntercomDotnet/Resources/Companies.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IntercomDotNet.Resources
{
public class Companies : Resource
{
public Companies(Client client) : base(client, "companies")
{
}

public dynamic Post(object hash)
{
return Client.Execute(BaseUrl, Method.POST, request =>
{
request.RequestFormat = DataFormat.Json;
request.AddBody(hash);
});
}

public dynamic Get(string name, string companyId)
{
return Client.Execute(BaseUrl, Method.GET, request =>
{
if (name != null)
request.AddParameter("name", name);

if (companyId != null)
request.AddParameter("company_id", companyId);
});
}

public dynamic GetCompanyList(string tagId = null, string segmentId = null)
{
return Client.Execute(BaseUrl, Method.GET, request =>
{
if (tagId != null)
request.AddParameter("tag_id", tagId);

if (segmentId != null)
request.AddParameter("segment_id", segmentId);
});
}

public dynamic GetCompanyList(int page = 1, int perPage = 50, string order = null)
{
return Client.Execute(BaseUrl, Method.GET, request =>
{
request.AddParameter("page", page);
request.AddParameter("per_page", perPage);

if (order != null)
request.AddParameter("order", order);
});
}
}
}

0 comments on commit 22bbed2

Please sign in to comment.