Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Example Console Application #245

Merged
merged 5 commits into from
Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
Zendesk Api V2
==============
## Zendesk Api V2

[![Join the chat at https://gitter.im/mozts2005/ZendeskApi_v2](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mozts2005/ZendeskApi_v2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LRHN43F4DFLU6&lc=US&item_name=Elizabeth%20Schneider&item_number=ZendeskAPI%20support&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)
[![Join the chat at https://gitter.im/mozts2005/ZendeskApi_v2](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mozts2005/ZendeskApi_v2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build status](https://ci.appveyor.com/api/projects/status/6ve1ey4x7ctd5029?svg=true)](https://ci.appveyor.com/project/mozts2005/zendeskapi-v2)
[![NuGet Version](https://img.shields.io/nuget/v/ZendeskApi_v2.svg)](https://www.nuget.org/packages/ZendeskApi_v2/)
[![NuGet Version](https://img.shields.io/nuget/v/ZendeskApi_v2.svg)](https://www.nuget.org/packages/ZendeskApi_v2/)
[![MyGet Prerelease](https://img.shields.io/myget/zendeskapi_v2_prerelease/vpre/ZendeskApi_v2.svg?label=MyGet_Prerelease)](https://www.myget.org/feed/zendeskapi_v2_prerelease/package/nuget/ZendeskApi_v2)

This is a client for [Zendesk's v2 REST api](http://developer.zendesk.com/documentation/rest_api/introduction.html).
This is a client for [Zendesk's v2 REST api](http://developer.zendesk.com/documentation/rest_api/introduction.html).

The client uses the Zendesk api however it is not supported by the zendesk for questions
about the client please join our gitter room.
The client uses the Zendesk api however it is not supported by the zendesk for questions
about the client please join our gitter room.

If you have questions about your account or the api its self please contact the zendesk team at <mailto:[email protected]>
If you have questions about your account or the api its self please contact the zendesk team at [[email protected]](mailto:[email protected])

#### Contributing

Any and all are welcome to contribute to this project.
Please read our [Contributing Guidelines](CONTRIBUTING.md)


#### Special Thanks
Thank you to the team at [Zendesk](https://www.zendesk.com/) for their support. They provide this project with a sponsored account. Allowing a greater level of testing and faster support of API changes.


##### License
This code is released under the [Apache Version 2 License](LICENSE.md).

This code is released under the [Apache Version 2 License](http://www.apache.org/licenses/LICENSE-2.0.html).
9 changes: 6 additions & 3 deletions src/Tests/HelpCenter/CategoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ public void CanCreateUpdateAndDeleteCategories()
{
var res = api.HelpCenter.Categories.CreateCategory(new Category()
{
Name = "My Test category"
Name = "My Test category",
Description = "stuff and things",
Position = 1
});

Assert.Greater(res.Category.Id, 0);

res.Category.Description = "updated description";
res.Category.Position = 2;
var update = api.HelpCenter.Categories.UpdateCategory(res.Category);
Assert.AreEqual(update.Category.Description, res.Category.Description);
Assert.AreEqual(update.Category.Position, res.Category.Position);

Assert.True(api.HelpCenter.Categories.DeleteCategory(res.Category.Id.Value));
}
Expand Down
7 changes: 7 additions & 0 deletions src/Tests/TagTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ public class TagTests
{
private ZendeskApi api = new ZendeskApi(Settings.Site, Settings.Email, Settings.Password);


[TestFixtureSetUp]
public void Setup()
{

}

[Test]
public void CanGetTags()
{
Expand Down
14 changes: 14 additions & 0 deletions src/ZendeskApi_v2.Example/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
55 changes: 55 additions & 0 deletions src/ZendeskApi_v2.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using ZendeskApi_v2.Models.Tickets;
using ZendeskApi_v2.Models.Users;

namespace ZendeskApi_v2.Example
{
class Program
{

static void Main(string[] args)
{
Task.Run(() => MainAsync(null)).Wait();

System.Console.ReadKey();
}

static async Task MainAsync(string email)
{

string userEmailToSreachFor = "[email protected]";

string userName = "[email protected]"; // the user that will be logging in the API aka the call center staff
string userPassword = "pa55word";
string companySubDomain = "csharpapi"; // sub-domain for the account with Zendesk
int pageSize = 5;
var api = new ZendeskApi(companySubDomain, userName, userPassword);

var userResponse = api.Search.SearchFor<User>(userEmailToSreachFor);

long userId = userResponse.Results[0].Id.Value;
List<Ticket> tickets = new List<Ticket>();

var ticketResponse = await api.Tickets.GetTicketsByUserIDAsync(userId, pageSize, sideLoadOptions: Requests.TicketSideLoadOptionsEnum.Users); // default per page is 100

do
{
tickets.AddRange(ticketResponse.Tickets);

if (!string.IsNullOrWhiteSpace(ticketResponse.NextPage))
{
ticketResponse = await api.Tickets.GetByPageUrlAsync<GroupTicketResponse>(ticketResponse.NextPage, pageSize);
}


} while (tickets.Count != ticketResponse.Count);

foreach (var ticket in tickets)
{
System.Console.WriteLine(string.Format("ticket id: {0 }, Assignee Id: {1}, Requester Id: {2}", ticket.Id, ticket.AssigneeId, ticket.RequesterId ));
}

}
}
}
36 changes: 36 additions & 0 deletions src/ZendeskApi_v2.Example/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ZendeskApi_v2.Example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ZendeskApi_v2.Example")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0a9fe800-92f6-4979-8f0c-6129ecf94952")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
69 changes: 69 additions & 0 deletions src/ZendeskApi_v2.Example/ZendeskApi_v2.Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0A9FE800-92F6-4979-8F0C-6129ECF94952}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ZendeskApi_v2.Example</RootNamespace>
<AssemblyName>ZendeskApi_v2.Example</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="ZendeskApi_v2, Version=3.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ZendeskApi_v2.3.5.1\lib\net45\ZendeskApi_v2.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
5 changes: 5 additions & 0 deletions src/ZendeskApi_v2.Example/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="ZendeskApi_v2" version="3.5.1" targetFramework="net452" />
</packages>
7 changes: 7 additions & 0 deletions src/ZendeskApi_v2_vs2013.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
..\.gitattributes = ..\.gitattributes
..\.gitignore = ..\.gitignore
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZendeskApi_v2", "ZenDeskApi_v2\ZendeskApi_v2.csproj", "{D17BCC22-9561-4FC4-9C52-975808641ECE}"
Expand Down Expand Up @@ -34,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZendeskApi_v2_Package", "Ze
{C1D27B49-4B9D-467D-98E7-3695F35EA400} = {C1D27B49-4B9D-467D-98E7-3695F35EA400}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZendeskApi_v2.Example", "ZendeskApi_v2.Example\ZendeskApi_v2.Example.csproj", "{0A9FE800-92F6-4979-8F0C-6129ECF94952}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -60,6 +63,10 @@ Global
{0451BAEF-DF2E-4B98-8644-94EE9415E389}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0451BAEF-DF2E-4B98-8644-94EE9415E389}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0451BAEF-DF2E-4B98-8644-94EE9415E389}.Release|Any CPU.Build.0 = Release|Any CPU
{0A9FE800-92F6-4979-8F0C-6129ECF94952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A9FE800-92F6-4979-8F0C-6129ECF94952}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A9FE800-92F6-4979-8F0C-6129ECF94952}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A9FE800-92F6-4979-8F0C-6129ECF94952}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down