Skip to content

added help-center article attachments for Issue #280 #286

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

Merged
merged 5 commits into from
Jun 30, 2017
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
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ max_jobs: 1
install:
- ps: >-

choco install gitversion.portable -pre -y
choco install gitversion.portable --no-progress -y

$output = gitversion

Expand Down Expand Up @@ -40,7 +40,7 @@ install:
Write-Host "Is the build Prerelease: " $env:Is_Prerelease
pull_requests:
do_not_increment_build_number: true
image: Visual Studio 2015
image: Visual Studio 2017 Preview
configuration: Release
platform: Any CPU
assembly_info:
Expand Down
Binary file modified src/.nuget/NuGet.exe
Binary file not shown.
17 changes: 17 additions & 0 deletions src/Tests/GroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using ZendeskApi_v2.Models.Constants;
using ZendeskApi_v2.Models.Users;
using ZendeskApi_v2.Models.Groups;
using System.Threading.Tasks;
using ZendeskApi_v2.Models.Search;

namespace Tests
{
Expand All @@ -12,6 +14,21 @@ public class GroupTests
{
private ZendeskApi api = new ZendeskApi(Settings.Site, Settings.AdminEmail, Settings.AdminPassword);

[OneTimeSetUp]
public async Task CleanUp()
{

var resp = await api.Search.SearchForAsync<User>("test133@test.com");


foreach (var user in resp.Results)
{
await api.Users.DeleteUserAsync(user.Id.Value);
}
}



[Test]
public void CanGetGroups()
{
Expand Down
87 changes: 87 additions & 0 deletions src/Tests/HelpCenter/ArticleAttachmentsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZendeskApi_v2;
using ZendeskApi_v2.Models.Articles;
using ZendeskApi_v2.Models.Shared;

namespace Tests.HelpCenter
{
[TestFixture]
[Category("HelpCenter")]
public class ArticleAttachmentsTest
{
private ZendeskApi api = new ZendeskApi(Settings.Site, Settings.AdminEmail, Settings.AdminPassword);

[Test]
public void CanGetAttachmentsForArticle()
{
var res = api.HelpCenter.ArticleAttachments.GetAttachments(204838115);
Assert.That(res.Attachments, Is.Not.Null);
}

[Test]
public void CanUploadAttachmentsForArticle()
{
var file = new ZenFile()
{
ContentType = "text/plain",
FileName = "testupload.txt",
FileData = File.ReadAllBytes(TestContext.CurrentContext.TestDirectory + "\\testupload.txt")
};

var respSections = api.HelpCenter.Sections.GetSections();
var articleResponse = api.HelpCenter.Articles.CreateArticle(respSections.Sections[0].Id.Value, new Article
{
Title = "My Test article",
Body = "The body of my article",
Locale = "en-us"
});

var resp = api.HelpCenter.ArticleAttachments.UploadAttchment(articleResponse.Article.Id, file);

Assert.That(resp.Attachment, Is.Not.Null);
Assert.That(api.HelpCenter.ArticleAttachments.DeleteAttchment(resp.Attachment.Id), Is.True);
Assert.That(api.HelpCenter.Articles.DeleteArticle(articleResponse.Article.Id.Value), Is.True);
}


[Test]
public async Task CanGetAttachmentsForArticleAsync()
{
var res = await api.HelpCenter.ArticleAttachments.GetAttachmentsAsync(204838115);
Assert.That(res.Attachments, Is.Not.Null);
}

[Test]
public async Task CanUploadAttachmentsForArticleAsync()
{
var file = new ZenFile()
{
ContentType = "text/plain",
FileName = "testupload.txt",
FileData = File.ReadAllBytes(TestContext.CurrentContext.TestDirectory + "\\testupload.txt")
};

var respSections = await api.HelpCenter.Sections.GetSectionsAsync();
var articleResponse = await api.HelpCenter.Articles.CreateArticleAsync(respSections.Sections[0].Id.Value, new Article
{
Title = "My Test article",
Body = "The body of my article",
Locale = "en-us"
});

var resp = await api.HelpCenter.ArticleAttachments.UploadAttchmentAsync(articleResponse.Article.Id, file, true);

Assert.That(resp.Attachment, Is.Not.Null);
Assert.That(resp.Attachment.Inline, Is.True);

Assert.That(await api.HelpCenter.ArticleAttachments.DeleteAttchmentAsync(resp.Attachment.Id), Is.True);
Assert.That(await api.HelpCenter.Articles.DeleteArticleAsync(articleResponse.Article.Id.Value), Is.True);
}
}
}
10 changes: 5 additions & 5 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@
<WarningLevel>0</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 Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=3.7.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -72,6 +71,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="HelpCenter\ArticleAttachmentsTest.cs" />
<Compile Include="HelpCenter\PostTests.cs" />
<Compile Include="HelpCenter\TopicTests.cs" />
<Compile Include="HelpCenter\TranslationTests.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="NUnit" version="3.6.0" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="3.6.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
<package id="NUnit" version="3.7.1" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="3.7.0" targetFramework="net45" />
</packages>
2 changes: 1 addition & 1 deletion src/ZendeskApi_v2.Example/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<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" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
9 changes: 4 additions & 5 deletions src/ZendeskApi_v2.Example/ZendeskApi_v2.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
<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 Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -45,8 +44,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="ZendeskApi_v2, Version=3.5.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ZendeskApi_v2.3.5.3\lib\net45\ZendeskApi_v2.dll</HintPath>
<Reference Include="ZendeskApi_v2, Version=3.6.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ZendeskApi_v2.3.6.1\lib\net45\ZendeskApi_v2.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/ZendeskApi_v2.Example/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +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.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
<package id="ZendeskApi_v2" version="3.6.1" targetFramework="net452" />
</packages>
Loading