Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Created January 29, 2018 15:10
Show Gist options
  • Save sjehutch/62293ac3a9d588923e0055ce080be525 to your computer and use it in GitHub Desktop.
Save sjehutch/62293ac3a9d588923e0055ce080be525 to your computer and use it in GitHub Desktop.
SREQ-details
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using sitehands;
//
// var data = Sreq.FromJson(jsonString);
namespace sitehands
{
using System;
using System.Net;
using System.Collections.Generic;
using Newtonsoft.Json;
public partial class Sreq
{
[JsonProperty("workOrders")]
public List<SreqWorkOrder> WorkOrders { get; set; }
[JsonProperty("sreq")]
public PurpleSreq PurpleSreq { get; set; }
[JsonProperty("skills")]
public object Skills { get; set; }
[JsonProperty("proposals")]
public List<Proposal> Proposals { get; set; }
[JsonProperty("notes")]
public List<SreqNote> Notes { get; set; }
[JsonProperty("lookupData")]
public object LookupData { get; set; }
[JsonProperty("formAsJson")]
public string FormAsJson { get; set; }
[JsonProperty("error")]
public object Error { get; set; }
[JsonProperty("children")]
public object Children { get; set; }
[JsonProperty("actions")]
public object Actions { get; set; }
[JsonProperty("actionHistories")]
public List<ActionHistory> ActionHistories { get; set; }
}
public partial class ActionHistory
{
[JsonProperty("relatedRecordType")]
public object RelatedRecordType { get; set; }
[JsonProperty("relatedRecordName")]
public object RelatedRecordName { get; set; }
[JsonProperty("relatedRecordId")]
public object RelatedRecordId { get; set; }
[JsonProperty("history")]
public History History { get; set; }
}
public partial class History
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Action_Date__c")]
public string ActionDateC { get; set; }
[JsonProperty("Action_Type__c")]
public string ActionTypeC { get; set; }
[JsonProperty("Service_Request__c")]
public string ServiceRequestC { get; set; }
[JsonProperty("Performed_By__c")]
public string PerformedByC { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Performed_By__r")]
public PerformedByR PerformedByR { get; set; }
}
public partial class Attributes
{
[JsonProperty("type")]
public string PurpleType { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
}
public partial class PerformedByR
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("LastModifiedDate")]
public string LastModifiedDate { get; set; }
}
public partial class SreqNote
{
[JsonProperty("note")]
public NoteNote Note { get; set; }
[JsonProperty("attachments")]
public object Attachments { get; set; }
}
public partial class NoteNote
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Subject__c")]
public string SubjectC { get; set; }
[JsonProperty("Message__c")]
public string MessageC { get; set; }
[JsonProperty("CreatedById")]
public CreatedById CreatedById { get; set; }
[JsonProperty("CreatedDate")]
public string CreatedDate { get; set; }
[JsonProperty("CreatedBy")]
public PerformedByR CreatedBy { get; set; }
}
public partial class Proposal
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Proposal_Type__c")]
public string ProposalTypeC { get; set; }
[JsonProperty("Service_Request__c")]
public string ServiceRequestC { get; set; }
[JsonProperty("Site__c")]
public string SiteC { get; set; }
[JsonProperty("Status__c")]
public string StatusC { get; set; }
[JsonProperty("Account__c")]
public string AccountC { get; set; }
[JsonProperty("Short_Description__c")]
public string ShortDescriptionC { get; set; }
[JsonProperty("Service_Request__r")]
public ServiceRequestR ServiceRequestR { get; set; }
[JsonProperty("Account__r")]
public PerformedByR AccountR { get; set; }
[JsonProperty("Site__r")]
public SiteR SiteR { get; set; }
}
public partial class ServiceRequestR
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Request_Owner__c")]
public string RequestOwnerC { get; set; }
[JsonProperty("Client__c")]
public string ClientC { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("LastModifiedDate")]
public string LastModifiedDate { get; set; }
[JsonProperty("OwnerId")]
public string OwnerId { get; set; }
[JsonProperty("RecordTypeId")]
public string RecordTypeId { get; set; }
[JsonProperty("Account__c")]
public string AccountC { get; set; }
[JsonProperty("CF_Form__c")]
public string CfFormC { get; set; }
[JsonProperty("Opened_By__c")]
public string OpenedByC { get; set; }
[JsonProperty("Requested_By__c")]
public string RequestedByC { get; set; }
[JsonProperty("Site__c")]
public string SiteC { get; set; }
[JsonProperty("Task_Type_Record__c")]
public string TaskTypeRecordC { get; set; }
[JsonProperty("Owner")]
public PerformedByR Owner { get; set; }
[JsonProperty("RecordType")]
public PerformedByR RecordType { get; set; }
[JsonProperty("Account__r")]
public PerformedByR AccountR { get; set; }
[JsonProperty("CF_Form__r")]
public PerformedByR CfFormR { get; set; }
[JsonProperty("Opened_By__r")]
public PerformedByR OpenedByR { get; set; }
[JsonProperty("Request_Owner__r")]
public PerformedByR RequestOwnerR { get; set; }
[JsonProperty("Requested_By__r")]
public PerformedByR RequestedByR { get; set; }
[JsonProperty("Site__r")]
public PerformedByR SiteR { get; set; }
[JsonProperty("Task_Type_Record__r")]
public PerformedByR TaskTypeRecordR { get; set; }
}
public partial class SiteR
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public SiteRId Id { get; set; }
[JsonProperty("Name")]
public SiteRName Name { get; set; }
[JsonProperty("LastModifiedDate")]
public SiteRLastModifiedDate LastModifiedDate { get; set; }
[JsonProperty("Location__c")]
public LocationC LocationC { get; set; }
[JsonProperty("City__c")]
public CityC CityC { get; set; }
[JsonProperty("State_Province__c")]
public StateProvinceC StateProvinceC { get; set; }
[JsonProperty("Country__c")]
public CountryC CountryC { get; set; }
[JsonProperty("Location__r")]
public PerformedByR LocationR { get; set; }
}
public partial class PurpleSreq
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("RecordTypeId")]
public string RecordTypeId { get; set; }
[JsonProperty("CreatedDate")]
public string CreatedDate { get; set; }
[JsonProperty("CreatedById")]
public string CreatedById { get; set; }
[JsonProperty("LastModifiedDate")]
public string LastModifiedDate { get; set; }
[JsonProperty("LastModifiedById")]
public string LastModifiedById { get; set; }
[JsonProperty("SystemModstamp")]
public string SystemModstamp { get; set; }
[JsonProperty("Account__c")]
public string AccountC { get; set; }
[JsonProperty("Apply_Summary__c")]
public bool ApplySummaryC { get; set; }
[JsonProperty("Channel__c")]
public string ChannelC { get; set; }
[JsonProperty("Client__c")]
public string ClientC { get; set; }
[JsonProperty("Contact_Type__c")]
public string ContactTypeC { get; set; }
[JsonProperty("Is_Template__c")]
public bool IsTemplateC { get; set; }
[JsonProperty("Opened_By__c")]
public string OpenedByC { get; set; }
[JsonProperty("Opened__c")]
public string OpenedC { get; set; }
[JsonProperty("Request_Owner__c")]
public string RequestOwnerC { get; set; }
[JsonProperty("Requested_By__c")]
public string RequestedByC { get; set; }
[JsonProperty("Requested_Start__c")]
public string RequestedStartC { get; set; }
[JsonProperty("Rollup_Status__c")]
public string RollupStatusC { get; set; }
[JsonProperty("SREQs_Active_Count__c")]
public long SreQsActiveCountC { get; set; }
[JsonProperty("SREQs_Canceled_Count__c")]
public long SreQsCanceledCountC { get; set; }
[JsonProperty("SREQs_Completed_Count__c")]
public long SreQsCompletedCountC { get; set; }
[JsonProperty("SREQs_New_Count__c")]
public long SreQsNewCountC { get; set; }
[JsonProperty("SREQs_Processing_Count__c")]
public long SreQsProcessingCountC { get; set; }
[JsonProperty("Site__c")]
public string SiteC { get; set; }
[JsonProperty("State__c")]
public string StateC { get; set; }
[JsonProperty("Status__c")]
public string StatusC { get; set; }
[JsonProperty("Summary__c")]
public string SummaryC { get; set; }
[JsonProperty("Task_Type_Record__c")]
public string TaskTypeRecordC { get; set; }
[JsonProperty("WOs_Canceled_Count__c")]
public long WOsCanceledCountC { get; set; }
[JsonProperty("WOs_Completed_Count__c")]
public long WOsCompletedCountC { get; set; }
[JsonProperty("WOs_Completed_With_Issues_Count__c")]
public long WOsCompletedWithIssuesCountC { get; set; }
[JsonProperty("WOs_In_Flight_Count__c")]
public long WOsInFlightCountC { get; set; }
[JsonProperty("OwnerId")]
public string OwnerId { get; set; }
[JsonProperty("Base_Object__c")]
public string BaseObjectC { get; set; }
[JsonProperty("CF_Form__c")]
public string CfFormC { get; set; }
[JsonProperty("Owner")]
public PerformedByR Owner { get; set; }
[JsonProperty("RecordType")]
public PerformedByR RecordType { get; set; }
[JsonProperty("CreatedBy")]
public PerformedByR CreatedBy { get; set; }
[JsonProperty("LastModifiedBy")]
public PerformedByR LastModifiedBy { get; set; }
[JsonProperty("Account__r")]
public AccountR AccountR { get; set; }
[JsonProperty("Base_Object__r")]
public BaseObjectR BaseObjectR { get; set; }
[JsonProperty("CF_Form__r")]
public CfFormR CfFormR { get; set; }
[JsonProperty("Channel__r")]
public PerformedByR ChannelR { get; set; }
[JsonProperty("Opened_By__r")]
public R OpenedByR { get; set; }
[JsonProperty("Request_Owner__r")]
public R RequestOwnerR { get; set; }
[JsonProperty("Requested_By__r")]
public R RequestedByR { get; set; }
[JsonProperty("Site__r")]
public SiteR SiteR { get; set; }
[JsonProperty("Task_Type_Record__r")]
public TaskTypeRecordR TaskTypeRecordR { get; set; }
}
public partial class AccountR
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("LastModifiedDate")]
public string LastModifiedDate { get; set; }
[JsonProperty("Primary_Group__c")]
public string PrimaryGroupC { get; set; }
[JsonProperty("Primary_Group__r")]
public PerformedByR PrimaryGroupR { get; set; }
}
public partial class BaseObjectR
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("LastModifiedDate")]
public string LastModifiedDate { get; set; }
[JsonProperty("OwnerId")]
public string OwnerId { get; set; }
[JsonProperty("Account__c")]
public string AccountC { get; set; }
[JsonProperty("Is_Template__c")]
public bool IsTemplateC { get; set; }
[JsonProperty("FCObject_Class__c")]
public string FcObjectClassC { get; set; }
[JsonProperty("FCObject_Type__c")]
public string FcObjectTypeC { get; set; }
[JsonProperty("State__c")]
public string StateC { get; set; }
[JsonProperty("Owner")]
public PerformedByR Owner { get; set; }
[JsonProperty("Account__r")]
public PerformedByR AccountR { get; set; }
}
public partial class CfFormR
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("LastModifiedDate")]
public string LastModifiedDate { get; set; }
[JsonProperty("OwnerId")]
public string OwnerId { get; set; }
[JsonProperty("Account__c")]
public string AccountC { get; set; }
[JsonProperty("Parent__c")]
public string ParentC { get; set; }
[JsonProperty("Owner")]
public PerformedByR Owner { get; set; }
[JsonProperty("Account__r")]
public PerformedByR AccountR { get; set; }
[JsonProperty("Parent__r")]
public PerformedByR ParentR { get; set; }
}
public partial class R
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("LastModifiedDate")]
public string LastModifiedDate { get; set; }
[JsonProperty("User__c")]
public string UserC { get; set; }
[JsonProperty("User__r")]
public PerformedByR UserR { get; set; }
[JsonProperty("Email__c")]
public string EmailC { get; set; }
}
public partial class TaskTypeRecordR
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public TaskTypeRecordRId Id { get; set; }
[JsonProperty("Name")]
public TaskTypeRecordRName Name { get; set; }
[JsonProperty("LastModifiedDate")]
public TaskTypeRecordRLastModifiedDate LastModifiedDate { get; set; }
[JsonProperty("OwnerId")]
public OwnerId OwnerId { get; set; }
[JsonProperty("Account__c")]
public AccountC AccountC { get; set; }
[JsonProperty("Category__c")]
public CategoryC CategoryC { get; set; }
[JsonProperty("Service_Domain__c")]
public ServiceDomainC ServiceDomainC { get; set; }
[JsonProperty("Valid_for_Work_Order__c")]
public bool ValidForWorkOrderC { get; set; }
[JsonProperty("Owner")]
public PerformedByR Owner { get; set; }
[JsonProperty("Account__r")]
public PerformedByR AccountR { get; set; }
}
public partial class SreqWorkOrder
{
[JsonProperty("workOrder")]
public WorkOrderWorkOrder WorkOrder { get; set; }
[JsonProperty("timeCards")]
public List<TimeCard> TimeCards { get; set; }
[JsonProperty("surveys")]
public object Surveys { get; set; }
[JsonProperty("skills")]
public object Skills { get; set; }
[JsonProperty("jcfAsJson")]
public string JcfAsJson { get; set; }
[JsonProperty("invoice")]
public object Invoice { get; set; }
}
public partial class TimeCard
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Work_Order__c")]
public string WorkOrderC { get; set; }
[JsonProperty("Leave_Reason__c")]
public string LeaveReasonC { get; set; }
[JsonProperty("Start_Time__c")]
public string StartTimeC { get; set; }
[JsonProperty("End_Time__c")]
public string EndTimeC { get; set; }
[JsonProperty("Performed_By__c")]
public string PerformedByC { get; set; }
[JsonProperty("Performed_By__r")]
public PerformedByR PerformedByR { get; set; }
}
public partial class WorkOrderWorkOrder
{
[JsonProperty("attributes")]
public Attributes Attributes { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Task_Type_Record__c")]
public string TaskTypeRecordC { get; set; }
[JsonProperty("Site__c")]
public string SiteC { get; set; }
[JsonProperty("State__c")]
public string StateC { get; set; }
[JsonProperty("Status__c")]
public string StatusC { get; set; }
[JsonProperty("Work_Status__c")]
public string WorkStatusC { get; set; }
[JsonProperty("Account__c")]
public string AccountC { get; set; }
[JsonProperty("Technician__c")]
public string TechnicianC { get; set; }
[JsonProperty("Work_in_Progress_Time__c")]
public string WorkInProgressTimeC { get; set; }
[JsonProperty("Submitted_For_Review_Time__c")]
public string SubmittedForReviewTimeC { get; set; }
[JsonProperty("Job_Successful__c")]
public string JobSuccessfulC { get; set; }
[JsonProperty("Summary__c")]
public string SummaryC { get; set; }
[JsonProperty("Is_Primary__c")]
public bool IsPrimaryC { get; set; }
[JsonProperty("Technician__r")]
public R TechnicianR { get; set; }
[JsonProperty("Account__r")]
public PerformedByR AccountR { get; set; }
[JsonProperty("Site__r")]
public SiteR SiteR { get; set; }
[JsonProperty("Task_Type_Record__r")]
public TaskTypeRecordR TaskTypeRecordR { get; set; }
[JsonProperty("Requested_Start__c")]
public string RequestedStartC { get; set; }
}
public enum CreatedById { The0054D000000GkLpqay, The0054D000000NkMwqay };
public enum CityC { TestCity };
public enum CountryC { Usa };
public enum SiteRId { A3V4D000000HmKsUao };
public enum SiteRLastModifiedDate { The20180124T2326380000000 };
public enum LocationC { A2H4D0000006OiOuaq };
public enum SiteRName { MgSiteChildUsd };
public enum StateProvinceC { Al };
public enum AccountC { A1V4D000000J3Zauay };
public enum CategoryC { AdHocProject };
public enum TaskTypeRecordRId { A3Q4D0000009BHfUam };
public enum TaskTypeRecordRLastModifiedDate { The20171005T2158190000000 };
public enum TaskTypeRecordRName { MgTtMvChildUsd };
public enum OwnerId { The0054D000000GkLpqay };
public enum ServiceDomainC { FieldServices };
public partial class Sreq
{
public static Sreq FromJson(string json) => JsonConvert.DeserializeObject<Sreq>(json, Converter.Settings);
}
static class CreatedByIdExtensions
{
public static CreatedById? ValueForString(string str)
{
switch (str)
{
case "0054D000000gkLPQAY": return CreatedById.The0054D000000GkLpqay;
case "0054D000000nkMWQAY": return CreatedById.The0054D000000NkMwqay;
default: return null;
}
}
public static CreatedById ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this CreatedById value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case CreatedById.The0054D000000GkLpqay: serializer.Serialize(writer, "0054D000000gkLPQAY"); break;
case CreatedById.The0054D000000NkMwqay: serializer.Serialize(writer, "0054D000000nkMWQAY"); break;
}
}
}
static class CityCExtensions
{
public static CityC? ValueForString(string str)
{
switch (str)
{
case "TestCity": return CityC.TestCity;
default: return null;
}
}
public static CityC ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this CityC value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case CityC.TestCity: serializer.Serialize(writer, "TestCity"); break;
}
}
}
static class CountryCExtensions
{
public static CountryC? ValueForString(string str)
{
switch (str)
{
case "USA": return CountryC.Usa;
default: return null;
}
}
public static CountryC ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this CountryC value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case CountryC.Usa: serializer.Serialize(writer, "USA"); break;
}
}
}
static class SiteRIdExtensions
{
public static SiteRId? ValueForString(string str)
{
switch (str)
{
case "a3V4D000000HMKsUAO": return SiteRId.A3V4D000000HmKsUao;
default: return null;
}
}
public static SiteRId ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this SiteRId value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case SiteRId.A3V4D000000HmKsUao: serializer.Serialize(writer, "a3V4D000000HMKsUAO"); break;
}
}
}
static class SiteRLastModifiedDateExtensions
{
public static SiteRLastModifiedDate? ValueForString(string str)
{
switch (str)
{
case "2018-01-24T23:26:38.000+0000": return SiteRLastModifiedDate.The20180124T2326380000000;
default: return null;
}
}
public static SiteRLastModifiedDate ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this SiteRLastModifiedDate value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case SiteRLastModifiedDate.The20180124T2326380000000: serializer.Serialize(writer, "2018-01-24T23:26:38.000+0000"); break;
}
}
}
static class LocationCExtensions
{
public static LocationC? ValueForString(string str)
{
switch (str)
{
case "a2H4D0000006oiOUAQ": return LocationC.A2H4D0000006OiOuaq;
default: return null;
}
}
public static LocationC ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this LocationC value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case LocationC.A2H4D0000006OiOuaq: serializer.Serialize(writer, "a2H4D0000006oiOUAQ"); break;
}
}
}
static class SiteRNameExtensions
{
public static SiteRName? ValueForString(string str)
{
switch (str)
{
case "[MG]Site-Child-USD": return SiteRName.MgSiteChildUsd;
default: return null;
}
}
public static SiteRName ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this SiteRName value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case SiteRName.MgSiteChildUsd: serializer.Serialize(writer, "[MG]Site-Child-USD"); break;
}
}
}
static class StateProvinceCExtensions
{
public static StateProvinceC? ValueForString(string str)
{
switch (str)
{
case "AL": return StateProvinceC.Al;
default: return null;
}
}
public static StateProvinceC ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this StateProvinceC value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case StateProvinceC.Al: serializer.Serialize(writer, "AL"); break;
}
}
}
static class AccountCExtensions
{
public static AccountC? ValueForString(string str)
{
switch (str)
{
case "a1V4D000000j3ZAUAY": return AccountC.A1V4D000000J3Zauay;
default: return null;
}
}
public static AccountC ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this AccountC value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case AccountC.A1V4D000000J3Zauay: serializer.Serialize(writer, "a1V4D000000j3ZAUAY"); break;
}
}
}
static class CategoryCExtensions
{
public static CategoryC? ValueForString(string str)
{
switch (str)
{
case "Ad Hoc Project": return CategoryC.AdHocProject;
default: return null;
}
}
public static CategoryC ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this CategoryC value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case CategoryC.AdHocProject: serializer.Serialize(writer, "Ad Hoc Project"); break;
}
}
}
static class TaskTypeRecordRIdExtensions
{
public static TaskTypeRecordRId? ValueForString(string str)
{
switch (str)
{
case "a3Q4D0000009BHfUAM": return TaskTypeRecordRId.A3Q4D0000009BHfUam;
default: return null;
}
}
public static TaskTypeRecordRId ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this TaskTypeRecordRId value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case TaskTypeRecordRId.A3Q4D0000009BHfUam: serializer.Serialize(writer, "a3Q4D0000009BHfUAM"); break;
}
}
}
static class TaskTypeRecordRLastModifiedDateExtensions
{
public static TaskTypeRecordRLastModifiedDate? ValueForString(string str)
{
switch (str)
{
case "2017-10-05T21:58:19.000+0000": return TaskTypeRecordRLastModifiedDate.The20171005T2158190000000;
default: return null;
}
}
public static TaskTypeRecordRLastModifiedDate ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this TaskTypeRecordRLastModifiedDate value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case TaskTypeRecordRLastModifiedDate.The20171005T2158190000000: serializer.Serialize(writer, "2017-10-05T21:58:19.000+0000"); break;
}
}
}
static class TaskTypeRecordRNameExtensions
{
public static TaskTypeRecordRName? ValueForString(string str)
{
switch (str)
{
case "[MG]TT-MV-Child-USD": return TaskTypeRecordRName.MgTtMvChildUsd;
default: return null;
}
}
public static TaskTypeRecordRName ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this TaskTypeRecordRName value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case TaskTypeRecordRName.MgTtMvChildUsd: serializer.Serialize(writer, "[MG]TT-MV-Child-USD"); break;
}
}
}
static class OwnerIdExtensions
{
public static OwnerId? ValueForString(string str)
{
switch (str)
{
case "0054D000000gkLPQAY": return OwnerId.The0054D000000GkLpqay;
default: return null;
}
}
public static OwnerId ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this OwnerId value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case OwnerId.The0054D000000GkLpqay: serializer.Serialize(writer, "0054D000000gkLPQAY"); break;
}
}
}
static class ServiceDomainCExtensions
{
public static ServiceDomainC? ValueForString(string str)
{
switch (str)
{
case "Field Services": return ServiceDomainC.FieldServices;
default: return null;
}
}
public static ServiceDomainC ReadJson(JsonReader reader, JsonSerializer serializer)
{
var str = serializer.Deserialize<string>(reader);
var maybeValue = ValueForString(str);
if (maybeValue.HasValue) return maybeValue.Value;
throw new Exception("Unknown enum case " + str);
}
public static void WriteJson(this ServiceDomainC value, JsonWriter writer, JsonSerializer serializer)
{
switch (value)
{
case ServiceDomainC.FieldServices: serializer.Serialize(writer, "Field Services"); break;
}
}
}
public static class Serialize
{
public static string ToJson(this Sreq self) => JsonConvert.SerializeObject(self, Converter.Settings);
}
public class Converter: JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(CreatedById) || t == typeof(CityC) || t == typeof(CountryC) || t == typeof(SiteRId) || t == typeof(SiteRLastModifiedDate) || t == typeof(LocationC) || t == typeof(SiteRName) || t == typeof(StateProvinceC) || t == typeof(AccountC) || t == typeof(CategoryC) || t == typeof(TaskTypeRecordRId) || t == typeof(TaskTypeRecordRLastModifiedDate) || t == typeof(TaskTypeRecordRName) || t == typeof(OwnerId) || t == typeof(ServiceDomainC) || t == typeof(CreatedById?) || t == typeof(CityC?) || t == typeof(CountryC?) || t == typeof(SiteRId?) || t == typeof(SiteRLastModifiedDate?) || t == typeof(LocationC?) || t == typeof(SiteRName?) || t == typeof(StateProvinceC?) || t == typeof(AccountC?) || t == typeof(CategoryC?) || t == typeof(TaskTypeRecordRId?) || t == typeof(TaskTypeRecordRLastModifiedDate?) || t == typeof(TaskTypeRecordRName?) || t == typeof(OwnerId?) || t == typeof(ServiceDomainC?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (t == typeof(CreatedById))
return CreatedByIdExtensions.ReadJson(reader, serializer);
if (t == typeof(CityC))
return CityCExtensions.ReadJson(reader, serializer);
if (t == typeof(CountryC))
return CountryCExtensions.ReadJson(reader, serializer);
if (t == typeof(SiteRId))
return SiteRIdExtensions.ReadJson(reader, serializer);
if (t == typeof(SiteRLastModifiedDate))
return SiteRLastModifiedDateExtensions.ReadJson(reader, serializer);
if (t == typeof(LocationC))
return LocationCExtensions.ReadJson(reader, serializer);
if (t == typeof(SiteRName))
return SiteRNameExtensions.ReadJson(reader, serializer);
if (t == typeof(StateProvinceC))
return StateProvinceCExtensions.ReadJson(reader, serializer);
if (t == typeof(AccountC))
return AccountCExtensions.ReadJson(reader, serializer);
if (t == typeof(CategoryC))
return CategoryCExtensions.ReadJson(reader, serializer);
if (t == typeof(TaskTypeRecordRId))
return TaskTypeRecordRIdExtensions.ReadJson(reader, serializer);
if (t == typeof(TaskTypeRecordRLastModifiedDate))
return TaskTypeRecordRLastModifiedDateExtensions.ReadJson(reader, serializer);
if (t == typeof(TaskTypeRecordRName))
return TaskTypeRecordRNameExtensions.ReadJson(reader, serializer);
if (t == typeof(OwnerId))
return OwnerIdExtensions.ReadJson(reader, serializer);
if (t == typeof(ServiceDomainC))
return ServiceDomainCExtensions.ReadJson(reader, serializer);
if (t == typeof(CreatedById?))
{
if (reader.TokenType == JsonToken.Null) return null;
return CreatedByIdExtensions.ReadJson(reader, serializer);
}
if (t == typeof(CityC?))
{
if (reader.TokenType == JsonToken.Null) return null;
return CityCExtensions.ReadJson(reader, serializer);
}
if (t == typeof(CountryC?))
{
if (reader.TokenType == JsonToken.Null) return null;
return CountryCExtensions.ReadJson(reader, serializer);
}
if (t == typeof(SiteRId?))
{
if (reader.TokenType == JsonToken.Null) return null;
return SiteRIdExtensions.ReadJson(reader, serializer);
}
if (t == typeof(SiteRLastModifiedDate?))
{
if (reader.TokenType == JsonToken.Null) return null;
return SiteRLastModifiedDateExtensions.ReadJson(reader, serializer);
}
if (t == typeof(LocationC?))
{
if (reader.TokenType == JsonToken.Null) return null;
return LocationCExtensions.ReadJson(reader, serializer);
}
if (t == typeof(SiteRName?))
{
if (reader.TokenType == JsonToken.Null) return null;
return SiteRNameExtensions.ReadJson(reader, serializer);
}
if (t == typeof(StateProvinceC?))
{
if (reader.TokenType == JsonToken.Null) return null;
return StateProvinceCExtensions.ReadJson(reader, serializer);
}
if (t == typeof(AccountC?))
{
if (reader.TokenType == JsonToken.Null) return null;
return AccountCExtensions.ReadJson(reader, serializer);
}
if (t == typeof(CategoryC?))
{
if (reader.TokenType == JsonToken.Null) return null;
return CategoryCExtensions.ReadJson(reader, serializer);
}
if (t == typeof(TaskTypeRecordRId?))
{
if (reader.TokenType == JsonToken.Null) return null;
return TaskTypeRecordRIdExtensions.ReadJson(reader, serializer);
}
if (t == typeof(TaskTypeRecordRLastModifiedDate?))
{
if (reader.TokenType == JsonToken.Null) return null;
return TaskTypeRecordRLastModifiedDateExtensions.ReadJson(reader, serializer);
}
if (t == typeof(TaskTypeRecordRName?))
{
if (reader.TokenType == JsonToken.Null) return null;
return TaskTypeRecordRNameExtensions.ReadJson(reader, serializer);
}
if (t == typeof(OwnerId?))
{
if (reader.TokenType == JsonToken.Null) return null;
return OwnerIdExtensions.ReadJson(reader, serializer);
}
if (t == typeof(ServiceDomainC?))
{
if (reader.TokenType == JsonToken.Null) return null;
return ServiceDomainCExtensions.ReadJson(reader, serializer);
}
throw new Exception("Unknown type");
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var t = value.GetType();
if (t == typeof(CreatedById))
{
((CreatedById)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(CityC))
{
((CityC)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(CountryC))
{
((CountryC)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(SiteRId))
{
((SiteRId)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(SiteRLastModifiedDate))
{
((SiteRLastModifiedDate)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(LocationC))
{
((LocationC)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(SiteRName))
{
((SiteRName)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(StateProvinceC))
{
((StateProvinceC)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(AccountC))
{
((AccountC)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(CategoryC))
{
((CategoryC)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(TaskTypeRecordRId))
{
((TaskTypeRecordRId)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(TaskTypeRecordRLastModifiedDate))
{
((TaskTypeRecordRLastModifiedDate)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(TaskTypeRecordRName))
{
((TaskTypeRecordRName)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(OwnerId))
{
((OwnerId)value).WriteJson(writer, serializer);
return;
}
if (t == typeof(ServiceDomainC))
{
((ServiceDomainC)value).WriteJson(writer, serializer);
return;
}
throw new Exception("Unknown type");
}
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters = { new Converter() },
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment