Skip to content

Commit

Permalink
Change type of date/time fields from 'string' to 'DateTimeOffset'
Browse files Browse the repository at this point in the history
Add unit test for creating a ticket with DueAt setting
Add check for CreatedAt, UpdatedAt to ticket creation test
  • Loading branch information
Gary Grossman committed Sep 11, 2014
1 parent 4481d8b commit cde6aa9
Show file tree
Hide file tree
Showing 34 changed files with 226 additions and 84 deletions.
26 changes: 26 additions & 0 deletions Tests/TicketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ public void CanCreateUpdateAndDeleteTicket()
Assert.NotNull(res);
Assert.Greater(res.Id, 0);

Assert.AreEqual(res.CreatedAt, res.UpdatedAt);
Assert.LessOrEqual(res.CreatedAt - DateTimeOffset.UtcNow, TimeSpan.FromMinutes (1.0));

res.Status = TicketStatus.Solved;
res.AssigneeId = Settings.UserId;

Expand All @@ -234,6 +237,7 @@ public void CanCreateUpdateAndDeleteTicket()
Assert.NotNull(updateResponse);
Assert.AreEqual(updateResponse.Audit.Events.First().Body, body);
Assert.Greater(updateResponse.Ticket.CollaboratorIds.Count, 0);
Assert.GreaterOrEqual(updateResponse.Ticket.UpdatedAt, updateResponse.Ticket.CreatedAt);

Assert.True(api.Tickets.Delete(res.Id.Value));
}
Expand Down Expand Up @@ -264,6 +268,28 @@ public void CanCreateTicketWithRequester()
Assert.True(api.Tickets.Delete(res.Id.Value));
}

[Test]
public void CanCreateTicketWithDueDate()
{
var dueAt = DateTimeOffset.UtcNow;

var ticket = new Ticket()
{
Subject = "ticket with due date",
Comment = new Comment() { Body = "test comment" },
Type = "task",
Priority = TicketPriorities.Normal,
DueAt = DateTimeOffset.UtcNow
};

var res = api.Tickets.CreateTicket(ticket).Ticket;

Assert.NotNull(res);
Assert.AreEqual(dueAt.ToString(), res.DueAt.ToString());

Assert.True(api.Tickets.Delete(res.Id.Value));
}

[Test]
public void CanCreateTicketWithTicketFormId()
{
Expand Down
8 changes: 6 additions & 2 deletions ZendeskApi_v2/Models/AccountsAndActivities/Activity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// JSON C# Class Generator
// http://at-my-window.blogspot.com/?page=json-class-generator

using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;


namespace ZendeskApi_v2.Models.AccountsAndActivities
Expand Down Expand Up @@ -29,9 +31,11 @@ public class Activity
public ZendeskApi_v2.Models.Users.User Actor { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }
}
}
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/Categories/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.Categories
Expand All @@ -24,9 +25,11 @@ public class Category
public int Position { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }
}
}
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/CustomRoles/CustomRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.CustomRoles
Expand All @@ -21,10 +22,12 @@ public class CustomRole
public string Description { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }

[JsonProperty("configuration")]
public Configuration Configuration { get; set; }
Expand Down
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/Forums/Forum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.Forums
Expand Down Expand Up @@ -43,9 +44,11 @@ public class Forum
public string Access { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }
}
}
4 changes: 3 additions & 1 deletion ZendeskApi_v2/Models/Forums/ForumSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.Forums
Expand All @@ -22,6 +23,7 @@ public class ForumSubscription
public long? UserId { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }
}
}
10 changes: 7 additions & 3 deletions ZendeskApi_v2/Models/Groups/Group.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace ZendeskApi_v2.Models.Groups
{
Expand All @@ -18,9 +20,11 @@ public class Group
public bool Deleted { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }
}
}
}
10 changes: 7 additions & 3 deletions ZendeskApi_v2/Models/Groups/GroupMembership.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace ZendeskApi_v2.Models.Groups
{
Expand All @@ -21,9 +23,11 @@ public class GroupMembership
public bool Default { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }
}
}
}
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/Locales/Locale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.Locales
Expand All @@ -25,9 +26,11 @@ public class Locale
public string Name { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }
}
}
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/Macros/Macro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.Macros
Expand All @@ -24,10 +25,12 @@ public class Macro
public bool? Active { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("restriction")]
public Restriction Restriction { get; set; }
Expand Down
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/Organizations/Organization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.Organizations
Expand All @@ -25,10 +26,12 @@ public class Organization
public string Name { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }

[JsonProperty("domain_names")]
public IList<object> DomainNames { get; set; }
Expand Down
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/Requests/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using ZendeskApi_v2.Models.Shared;
using ZendeskApi_v2.Models.Tickets;
Expand Down Expand Up @@ -39,10 +40,12 @@ public class Request
public IList<CustomField> CustomFields { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }

/// <summary>
/// This is used for updates only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.Satisfaction
Expand Down Expand Up @@ -34,10 +35,12 @@ public class SatisfactionRating
public string Score { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("comment")]
public string Comment { get; set; }
Expand Down
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/Search/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using ZendeskApi_v2.Models.Shared;
using ZendeskApi_v2.Models.Tickets;
Expand Down Expand Up @@ -66,10 +67,12 @@ public class Result
public int? CommentsCount { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public string UpdatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? UpdatedAt { get; set; }

[JsonProperty("id")]
public int Id { get; set; }
Expand Down
7 changes: 5 additions & 2 deletions ZendeskApi_v2/Models/Shared/Audit.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace ZendeskApi_v2.Models.Shared
{
Expand All @@ -12,7 +14,8 @@ public class Audit
public string TicketId { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("author_id")]
public long AuthorId { get; set; }
Expand All @@ -26,4 +29,4 @@ public class Audit
[JsonProperty("events")]
public IList<Event> Events { get; set; }
}
}
}
4 changes: 3 additions & 1 deletion ZendeskApi_v2/Models/SharingAgreements/SharingAgreement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;

namespace ZendeskApi_v2.Models.SharingAgreements
Expand All @@ -27,6 +28,7 @@ public class SharingAgreement
public string Status { get; set; }

[JsonProperty("created_at")]
public string CreatedAt { get; set; }
[JsonConverter(typeof(IsoDateTimeConverter))]
public DateTimeOffset? CreatedAt { get; set; }
}
}
Loading

0 comments on commit cde6aa9

Please sign in to comment.