Skip to content

Instantly share code, notes, and snippets.

@devinrader
Created July 18, 2015 01:25
Show Gist options
  • Save devinrader/3913e7c47b4360eb3031 to your computer and use it in GitHub Desktop.
Save devinrader/3913e7c47b4360eb3031 to your computer and use it in GitHub Desktop.
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication37
{
class Program
{
static void Main(string[] args)
{
var taskRouting = new TaskRouting()
{
Filters = new List<Filter>
{
new Filter() {
FriendlyName="Gold Tickets",
Expression="customer_value == 'Gold' AND type == 'ticket'",
Targets = new List<Target> {
new Target() {
Queue = "WQ0123456789abcdef0123456789abcdef",
Priority = "2"
}
}
},
new Filter() {
FriendlyName="Silver and Bronze Tickets",
Expression="customer_value IN ['Silver', 'Bronze'] AND type == 'ticket'",
Targets = new List<Target> {
new Target() {
Queue = "WQabcdef0123456789abcdef0123456789",
Priority = "1",
Timeout="300"
},
new Target() {
Queue="WQabcdef01234567890123456789abcdef"
}
}
},
new Filter() {
FriendlyName="Leads",
Expression="type == 'lead'",
Targets = new List<Target> {
new Target() {
Queue = "WQabcdef01234567890123456789abcdef",
Priority = "3"
}
}
}
},
DefaultFilter = new DefaultFilter() { Queue = "WQabcdef01234567890123456789abcdef" }
};
var result = Newtonsoft.Json.JsonConvert.SerializeObject(taskRouting, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, ContractResolver=new CamelCasePropertyNamesContractResolver() });
Console.WriteLine(result);
Console.Read();
}
}
public class TaskRouting
{
public TaskRouting()
{
this.Filters = new List<Filter>();
}
public IEnumerable<Filter> Filters { get; set; }
[JsonProperty(PropertyName="default_filter")]
public DefaultFilter DefaultFilter { get; set; }
}
public class Filter
{
public Filter()
{
this.Targets = new List<Target>();
}
[JsonProperty(PropertyName = "friendly_name")]
public string FriendlyName { get; set; }
public string Expression { get; set; }
public IEnumerable<Target> Targets { get; set; }
}
public class Target
{
public string Queue { get; set; }
public string Priority { get; set; }
public string Timeout { get; set; }
public string Expression { get; set; }
}
public class DefaultFilter
{
public string Queue { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment