Added support for Zendesk
This commit is contained in:
Родитель
9056117c7b
Коммит
1a213d7b9c
|
@ -24,6 +24,7 @@
|
|||
<Word>trello</Word>
|
||||
<Word>ver</Word>
|
||||
<Word>zapier</Word>
|
||||
<Word>zendesk</Word>
|
||||
<Word>你好</Word>
|
||||
</Recognized>
|
||||
<Deprecated/>
|
||||
|
|
|
@ -14,8 +14,10 @@ Please see the initial [documentation](http://go.microsoft.com/fwlink/?LinkId=69
|
|||
- [Dropbox](/samples/DropboxReceiver)
|
||||
- [GitHub](/samples/GitHubReceiver)
|
||||
- [Instagram](/samples/InstagramReceiver)
|
||||
- [MyGet](/samples/MyGetReceiver)
|
||||
- [Slack](/samples/SlackReceiver)
|
||||
- [Stripe](/samples/StripeReceiver)
|
||||
- [Zendesk](/samples/ZendeskReceiver)
|
||||
|
||||
###Resources
|
||||
* Overview
|
||||
|
|
27
WebHooks.sln
27
WebHooks.sln
|
@ -146,6 +146,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyGetReceiver", "samples\My
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHubReceiver", "samples\GitHubReceiver\GitHubReceiver.csproj", "{F4FB75ED-543F-4FF0-BD41-F4B9AD120575}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZendeskReceiver", "samples\ZendeskReceiver\ZendeskReceiver.csproj", "{BD0AB018-7229-42BF-B607-5D46E9F1F2EA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.WebHooks.Receivers.Zendesk", "src\Microsoft.AspNet.WebHooks.Receivers.Zendesk\Microsoft.AspNet.WebHooks.Receivers.Zendesk.csproj", "{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.WebHooks.Receivers.Zendesk.Test", "test\Microsoft.AspNet.WebHooks.Receivers.Zendesk.Test\Microsoft.AspNet.WebHooks.Receivers.Zendesk.Test.csproj", "{D4AE6D4C-004F-4392-9EE1-772444719449}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeAnalysis|Any CPU = CodeAnalysis|Any CPU
|
||||
|
@ -531,6 +537,24 @@ Global
|
|||
{F4FB75ED-543F-4FF0-BD41-F4B9AD120575}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F4FB75ED-543F-4FF0-BD41-F4B9AD120575}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F4FB75ED-543F-4FF0-BD41-F4B9AD120575}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD0AB018-7229-42BF-B607-5D46E9F1F2EA}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD0AB018-7229-42BF-B607-5D46E9F1F2EA}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD0AB018-7229-42BF-B607-5D46E9F1F2EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BD0AB018-7229-42BF-B607-5D46E9F1F2EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD0AB018-7229-42BF-B607-5D46E9F1F2EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD0AB018-7229-42BF-B607-5D46E9F1F2EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU
|
||||
{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU
|
||||
{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D4AE6D4C-004F-4392-9EE1-772444719449}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU
|
||||
{D4AE6D4C-004F-4392-9EE1-772444719449}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU
|
||||
{D4AE6D4C-004F-4392-9EE1-772444719449}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D4AE6D4C-004F-4392-9EE1-772444719449}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D4AE6D4C-004F-4392-9EE1-772444719449}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D4AE6D4C-004F-4392-9EE1-772444719449}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -599,6 +623,9 @@ Global
|
|||
{AEF3F2C9-38E3-4C56-BE50-DE7CD4041A14} = {9575CB90-BC4B-43BB-8AEA-82C53FDA4187}
|
||||
{D9777B08-1097-4B80-BC9B-F5989F8D235C} = {E957C8D9-B4A0-488B-838F-BAB4DE080A76}
|
||||
{F4FB75ED-543F-4FF0-BD41-F4B9AD120575} = {E957C8D9-B4A0-488B-838F-BAB4DE080A76}
|
||||
{BD0AB018-7229-42BF-B607-5D46E9F1F2EA} = {E957C8D9-B4A0-488B-838F-BAB4DE080A76}
|
||||
{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA} = {929F44D0-A040-4DC3-A22F-4C5829C05D44}
|
||||
{D4AE6D4C-004F-4392-9EE1-772444719449} = {9575CB90-BC4B-43BB-8AEA-82C53FDA4187}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8;packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace BitbucketReceiver
|
||||
{
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
using System.Web.Http;
|
||||
|
||||
namespace ZendeskReceiver
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
// Web API configuration and services
|
||||
|
||||
// Web API routes
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
|
||||
// Initialize ZendeskReceiver WebHook receiver
|
||||
config.InitializeReceiveZendeskWebHooks();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<%@ Application Codebehind="Global.asax.cs" Inherits="BitbucketReceiver.WebApiApplication" Language="C#" %>
|
|
@ -0,0 +1,12 @@
|
|||
using System.Web.Http;
|
||||
|
||||
namespace ZendeskReceiver
|
||||
{
|
||||
public class WebApiApplication : System.Web.HttpApplication
|
||||
{
|
||||
protected void Application_Start()
|
||||
{
|
||||
GlobalConfiguration.Configure(WebApiConfig.Register);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
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("ZendeskReceiver")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ZendeskReceiver")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[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("b81f55bb-d4be-42da-9a9e-27cfcfe1007c")]
|
||||
|
||||
// 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 Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
In the example below, the "SetAttributes" transform will change the value of
|
||||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||
finds an attribute "name" that has a value of "MyDB".
|
||||
|
||||
<connectionStrings>
|
||||
<add name="MyDB"
|
||||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||
</connectionStrings>
|
||||
-->
|
||||
<system.web>
|
||||
<!--
|
||||
In the example below, the "Replace" transform will replace the entire
|
||||
<customErrors> section of your web.config file.
|
||||
Note that because there is only one customErrors section under the
|
||||
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
In the example below, the "SetAttributes" transform will change the value of
|
||||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||
finds an attribute "name" that has a value of "MyDB".
|
||||
|
||||
<connectionStrings>
|
||||
<add name="MyDB"
|
||||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||
</connectionStrings>
|
||||
-->
|
||||
<system.web>
|
||||
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
||||
<!--
|
||||
In the example below, the "Replace" transform will replace the entire
|
||||
<customErrors> section of your web.config file.
|
||||
Note that because there is only one customErrors section under the
|
||||
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
For more information on how to configure your ASP.NET application, please visit
|
||||
http://go.microsoft.com/fwlink/?LinkId=301879
|
||||
-->
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="MS_WebHookReceiverSecret_Zendesk" value="32-128 bytes of random data used as 'code' query parameter in the WebHook URI" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<compilation debug="true" targetFramework="4.5.2" />
|
||||
<httpRuntime targetFramework="4.5.2" />
|
||||
</system.web>
|
||||
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.codedom>
|
||||
<compilers>
|
||||
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
|
||||
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
|
||||
</compilers>
|
||||
</system.codedom>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
|
||||
<remove name="OPTIONSVerbHandler" />
|
||||
<remove name="TRACEVerbHandler" />
|
||||
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
|
||||
</handlers>
|
||||
</system.webServer></configuration>
|
|
@ -0,0 +1,26 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.WebHooks;
|
||||
|
||||
namespace ZendeskReceiver.WebHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// This <see cref="WebHookHandler"/> implementation handles Zendesk WebHooks.
|
||||
/// For more information about Zendesk push payloads, please see
|
||||
/// <c>https://developer.zendesk.com/embeddables/docs/android/push_notifications_webhook</c>.
|
||||
/// </summary>
|
||||
public class ZendeskWebHookHandler : WebHookHandler
|
||||
{
|
||||
public ZendeskWebHookHandler()
|
||||
{
|
||||
Receiver = ZendeskWebHookReceiver.ReceiverName;
|
||||
}
|
||||
|
||||
public override Task ExecuteAsync(string generator, WebHookHandlerContext context)
|
||||
{
|
||||
ZendeskPost post = context.GetDataOrDefault<ZendeskPost>();
|
||||
|
||||
// Implementation logic goes here
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
|
||||
<Import Project="..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
|
||||
<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>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{BD0AB018-7229-42BF-B607-5D46E9F1F2EA}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ZendeskReceiver</RootNamespace>
|
||||
<AssemblyName>ZendeskReceiver</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.EnterpriseServices" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Global.asax" />
|
||||
<Content Include="index.html" />
|
||||
<Content Include="Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Start\WebApiConfig.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WebHooks\ZendeskWebHookHandler.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="packages.config" />
|
||||
<None Include="Web.Debug.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
<None Include="Web.Release.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Src\Microsoft.AspNet.WebHooks.Common\Microsoft.AspNet.WebHooks.Common.csproj">
|
||||
<Project>{f7dd0935-6320-4efc-9464-d5a2d2b8c2f7}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNet.WebHooks.Receivers.Zendesk\Microsoft.AspNet.WebHooks.Receivers.Zendesk.csproj">
|
||||
<Project>{787a0ced-0c7e-40a0-b02b-ad675b618017}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Receivers.Zendesk</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Src\Microsoft.AspNet.WebHooks.Receivers\Microsoft.AspNet.WebHooks.Receivers.csproj">
|
||||
<Project>{8ced31fb-32f2-4ffb-9997-452fb9728577}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Receivers</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>4333</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:50010</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
|
||||
<Error Condition="!Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
|
||||
</Target>
|
||||
<!-- 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>
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Microsoft ASP.NET WewbHooks Zendesk Receiver</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Microsoft ASP.NET WewbHooks Zendesk Receiver</h1>
|
||||
|
||||
<p>This sample illustrates how to wire up a Zendesk WebHooks receiver. A sample WebHook URI is:</p>
|
||||
|
||||
<pre>https://<host>/api/webhooks/incoming/zendesk/{id}?code=83699ec7c1d794c0c780e49a5c72972590571fd8</pre>
|
||||
|
||||
<p>
|
||||
For security reasons the WebHook URI must be an <c>https</c> URI and contain a 'code' query parameter with the
|
||||
same value as configured in the <b>MS_WebHookReceiverSecret_Zendesk</b> application setting.
|
||||
The 'code' parameter must be between 32 and 128 characters long.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please see <a href="https://developer.zendesk.com/embeddables/docs/android/push_notifications_webhook#webhook-api">Zendesk WebHooks</a>
|
||||
for more information.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNet.WebApi" version="5.2.2" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.2" targetFramework="net452" />
|
||||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
|
||||
</packages>
|
|
@ -98,7 +98,9 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Microsoft.AspNet.WebHooks.Receivers.MyGet.nuspec" />
|
||||
<None Include="Microsoft.AspNet.WebHooks.Receivers.MyGet.nuspec">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.ComponentModel;
|
||||
using Microsoft.AspNet.WebHooks.Config;
|
||||
|
||||
namespace System.Web.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="HttpConfiguration"/>.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static class HttpConfigurationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes support for receiving Zendesk WebHooks.
|
||||
/// A sample WebHook URI is '<c>https://<host>/api/webhooks/incoming/zendesk/{id}?code=83699ec7c1d794c0c780e49a5c72972590571fd8</c>'.
|
||||
/// For security reasons the WebHook URI must be an <c>https</c> URI and contain a 'code' query parameter with the
|
||||
/// same value as configured in the '<c>MS_WebHookReceiverSecret_Zendesk</c>' application setting.
|
||||
/// The 'code' parameter must be between 32 and 128 characters long.
|
||||
/// For details about Zendesk WebHooks, see <c>https://developer.zendesk.com/embeddables/docs/ios/push_notifications_webhook</c>.
|
||||
/// For complete details about Zendesk APIs, see <c>https://developer.zendesk.com/rest_api/docs/core/introduction</c>.
|
||||
/// </summary>
|
||||
/// <param name="config">The current <see cref="HttpConfiguration"/>config.</param>
|
||||
public static void InitializeReceiveZendeskWebHooks(this HttpConfiguration config)
|
||||
{
|
||||
WebHooksConfig.Initialize(config);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebHooks.sln))\tools\WebHooks.settings.targets" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{DCD550FB-FE5E-4684-AA52-C09FE5F8FDDA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.AspNet.WebHooks</RootNamespace>
|
||||
<AssemblyName>Microsoft.AspNet.WebHooks.Receivers.Zendesk</AssemblyName>
|
||||
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
|
||||
<RunCodeAnalysis>$(CodeAnalysis)</RunCodeAnalysis>
|
||||
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
|
||||
<CodeAnalysisRuleSet>..\..\FxCop.ruleset</CodeAnalysisRuleSet>
|
||||
<DefineConstants>$(DefineConstants);ASPNETWEBHOOKS</DefineConstants>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<NuGetPackageImportStamp>84adb0a6</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\..\CustomDictionary.xml">
|
||||
<Link>CustomDictionary.xml</Link>
|
||||
<SubType>Designer</SubType>
|
||||
</CodeAnalysisDictionary>
|
||||
<Content Include="App.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Common\CommonAssemblyInfo.cs">
|
||||
<Link>Properties\CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Extensions\HttpConfigurationExtensions.cs" />
|
||||
<Compile Include="WebHooks\ZendeskDevice.cs" />
|
||||
<Compile Include="WebHooks\ZendeskPost.cs" />
|
||||
<Compile Include="WebHooks\ZendeskNotification.cs" />
|
||||
<Compile Include="WebHooks\ZendeskWebHookReceiver.cs" />
|
||||
<Compile Include="Properties\ZendeskReceiverResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ZendeskReceiverResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.AspNet.WebHooks.Common\Microsoft.AspNet.WebHooks.Common.csproj">
|
||||
<Project>{f7dd0935-6320-4efc-9464-d5a2d2b8c2f7}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.AspNet.WebHooks.Receivers\Microsoft.AspNet.WebHooks.Receivers.csproj">
|
||||
<Project>{8ced31fb-32f2-4ffb-9997-452fb9728577}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Receivers</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Microsoft.AspNet.WebHooks.Receivers.Zendesk.nuspec" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\ZendeskReceiverResources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>ZendeskReceiverResources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets" Condition="Exists('..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.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>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<package >
|
||||
<metadata>
|
||||
<id>$id$</id>
|
||||
<version>$symversion$</version>
|
||||
<title>Microsoft ASP.NET WebHooks Receiver for Zendesk</title>
|
||||
<authors>Microsoft</authors>
|
||||
<owners>Microsoft, aspnet</owners>
|
||||
<licenseUrl>http://www.microsoft.com/web/webpi/eula/net_library_eula_ENU.htm</licenseUrl>
|
||||
<projectUrl>http://go.microsoft.com/fwlink/?LinkId=690277</projectUrl>
|
||||
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>
|
||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<description>This package provides support for receiving WebHooks from Zendesk. For information about Zendesk WebHooks, see "https://developer.zendesk.com/embeddables/docs/ios/push_notifications_webhook".</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
|
||||
<tags>Microsoft AspNet WebApi AspNetWebApi WebHooks Zendesk</tags>
|
||||
</metadata>
|
||||
</package>
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNet.WebHooks.Receivers.Zendesk.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
|
99
src/Microsoft.AspNet.WebHooks.Receivers.Zendesk/Properties/ZendeskReceiverResources.Designer.cs
сгенерированный
Normal file
99
src/Microsoft.AspNet.WebHooks.Receivers.Zendesk/Properties/ZendeskReceiverResources.Designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,99 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class ZendeskReceiverResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal ZendeskReceiverResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.WebHooks.Properties.ZendeskReceiverResources", typeof(ZendeskReceiverResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The HTTP request body did not contain a required '{0}' property..
|
||||
/// </summary>
|
||||
internal static string Receiver_BadBody {
|
||||
get {
|
||||
return ResourceManager.GetString("Receiver_BadBody", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The WebHook request must contain a '{0}' HTTP header indicating the ID of Client..
|
||||
/// </summary>
|
||||
internal static string Receiver_NoClientId {
|
||||
get {
|
||||
return ResourceManager.GetString("Receiver_NoClientId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The WebHook request must contain a '{0}' HTTP header indicating the ID of RegisteredAPP..
|
||||
/// </summary>
|
||||
internal static string Receiver_NoRegisteredAppId {
|
||||
get {
|
||||
return ResourceManager.GetString("Receiver_NoRegisteredAppId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The WebHook request must contain a '{0}' HTTP header indicating the URL of the Zendesk..
|
||||
/// </summary>
|
||||
internal static string Receiver_NoUrl {
|
||||
get {
|
||||
return ResourceManager.GetString("Receiver_NoUrl", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Receiver_BadBody" xml:space="preserve">
|
||||
<value>The HTTP request body did not contain a required '{0}' property.</value>
|
||||
</data>
|
||||
<data name="Receiver_NoClientId" xml:space="preserve">
|
||||
<value>The WebHook request must contain a '{0}' HTTP header indicating the ID of Client.</value>
|
||||
</data>
|
||||
<data name="Receiver_NoRegisteredAppId" xml:space="preserve">
|
||||
<value>The WebHook request must contain a '{0}' HTTP header indicating the ID of RegisteredAPP.</value>
|
||||
</data>
|
||||
<data name="Receiver_NoUrl" xml:space="preserve">
|
||||
<value>The WebHook request must contain a '{0}' HTTP header indicating the URL of the Zendesk.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the information about registered device for Zendesk (iOS, Android)
|
||||
/// </summary>
|
||||
public class ZendeskDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// The device identifier/token that was registered through the SDK
|
||||
/// </summary>
|
||||
[JsonProperty("identifier")]
|
||||
public string Identifier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The device type. Possible values: "iOS" or "Android"
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public string DeviceType { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the information about notifications
|
||||
/// </summary>
|
||||
public class ZendeskNotification
|
||||
{
|
||||
/// <summary>
|
||||
/// The short message of the notification
|
||||
/// </summary>
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The long message of the notification
|
||||
/// </summary>
|
||||
[JsonProperty("body")]
|
||||
public string Body { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The identifier of the ticket that was updated. Pass this along as <c>zendesk_sdk_request_id</c> if you
|
||||
/// want ticket deep-linking in the application.
|
||||
/// </summary>
|
||||
[JsonProperty("ticket_id")]
|
||||
public string TicketId { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a Zendesk WebHook payload. For more details about Zendesk WebHooks,
|
||||
/// please see <c>https://developer.zendesk.com/embeddables/docs/ios/push_notifications_webhook</c>.
|
||||
/// </summary>
|
||||
public class ZendeskPost
|
||||
{
|
||||
private readonly Collection<ZendeskDevice> _devices = new Collection<ZendeskDevice>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of devices for this notification.
|
||||
/// </summary>
|
||||
[JsonProperty("devices")]
|
||||
public Collection<ZendeskDevice> Devices
|
||||
{
|
||||
get { return _devices; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the actual notification of this Zendesk WebHook payload.
|
||||
/// </summary>
|
||||
[JsonProperty("notification")]
|
||||
public ZendeskNotification Notification { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http.Controllers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides an <see cref="IWebHookReceiver"/> implementation which supports WebHooks generated by Zendesk.
|
||||
/// A sample WebHook URI is '<c>https://<host>/api/webhooks/incoming/zendesk/{id}?code=83699ec7c1d794c0c780e49a5c72972590571fd8</c>'.
|
||||
/// For security reasons the WebHook URI must be an <c>https</c> URI and contain a 'code' query parameter with the
|
||||
/// same value as configured in the '<c>MS_WebHookReceiverSecret_Zendesk</c>' application setting.
|
||||
/// The 'code' parameter must be between 32 and 128 characters long.
|
||||
/// For details about Zendesk WebHooks, see <c>https://developer.zendesk.com/embeddables/docs/ios/push_notifications_webhook</c>.
|
||||
/// For complete details about Zendesk APIs, see <c>https://developer.zendesk.com/rest_api/docs/core/introduction</c>.
|
||||
/// </summary>
|
||||
public class ZendeskWebHookReceiver : WebHookReceiver
|
||||
{
|
||||
internal const string RecName = "zendesk";
|
||||
internal const string DefaultAction = "change";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the receiver name for this receiver.
|
||||
/// </summary>
|
||||
public static string ReceiverName
|
||||
{
|
||||
get { return RecName; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name
|
||||
{
|
||||
get { return RecName; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task<HttpResponseMessage> ReceiveAsync(string id, HttpRequestContext context, HttpRequestMessage request)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
throw new ArgumentNullException("id");
|
||||
}
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException("context");
|
||||
}
|
||||
if (request == null)
|
||||
{
|
||||
throw new ArgumentNullException("request");
|
||||
}
|
||||
|
||||
if (request.Method == HttpMethod.Post)
|
||||
{
|
||||
// Ensure that we use https and have a valid code parameter
|
||||
await EnsureValidCode(request, id);
|
||||
|
||||
// Read the request entity body.
|
||||
JObject data = await ReadAsJsonAsync(request);
|
||||
|
||||
// Call registered handlers
|
||||
return await ExecuteWebHookAsync(id, context, request, new string[] { DefaultAction }, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return CreateBadMethodResponse(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
|
||||
<package id="StyleCop.MSBuild" version="4.7.49.1" targetFramework="net45" developmentDependency="true" />
|
||||
</packages>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="xunit.parallelizeAssembly" value="true" />
|
||||
</appSettings>
|
||||
<startup>
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"devices": [
|
||||
{
|
||||
"identifier": "oiuytrdsdfghjk",
|
||||
"type": "ios"
|
||||
},
|
||||
{
|
||||
"identifier": "iuytfrdcvbnmkl",
|
||||
"type": "android"
|
||||
}
|
||||
],
|
||||
"notification": {
|
||||
"body": "Agent replied something something",
|
||||
"title": "Agent replied",
|
||||
"ticket_id": "5"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\packages\xunit.runner.visualstudio.2.0.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.0.1\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),WebHooks.sln))\tools\WebHooks.settings.targets" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{D4AE6D4C-004F-4392-9EE1-772444719449}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Microsoft.AspNet.WebHooks</RootNamespace>
|
||||
<AssemblyName>Microsoft.AspNet.WebHooks.Receivers.Zendesk.Test</AssemblyName>
|
||||
<OutputPath>..\..\bin\$(Configuration)\Test\</OutputPath>
|
||||
<RunCodeAnalysis>$(CodeAnalysis)</RunCodeAnalysis>
|
||||
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
|
||||
<CodeAnalysisRuleSet>..\..\FxCopTest.ruleset</CodeAnalysisRuleSet>
|
||||
<DefineConstants>$(DefineConstants);ASPNETWEBHOOKS</DefineConstants>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Moq, Version=4.2.1502.911, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.core, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Common\EmbeddedResource.cs">
|
||||
<Link>EmbeddedResource.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WebHooks\ZendeskNotificationTests.cs" />
|
||||
<Compile Include="WebHooks\ZendeskDeviceTests.cs" />
|
||||
<Compile Include="WebHooks\ZendeskWebHookReceiverTests.cs" />
|
||||
<Compile Include="WebHooks\ZendeskPostTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="App.config" />
|
||||
<EmbeddedResource Include="Messages\ZendeskPostMessage.json" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Src\Microsoft.AspNet.WebHooks.Common\Microsoft.AspNet.WebHooks.Common.csproj">
|
||||
<Project>{f7dd0935-6320-4efc-9464-d5a2d2b8c2f7}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNet.WebHooks.Receivers.Zendesk\Microsoft.AspNet.WebHooks.Receivers.Zendesk.csproj">
|
||||
<Project>{dcd550fb-fe5e-4684-aa52-c09fe5f8fdda}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Receivers.Zendesk</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Src\Microsoft.AspNet.WebHooks.Receivers\Microsoft.AspNet.WebHooks.Receivers.csproj">
|
||||
<Project>{8ced31fb-32f2-4ffb-9997-452fb9728577}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Receivers</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.AspNet.WebHooks.Receivers.Test\Microsoft.AspNet.WebHooks.Receivers.Test.csproj">
|
||||
<Project>{cb965ed1-1e07-4374-a829-c636db09f567}</Project>
|
||||
<Name>Microsoft.AspNet.WebHooks.Receivers.Test</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.TestUtilities\Microsoft.TestUtilities.csproj">
|
||||
<Project>{608b1d09-e4de-4dba-8dbf-7758003988f0}</Project>
|
||||
<Name>Microsoft.TestUtilities</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\..\CustomDictionary.xml">
|
||||
<Link>CustomDictionary.xml</Link>
|
||||
</CodeAnalysisDictionary>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
|
||||
<Error Condition="!Exists('..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\xunit.runner.visualstudio.2.0.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.visualstudio.2.0.1\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
</Target>
|
||||
<Import Project="..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets" Condition="Exists('..\..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.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>
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: CLSCompliant(false)]
|
||||
[assembly: ComVisible(false)]
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks.Payloads
|
||||
{
|
||||
public class ZendeskDeviceTests
|
||||
{
|
||||
[Fact]
|
||||
public void ZendeskDevice_Roundtrips()
|
||||
{
|
||||
// Arrange
|
||||
JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.ZendeskPostMessage.json");
|
||||
ZendeskDevice expected = new ZendeskDevice
|
||||
{
|
||||
Identifier = "oiuytrdsdfghjk",
|
||||
DeviceType = "ios"
|
||||
};
|
||||
|
||||
// Act
|
||||
ZendeskDevice actual = data["devices"][0].ToObject<ZendeskDevice>();
|
||||
|
||||
// Assert
|
||||
string expectedJson = JsonConvert.SerializeObject(expected);
|
||||
string actualJson = JsonConvert.SerializeObject(actual);
|
||||
Assert.Equal(expectedJson, actualJson);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks.Payloads
|
||||
{
|
||||
public class ZendeskNotificationTests
|
||||
{
|
||||
[Fact]
|
||||
public void ZendeskNotification_Roundtrips()
|
||||
{
|
||||
// Arrange
|
||||
JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.ZendeskPostMessage.json");
|
||||
ZendeskNotification expected = new ZendeskNotification
|
||||
{
|
||||
Body = "Agent replied something something",
|
||||
Title = "Agent replied",
|
||||
TicketId = "5"
|
||||
};
|
||||
|
||||
// Act
|
||||
ZendeskNotification actual = data["notification"].ToObject<ZendeskNotification>();
|
||||
|
||||
// Assert
|
||||
string expectedJson = JsonConvert.SerializeObject(expected);
|
||||
string actualJson = JsonConvert.SerializeObject(actual);
|
||||
Assert.Equal(expectedJson, actualJson);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks.Payloads
|
||||
{
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "PostTests", Justification = "Correct term.")]
|
||||
public class ZendeskPostTests
|
||||
{
|
||||
[Fact]
|
||||
public void ZendeskPost_Roundtrips()
|
||||
{
|
||||
// Arrange
|
||||
JObject data = EmbeddedResource.ReadAsJObject("Microsoft.AspNet.WebHooks.Messages.ZendeskPostMessage.json");
|
||||
ZendeskPost expected = new ZendeskPost
|
||||
{
|
||||
Notification = new ZendeskNotification
|
||||
{
|
||||
Body = "Agent replied something something",
|
||||
Title = "Agent replied",
|
||||
TicketId = "5"
|
||||
}
|
||||
};
|
||||
expected.Devices.Add(new ZendeskDevice
|
||||
{
|
||||
Identifier = "oiuytrdsdfghjk",
|
||||
DeviceType = "ios"
|
||||
});
|
||||
expected.Devices.Add(new ZendeskDevice
|
||||
{
|
||||
Identifier = "iuytfrdcvbnmkl",
|
||||
DeviceType = "android"
|
||||
});
|
||||
|
||||
// Act
|
||||
ZendeskPost actual = data.ToObject<ZendeskPost>();
|
||||
|
||||
// Assert
|
||||
string expectedJson = JsonConvert.SerializeObject(expected);
|
||||
string actualJson = JsonConvert.SerializeObject(actual);
|
||||
Assert.Equal(expectedJson, actualJson);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using Moq;
|
||||
using Moq.Protected;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.WebHooks
|
||||
{
|
||||
public class ZendeskWebHookReceiverTests : WebHookReceiverTestsBase<ZendeskWebHookReceiver>
|
||||
{
|
||||
private const string TestContent = "{}";
|
||||
private const string TestId = "";
|
||||
private const string TestSecret = "12345678901234567890123456789012";
|
||||
private const string TestAddress = "https://some.ssl.host?code=" + TestSecret;
|
||||
|
||||
private HttpRequestMessage _postRequest;
|
||||
|
||||
public static TheoryData<string> InvalidCodeQueries
|
||||
{
|
||||
get
|
||||
{
|
||||
return new TheoryData<string>
|
||||
{
|
||||
string.Empty,
|
||||
"=",
|
||||
"==",
|
||||
"invalid",
|
||||
"code",
|
||||
"code=",
|
||||
"k1=v1;k2=v2",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReceiverName_IsConsistent()
|
||||
{
|
||||
// Arrange
|
||||
IWebHookReceiver rec = new ZendeskWebHookReceiver();
|
||||
string expected = "zendesk";
|
||||
|
||||
// Act
|
||||
string actual1 = rec.Name;
|
||||
string actual2 = ZendeskWebHookReceiver.ReceiverName;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expected, actual1);
|
||||
Assert.Equal(actual1, actual2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReceiveAsync_Throws_IfPostIsNotUsingHttps()
|
||||
{
|
||||
// Arrange
|
||||
Initialize(TestSecret);
|
||||
_postRequest.RequestUri = new Uri("http://some.no.ssl.host");
|
||||
|
||||
// Act
|
||||
HttpResponseException ex = await Assert.ThrowsAsync<HttpResponseException>(() => ReceiverMock.Object.ReceiveAsync(TestId, RequestContext, _postRequest));
|
||||
|
||||
// Assert
|
||||
HttpError error = await ex.Response.Content.ReadAsAsync<HttpError>();
|
||||
Assert.Equal("The WebHook receiver 'ZendeskWebHookReceiverProxy' requires HTTPS in order to be secure. Please register a WebHook URI of type 'https'.", error.Message);
|
||||
ReceiverMock.Protected()
|
||||
.Verify<Task<HttpResponseMessage>>("ExecuteWebHookAsync", Times.Never(), TestId, RequestContext, _postRequest, ItExpr.IsAny<IEnumerable<string>>(), ItExpr.IsAny<object>());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData("InvalidCodeQueries")]
|
||||
public async Task ReceiveAsync_Throws_IfPostHasNoCodeParameter(string query)
|
||||
{
|
||||
// Arrange
|
||||
Initialize(TestSecret);
|
||||
_postRequest.RequestUri = new Uri("https://some.no.ssl.host?" + query);
|
||||
|
||||
// Act
|
||||
HttpResponseException ex = await Assert.ThrowsAsync<HttpResponseException>(() => ReceiverMock.Object.ReceiveAsync(TestId, RequestContext, _postRequest));
|
||||
|
||||
// Assert
|
||||
HttpError error = await ex.Response.Content.ReadAsAsync<HttpError>();
|
||||
Assert.Equal("The WebHook verification request must contain a 'code' query parameter.", error.Message);
|
||||
ReceiverMock.Protected()
|
||||
.Verify<Task<HttpResponseMessage>>("ExecuteWebHookAsync", Times.Never(), TestId, RequestContext, _postRequest, ItExpr.IsAny<IEnumerable<string>>(), ItExpr.IsAny<object>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReceiveAsync_Throws_IfPostHasWrongCodeParameter()
|
||||
{
|
||||
// Arrange
|
||||
Initialize(TestSecret);
|
||||
_postRequest.RequestUri = new Uri("https://some.no.ssl.host?code=invalid");
|
||||
|
||||
// Act
|
||||
HttpResponseException ex = await Assert.ThrowsAsync<HttpResponseException>(() => ReceiverMock.Object.ReceiveAsync(TestId, RequestContext, _postRequest));
|
||||
|
||||
// Assert
|
||||
HttpError error = await ex.Response.Content.ReadAsAsync<HttpError>();
|
||||
Assert.Equal("The 'code' query parameter provided in the HTTP request did not match the expected value.", error.Message);
|
||||
ReceiverMock.Protected()
|
||||
.Verify<Task<HttpResponseMessage>>("ExecuteWebHookAsync", Times.Never(), TestId, RequestContext, _postRequest, ItExpr.IsAny<IEnumerable<string>>(), ItExpr.IsAny<object>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReceiveAsync_Throws_IfPostIsNotJson()
|
||||
{
|
||||
// Arrange
|
||||
Initialize(TestSecret);
|
||||
_postRequest.Content = new StringContent(TestContent, Encoding.UTF8, "text/plain");
|
||||
|
||||
// Act
|
||||
HttpResponseException ex = await Assert.ThrowsAsync<HttpResponseException>(() => ReceiverMock.Object.ReceiveAsync(TestId, RequestContext, _postRequest));
|
||||
|
||||
// Assert
|
||||
HttpError error = await ex.Response.Content.ReadAsAsync<HttpError>();
|
||||
Assert.Equal("The WebHook request must contain an entity body formatted as JSON.", error.Message);
|
||||
ReceiverMock.Protected()
|
||||
.Verify<Task<HttpResponseMessage>>("ExecuteWebHookAsync", Times.Never(), TestId, RequestContext, _postRequest, ItExpr.IsAny<IEnumerable<string>>(), ItExpr.IsAny<object>());
|
||||
}
|
||||
|
||||
[MemberData("ValidIdData")]
|
||||
public async Task ReceiveAsync_Succeeds_IfValidPostRequest(string id)
|
||||
{
|
||||
// Arrange
|
||||
Initialize(GetConfigValue(id, TestSecret));
|
||||
List<string> actions = new List<string> { ZendeskWebHookReceiver.DefaultAction };
|
||||
ReceiverMock.Protected()
|
||||
.Setup<Task<HttpResponseMessage>>("ExecuteWebHookAsync", id, RequestContext, _postRequest, actions, ItExpr.IsAny<object>())
|
||||
.ReturnsAsync(new HttpResponseMessage())
|
||||
.Verifiable();
|
||||
|
||||
// Act
|
||||
await ReceiverMock.Object.ReceiveAsync(id, RequestContext, _postRequest);
|
||||
|
||||
// Assert
|
||||
ReceiverMock.Verify();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("GET")]
|
||||
[InlineData("HEAD")]
|
||||
[InlineData("PATCH")]
|
||||
[InlineData("PUT")]
|
||||
[InlineData("OPTIONS")]
|
||||
public async Task ReceiveAsync_ReturnsError_IfInvalidMethod(string method)
|
||||
{
|
||||
// Arrange
|
||||
Initialize(TestSecret);
|
||||
HttpRequestMessage req = new HttpRequestMessage { Method = new HttpMethod(method) };
|
||||
req.SetRequestContext(RequestContext);
|
||||
|
||||
// Act
|
||||
HttpResponseMessage actual = await ReceiverMock.Object.ReceiveAsync(TestId, RequestContext, req);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.MethodNotAllowed, actual.StatusCode);
|
||||
ReceiverMock.Protected()
|
||||
.Verify<Task<HttpResponseMessage>>("ExecuteWebHookAsync", Times.Never(), TestId, RequestContext, req, ItExpr.IsAny<IEnumerable<string>>(), ItExpr.IsAny<object>());
|
||||
}
|
||||
|
||||
public override void Initialize(string config)
|
||||
{
|
||||
base.Initialize(config);
|
||||
|
||||
_postRequest = new HttpRequestMessage(HttpMethod.Post, TestAddress);
|
||||
_postRequest.SetRequestContext(RequestContext);
|
||||
_postRequest.Content = new StringContent(TestContent, Encoding.UTF8, "application/json");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
|
||||
<package id="Moq" version="4.2.1502.0911" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
|
||||
<package id="StyleCop.MSBuild" version="4.7.49.1" targetFramework="net45" developmentDependency="true" />
|
||||
<package id="xunit" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.assert" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.core" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.runner.visualstudio" version="2.0.1" targetFramework="net45" />
|
||||
</packages>
|
|
@ -25,6 +25,7 @@
|
|||
<assembly name="Microsoft.AspNet.WebHooks.Receivers.Stripe"/>
|
||||
<assembly name="Microsoft.AspNet.WebHooks.Receivers.Trello"/>
|
||||
<assembly name="Microsoft.AspNet.WebHooks.Receivers.WordPress"/>
|
||||
<assembly name="Microsoft.AspNet.WebHooks.Receivers.Zendesk"/>
|
||||
|
||||
<!-- Unit test assemblies and helpers -->
|
||||
<assembly name="Microsoft.AspNet.WebHooks.Common.Test"/>
|
||||
|
@ -51,5 +52,6 @@
|
|||
<assembly name="Microsoft.AspNet.WebHooks.Receivers.Test"/>
|
||||
<assembly name="Microsoft.AspNet.WebHooks.Receivers.Trello.Test"/>
|
||||
<assembly name="Microsoft.AspNet.WebHooks.Receivers.WordPress.Test"/>
|
||||
<assembly name="Microsoft.AspNet.WebHooks.Receivers.Zendesk.Test"/>
|
||||
<assembly name="Microsoft.TestUtilities"/>
|
||||
</assemblies>
|
||||
|
|
Загрузка…
Ссылка в новой задаче