OLX.FreshDeskAPI 1.0.1-alpha

This is a prerelease version of OLX.FreshDeskAPI.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package OLX.FreshDeskAPI --version 1.0.1-alpha
NuGet\Install-Package OLX.FreshDeskAPI -Version 1.0.1-alpha
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OLX.FreshDeskAPI" Version="1.0.1-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OLX.FreshDeskAPI --version 1.0.1-alpha
#r "nuget: OLX.FreshDeskAPI, 1.0.1-alpha"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OLX.FreshDeskAPI as a Cake Addin
#addin nuget:?package=OLX.FreshDeskAPI&version=1.0.1-alpha&prerelease

// Install OLX.FreshDeskAPI as a Cake Tool
#tool nuget:?package=OLX.FreshDeskAPI&version=1.0.1-alpha&prerelease

Welcome to OLX.FreshDeskAPI

OLX.FreshDeskAPI is a simple implementation for freshdesk api v2.

Installation

OLX.FreshDeskAPI is available as a NuGet Package. NuGet package manager is preferred method of integrating OLX.FreshDeskAPI into your project. For installation, run the following command into Package Manager Console.

Install-Package OLX.FreshDeskAPI -Version 1.0.0-alpha

Usage

Firstly, you have to setup an account on Freshdesk.com. After creating an account, you will get a FreshDesk sub domain URL(typically: http://domainname.freshdesk.com) and FreshDesk API Key(in your Profile Settings) which is needed for further API calls.

This Package makes calls to the Freshdesk REST API.

FreshDeskService

To create a new instance of FreshDeskService use the below code. The constructor requires your FreshDesk URL, API Key and Company Name(Custom Field) against which the ticket(s) will be created or fetched. Note that the company's name must be registered on your FreshDesk account(https://domainname.freshdesk.com/a/admin/contact_fields).

IFreshDeskService _ifreshdeskservice = new FreshDeskService("https://domain.freshdesk.com/api/v2/", 
				    "FreshDeskAPIV2Key",
				    "CompanyName_CustomField");

GetTickets

This method requires SearchTicketViewModel as an input parameter. If SearchTicketViewModel.isSuperAdmin(uses Freshdesk API) is FALSE, then it will return all tickets of the mentioned email address(this can be used when displaying records to end user).

_ifreshdeskservice.GetTickets(_ifreshdeskservice.GetTickets(new SearchTicketViewModel()
            {
                EmailId= "example@example.com",
                FilterFields= null,
                isSuperAdmin= false,
                Page = 0
            }));

If SearchTicketViewModel.isSuperAdmin(uses Freshdesk API) is TRUE, then tickets will be retuned on the basis of SearchTicketViewModel.FilterFields(At present, this filter works on 'status' field only). When FilterFields are not mentioned, this will bring up all the records(30 records per page). This can be used to display records for admin user. This may take some time to reflect the changes as the query api on FreshDesk v2 doesnot return realtime records(takes some time to reflect the latest modifications).

_ifreshdeskservice.GetTickets(_ifreshdeskservice.GetTickets(new SearchTicketViewModel()
        {
            EmailId= null,
            FilterFields= new List<Filter>()
            {
                new Filter() { Key="status",Value="" }//will return all the records
            },
            isSuperAdmin= true,
            Page = 1//page size is 30
        }));

GetTicketDetails

This api(Freshdesk API) expects an int Ticket Id as input parameter and returns details of the mentioned ticket with conversation included(first 10 conversations only).

_ifreshdeskservice.GetTicketDetails(42);//ticket id

GetTicketConversationWithPageNumber

Freshdesk API takes int Ticket Id and int Page Number as input parameter and returns the conversations. Page size is 10.

    _ifreshdeskservice.GetTicketConversationWithPageNumber(
    							 42,//Ticket Id 
    							  2//Page Number
); 

CreateTicket

Freshdesk API accept an instance of TicketDescriptionModel type and returns success response if the ticket is created successfully.

var httpRequest = HttpContext.Current.Request;
var model = new TicketDescriptionModel()
{
    Requester = httpRequest.Form["Requester"],//Email id of the ticket requester
    TicketSubject = httpRequest.Form["TicketSubject"],//Subject on the ticket
    TicketDesc = httpRequest.Form["TicketDesc"],//Description on the ticket
    TicketPriority = httpRequest.Form["TicketPriority"],//Priority in the range of 1-4
    attachments = httpRequest.Files,//Attachments with the ticket
};
_ifreshdeskservice.CreateTicket(model);

ReplyOnTicket

Freshdesk API accept an instance of TicketReply type and returns success response if the reply is posted successfully.

var httpRequest = HttpContext.Current.Request;
var model = new TicketReply()
{
    TicketId = Convert.ToInt16(httpRequest.Form["ticketId"]),//ticket id against which the reply is posted
    IsClosingComment = Convert.ToBoolean(httpRequest.Form["isClosingComment"]),//if true, the ticket will be closed after this reply is posted
    IsSuperAdminComment = Convert.ToBoolean(httpRequest.Form["IsSuperAdminComment"]),//is this comment posted by admin or the user
    TicketComment = httpRequest.Form["ticketComment"],//comments on the ticket
    TicketFrom = httpRequest.Form["ticketFrom"],//Email id of replier (Only used if IsSuperAdminComment comes false)
    attachments = httpRequest.Files,//files associated with the request
};
_ifreshdeskservice.ReplyOnTicket(model);

DeleteTicket

Freshdesk API accept an int Ticket Id and returns success response if the mentioned ticket is deleted successfully.

_ifreshdeskservice.DeleteTicket(42);//id of ticket to be deleted

UpdateTicket

Freshdesk API accept int Ticket Id and int Status and returns success response if the ticket status is updated successfully. Note that this api only updates the status.

_ifreshdeskservice.UpdateTicket(
	    42,//ticket id to be updated
	    3//new status id
);
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2-alpha 594 9/14/2018
1.0.1-alpha 740 7/14/2018

Initial release