Skip to content

A lightweight wrapper around the Freshdesk REST API as described here: https://developers.freshdesk.com/api

License

Notifications You must be signed in to change notification settings

trejjam/FreshdeskApiDotnet

 
 

Repository files navigation

Build Status NuGet MyGet

Freshdesk API Client

This is a dotnet standard library providing a thin wrapper around the Freshdesk API as described here: https://developers.freshdesk.com/api.

At present this library requires .NET Standard 2.1 (for IAsyncEnumerable), if I get interest then I'll build a version of the library which doesn't make use of that feature and is therefore available in .NET Standard 2.0 (or possibly lower)

Usage

This library provides a single client class which can be created in one of several ways:

  1. No existing HttpClient object (suitable for console applications)
using var freshdeskHttpClient = FreshdeskHttpClient.Create("https://mydomain.freshdesk.com", "APIKEY");
var freshdeskClient = FreshdeskClient.Create(freshdeskHttpClient);

NOTE: Disposing the freshdeskClient will dispose the HttpClient object, as per https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/ you need to be careful when disposing HttpClient objects. Broadly speaking, don't make and dispose lots of FreshdeskClient objects using this model.

  1. Existing HttpClient object (suitable for asp.net applications or cases where you want more control over the HttpClient)
var freshdeskHttpClient = new FreshdeskHttpClient(myHttpClient);
var freshdeskClient = FreshdeskClient.Create(freshdeskHttpClient);

NOTE: Typically you don't want to dispose the freshdesk client in this case.

  1. Using Microsoft.Extensions.DependencyInjection
using FreshdeskApi.Client.Extensions;

serviceCollection.AddFreshdeskApiClient(options => {
  options.FreshdeskDomain = "https://<mydomain>.freshdesk.com";
  options.ApiKey = "APIKEY"; 
})

...

container.GetRequiredService<IFreshdeskClient>();
container.GetRequiredService<IFreshdeskTicketClient>();
container.GetRequiredService<IFreshdesk...Client>();

Examples

Get a single ticket, including the company information on the API response

using var freshdeskHttpClient = new FreshdeskHttpClient("https://mydomain.freshdesk.com", "APIKEY");
var freshdeskTicketClient = new FreshdeskTicketClient(freshdeskHttpClient);
var ticket = await freshdeskTicketClient.ViewTicketAsync(
  ticketId: 12345, 
  includes: new TicketIncludes { Company = true }
);

API Coverage

Not all of the Freshdesk API is covered, this table illustrates the current status of coverage by this library. Pull requests to add additional features are welcome.

API Area Coverage
Tickets ✔️
Ticket Fields ✔️
Conversations ✔️
Contacts ✔️
Agents ✔️
Skills
Roles ✔️
Groups ✔️
Companies ✔️
Canned Responses ✔️ (read only)
Discussions
Solutions ✔️
Surveys
Satisfaction Ratings
Field Service Management
Time Entries
Email Configs
Email Mailboxes
Products ✔️
Business Hours
Scenario Automations
SLA Policies
Settings

Development

The library utilises C#11 features and therefore VS2022 or a suitable text editor are required for making changes.

Please feel free to send pull requests or raise Github issues.

About

A lightweight wrapper around the Freshdesk REST API as described here: https://developers.freshdesk.com/api

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%