From b346abf49c1538893330a16ff14f14b6ac245b80 Mon Sep 17 00:00:00 2001 From: durop Date: Thu, 27 Aug 2015 11:47:10 -0300 Subject: [PATCH 1/3] Companies.cs Simply added post method for companies. --- IntercomDotnet/Resources/Companies.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 IntercomDotnet/Resources/Companies.cs diff --git a/IntercomDotnet/Resources/Companies.cs b/IntercomDotnet/Resources/Companies.cs new file mode 100644 index 0000000..c936ce1 --- /dev/null +++ b/IntercomDotnet/Resources/Companies.cs @@ -0,0 +1,25 @@ +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); + }); + } + } +} From 049634ec2be54bf6f3df20f8976c0ec267575f2b Mon Sep 17 00:00:00 2001 From: durop Date: Thu, 27 Aug 2015 11:49:04 -0300 Subject: [PATCH 2/3] Update IntercomClient. Added Companies classs. --- IntercomDotnet/IntercomClient.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/IntercomDotnet/IntercomClient.cs b/IntercomDotnet/IntercomClient.cs index a86e924..81cdb36 100644 --- a/IntercomDotnet/IntercomClient.cs +++ b/IntercomDotnet/IntercomClient.cs @@ -1,4 +1,4 @@ -using IntercomDotNet.Resources; +using IntercomDotNet.Resources; namespace IntercomDotNet { @@ -20,16 +20,18 @@ 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; } @@ -37,5 +39,6 @@ private IntercomClient(Users users, Notes notes, Tags tags, Events events, Segme public Tags Tags { get; private set; } public Events Events { get; private set; } public Segments Segments { get; private set; } + public Companies Companies { get; private set; } } } From 0218ddcd44ac6d2ea6e3ddf2f70291d5418acf31 Mon Sep 17 00:00:00 2001 From: durop Date: Thu, 27 Aug 2015 14:36:39 -0300 Subject: [PATCH 3/3] Added get methods --- IntercomDotnet/Resources/Companies.cs | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/IntercomDotnet/Resources/Companies.cs b/IntercomDotnet/Resources/Companies.cs index c936ce1..e9f1b83 100644 --- a/IntercomDotnet/Resources/Companies.cs +++ b/IntercomDotnet/Resources/Companies.cs @@ -21,5 +21,41 @@ public dynamic Post(object hash) 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); + }); + } } }