Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
/ Freshdesk.NET Public archive

Freshdesk REST Client

License

Notifications You must be signed in to change notification settings

jscarle/Freshdesk.NET

Repository files navigation

Freshdesk.NET - Freshdesk REST Client

The Freshdesk REST Client is designed to abstract Freshdesk's JSON API and present the developer with a simplified and strongly typed implementation. Much of the underlying mechanics have therefore purposefully been abstracted behind private modifiers.

Release Notes

The current release notes can be read in CHANGELOG.md.

Dependencies

Both RestSharp and Newtonsoft.Json are required dependencies.

Quick Start

Make sure to consult the Wiki for the full documentation.

Creating an instance of the client

string freshdeskDomain = "yourcompany.freshdesk.com";
string apiKey = "yourapikey";
FreshdeskClient freshdesk = new FreshdeskClient(freshdeskDomain, apiKey, "X");

Retrieving all contacts

(Response response, List<Contact> contacts) = freshdesk.GetContacts();
if (response.StatusCode == HttpStatusCode.OK)
    Console.WriteLine(contacts.Count);

Retrieving a single contact

(Response response, Contact contact) = freshdesk.GetContact(28000000000);
if (response.StatusCode == HttpStatusCode.OK)
    Console.WriteLine(contact.Name);

Creating a contact

NewContact newContact = new NewContact();
newContact.Name = "Iosef Tarasov";
newContact.Email = "iosef [email protected]";
(Response response, Contact contact) = freshdesk.CreateContact(newContact);
if (response.StatusCode == HttpStatusCode.Created)
    Console.WriteLine(contact.ID);

Updating a contact

Contact contact = new Contact();
contact.ID = 28000000002;
contact.Name = "John Wick";
contact.Email = "[email protected]";
(Response response, Contact contact) = freshdesk.UpdateContact(contact);
if (response.StatusCode == HttpStatusCode.OK)
    Console.WriteLine(contact.Name);

Deleting a contact

Response response = freshdesk.DeleteContact(28000000001);
if (response.StatusCode == HttpStatusCode.NoContent)
    Console.WriteLine("Iosef didn't make it.");