Giter Club home page Giter Club logo

zendeskapi_v2's Introduction

Zendesk Api V2

Want to take over ownership of this project?

I want to throw this out there to see if there is anyone in the community that would be willing to take over ownership of this project. If you are interested please write me [email protected].

Hope to hear from you, Eric

About

This is a full c# wrapper for Zendesk's api v2. http://developer.zendesk.com/documentation/rest_api/introduction.html

I am sorry to say but I will no longer be able to support ths api but here are some examples of things you might want to do, for even more examples check out the "Tests" folder above. Everything is tested so there are plenty of examples! Also there is a live demo here: http://zendeskcdemo.apphb.com/

This code is released under the Apache Version 2 License.

Nov 2014 Possible Breaking Changes: Dates now use DateTimeOffset instead of string

Please look at this pull request for more information.

Nov 2014 Help Center Api

Thanks to PeteAllen there is now HelpCenter Support for the Api! You can find out more here

FEB 2014 - Ticket Description Changes

As of Feb 2014 the Ticket.Description field goes from being mandatory to read only. So when you want to create a ticket you must now set the description by using the Comment.Body field instead. For example, from now on create tickets this way:

var ticket = api.Tickets.CreateTicket(new Ticket()
                             {
                                 Subject = "my printer is on fire",
                                 Comment = new Comment(){Body = "HELP"},
                                 Priority = TicketPriorities.Urgent
                             });

NOT this way:

var ticket = api.Tickets.CreateTicket(new Ticket()
                             {
                                 Subject = "my printer is on fire",
                                 Description = "HELP", //THIS WILL NOT WORK
                                 Priority = TicketPriorities.Urgent
                             });

See here for more information.

Setting Up:

You can instantiate the wrapper using the email and password or token. To set up using the password do it like this.

	ZendeskApi api = new ZendeskApi(https://{yoursite}.zendesk.com/api/v2, "[email protected]", "password"); 

To set up using the token, add the token as the fourth param. Note the third paramter (password) can be blank or not. Here is an example.

	ZendeskApi api = new ZendeskApi(https://{yoursite}.zendesk.com/api/v2, "[email protected]", "", "{your token here}"); 

Creating a ticket:

	ZendeskApi api = new ZendeskApi(https://{yoursite}.zendesk.com/api/v2, "[email protected]", "password"); 
	var ticket = api.Tickets.CreateTicket(new Ticket()
                             {
                                 Subject = "my printer is on fire",
                                 Comment = new Comment(){Body = "HELP"},
                                 Priority = TicketPriorities.Urgent
                             });

Getting all the tickets in a view

	var myViewId = 1; //ex Id for the All unsolved tickets view
	var tickets = api.Views.ExecuteView(myViewId);

Uploading an attachment to a ticket

1st we need to upload the attachment.

	var attachment = api.Attachments.UploadAttachment(new ZenFile()
            {
                ContentType = "text/plain",
                FileName = "testupload.txt",
                FileData = File.ReadAllBytes("testupload.txt")
            });

Now we add the attachment token to a ticket.

	var ticket = new Ticket()
            {
                Subject = "testing attachments",
                Priority = TicketPriorities.Normal,
                Comment = new Comment() { 
                    Body = "comments are required for attachments", 
                    Public = true, 
                    Uploads = new List<string>() { attachment.Token } \\Add the attachment token here
                },
            };

    var t1 = api.Tickets.CreateTicket(ticket);

Updating a ticket works the same way, just create a new comment and set the Uploads token. Note you can add more than one attachment to a comment.

Paging

By default Zendesk will only return you 100 items at a time. But when there are more than that you can use the "NextPage" and "PreviousPage" urls to get more. For example lets say we call GetAllTickets and want to get the second page as well, here's how you would do it.

	ZendeskApi api = new ZendeskApi(Settings.Site, Settings.Email, Settings.Password);
	var tickets = api.Tickets.GetAllTickets();
	if(!string.IsNullOrEmpty(tickets.NextPage))
    {
        var page2 = api.Tickets.GetByPageUrl<GroupTicketResponse>(tickets.NextPage);
    }

*Note that the type in GetByPageUrl must be the same type as returned by the original collection. So in this case api.Tickets.GetAllTickets() returns a GroupTicketResponse, so that is the type we want to use.

Remote Authentication

As an added bonus you can also generate a link to log a user in. Make sure you have "Token Access" enabled at Settings -> Channels -> Api. *Note if you are using Single Sign On the token would be in Admin -> Settings -> Security -> Single Sign-On.

	var loginUrl = api.GetLoginUrl("Name", "Email", "Your Auth Token", "optional forward to url");

A good example of how to use this would be, say you want a user to be able to see their tickets on your business's website. Using this you could link directly to the ticket from your site and with one click the user could be logged into Zendesk and seeing their ticket. Kind of nice :)

Summary

All of the api calls are under the following properties. And these properties pretty much correspond to the Zendesk docs except for things like "Ticket Audits" which are grouped with all of the other ticket methods.

  • Tickets
  • Attachments
  • Views
  • Users
  • Requests
  • Groups
  • CustomAgentRoles
  • Organizations
  • Search
  • Tags
  • Forums
  • Categories
  • Topics
  • AccountsAndActivity
  • JobStatuses
  • Locales
  • Macros
  • SatisfactionRatings
  • SharingAgreements
  • Triggers

ASYNC Support

As of 12/4/2012 the project now has complete async support for net4.0 + and for Portable Class Libraries. The PCL synchronous support was removed since windows phone is not meant to have synchronous tasks like this. Also note that you must have nuget 2.1+ to get the portable class library version!

Ticket Exporting

There is a Windows console application for keeping a local copy of your Zendesk tickets updated in an application-managed SQLite database, with optional export to csv availible here. Thanks to Ken Dale!

For any API related questions please email [email protected], thanks!

zendeskapi_v2's People

Contributors

eneifert avatar sitefinitysteve avatar kendaleiv avatar aarongundel avatar anturgyffrous avatar sumez avatar automagic avatar bishnupokharel avatar jonasmolgaard avatar ithielnor avatar kevinkuszyk avatar j0emay avatar davidfrankland avatar irq avatar khezamian avatar alanc10n avatar alexisvz avatar ggrossman avatar gillesber avatar jopierrelerm avatar tapamarcotte avatar

Watchers

Jake avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.