OfferCategoryEvent
OfferCategoryEvent schema
Properties
AggregateId(string, format: {FulfillmentSystemId}-{FulfillmentSystemCustomerId}-{ShippingOrderId})Unique ID for shipping order within Integration Broker.CorrelationId(string)Unique ID for SOB-external event trigger.AggregateType(string)Type of event schema.EventActionUser(['string', 'null'])Username of user who triggered event.EventDateTimeUtc(string)UTC based datetime of when event was triggered.EventName(string)Name of triggered event.-
EventNameValuePairs(['array', 'null'])- Items (object)
-
EventPublisherApp(string)Name of source application that published event. EventSchemaVersion(string)Version of event schema being used.EventSource(string)Name of system where event was triggered.-
OfferCategory(object)OfferCategory properties.CustomerId(string, required)SOB unique ID of customer.OfferCategoryId(string, required)SOB globally-unique ID of category.ParentId(['string', 'null'])SOB unique ID of the parent category, if there is one.Name(string, required)Name to identify category.
-
EventName(string)Name of triggered event. Must be one of:["Offer Category Created", "Offer Category Updated", "Offer Category Deleted"].
Examples
{
"AggregateId": "6-mzvanhki-4-C-5606-0046-03",
"CorrelationId": "282so37c-sac5-77s3-1ow7-74u10g0386cq",
"AggregateType": "OfferCategory",
"EventActionUser": null,
"EventDateTimeUtc": "2024-11-22T22:16:00.263",
"EventName": "Offer Category Created",
"EventNameValuePairs": null,
"EventPublisherApp": "OfferBroker Category Event Publisher",
"EventSchemaVersion": "1.0",
"EventSource": "OfferBroker",
"OfferCategory": {
"CustomerId": "customer-123",
"OfferCategoryId": "category-456",
"ParentId": null,
"Name": "Electronics"
}
}
Quicktype Command
quicktype \
--framework SystemTextJson \
--lang cs \
--number-type double \
--src-lang schema \
--no-check-required \
--density dense \
--features complete \
--namespace OtpSchema.Event.OfferCategory.OfferCategoryEvent \
--src .working/build/internal/json-schema-for-cs/OfferCategoryEvent.json -o .working/build/internal/csharp/OtpSchema/Event/OfferCategory/OfferCategoryEvent.cs
OfferCategoryEvent
// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
// using OtpSchema.Event.OfferCategory.OfferCategoryEvent;
//
// var offerCategoryEvent = OfferCategoryEvent.FromJson(jsonString);
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8603
namespace OtpSchema.Event.OfferCategory.OfferCategoryEvent
{
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Globalization;
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
using N = System.Text.Json.Serialization.JsonIgnoreCondition;
/// <summary>OfferCategoryEvent schema; ; Details for Shipping Order JSON schema</summary>
public partial class OfferCategoryEvent
{
[J("AggregateId")] public string AggregateId { get; set; } // Unique ID for shipping order within Integration Broker
[J("AggregateType")] public string AggregateType { get; set; } // Type of event schema
[J("CorrelationId")] public string CorrelationId { get; set; } // Unique ID for SOB-external event trigger
[J("EventActionUser")] public string EventActionUser { get; set; } // Username of user who triggered event
[J("EventDateTimeUtc")] public string EventDateTimeUtc { get; set; } // UTC based datetime of when event was triggered
[J("EventName")] public AggregateId EventName { get; set; } // Name of triggered event
[J("EventNameValuePairs")] public Dictionary<string, object>[] EventNameValuePairs { get; set; }
[J("EventPublisherApp")] public string EventPublisherApp { get; set; } // Name of source application that published event
[J("EventSchemaVersion")] public string EventSchemaVersion { get; set; } // Version of event schema being used
[J("EventSource")] public string EventSource { get; set; } // Name of system where event was triggered
[J("OfferCategory")] public OfferCategory OfferCategory { get; set; } // OfferCategory properties
}
/// <summary>OfferCategory properties</summary>
public partial class OfferCategory
{
[J("CustomerId")] public string CustomerId { get; set; } // SOB unique ID of customer
[J("Name")] public string Name { get; set; } // Name to identify category
[J("OfferCategoryId")] public string OfferCategoryId { get; set; } // SOB globally-unique ID of category
[J("ParentId")] public string ParentId { get; set; } // SOB unique ID of the parent category, if there is one
}
/// <summary>Name of triggered event</summary>
public enum AggregateId { OfferCategoryCreated, OfferCategoryDeleted, OfferCategoryUpdated };
public partial class OfferCategoryEvent
{
public static OfferCategoryEvent FromJson(string json) => JsonSerializer.Deserialize<OfferCategoryEvent>(json, OtpSchema.Event.OfferCategory.OfferCategoryEvent.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this OfferCategoryEvent self) => JsonSerializer.Serialize(self, OtpSchema.Event.OfferCategory.OfferCategoryEvent.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
{
Converters =
{
AggregateIdConverter.Singleton,
new DateOnlyConverter(),
new TimeOnlyConverter(),
IsoDateTimeOffsetConverter.Singleton
},
};
}
internal class AggregateIdConverter : JsonConverter<AggregateId>
{
public override bool CanConvert(Type t) => t == typeof(AggregateId);
public override AggregateId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
switch (value)
{
case "Offer Category Created":
return AggregateId.OfferCategoryCreated;
case "Offer Category Deleted":
return AggregateId.OfferCategoryDeleted;
case "Offer Category Updated":
return AggregateId.OfferCategoryUpdated;
}
throw new Exception("Cannot unmarshal type AggregateId");
}
public override void Write(Utf8JsonWriter writer, AggregateId value, JsonSerializerOptions options)
{
switch (value)
{
case AggregateId.OfferCategoryCreated:
JsonSerializer.Serialize(writer, "Offer Category Created", options);
return;
case AggregateId.OfferCategoryDeleted:
JsonSerializer.Serialize(writer, "Offer Category Deleted", options);
return;
case AggregateId.OfferCategoryUpdated:
JsonSerializer.Serialize(writer, "Offer Category Updated", options);
return;
}
throw new Exception("Cannot marshal type AggregateId");
}
public static readonly AggregateIdConverter Singleton = new AggregateIdConverter();
}
public class DateOnlyConverter : JsonConverter<DateOnly>
{
private readonly string serializationFormat;
public DateOnlyConverter() : this(null) { }
public DateOnlyConverter(string? serializationFormat)
{
this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
}
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
return DateOnly.Parse(value!);
}
public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(serializationFormat));
}
public class TimeOnlyConverter : JsonConverter<TimeOnly>
{
private readonly string serializationFormat;
public TimeOnlyConverter() : this(null) { }
public TimeOnlyConverter(string? serializationFormat)
{
this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
}
public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
return TimeOnly.Parse(value!);
}
public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(serializationFormat));
}
internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
{
public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
private string? _dateTimeFormat;
private CultureInfo? _culture;
public DateTimeStyles DateTimeStyles
{
get => _dateTimeStyles;
set => _dateTimeStyles = value;
}
public string? DateTimeFormat
{
get => _dateTimeFormat ?? string.Empty;
set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
}
public CultureInfo Culture
{
get => _culture ?? CultureInfo.CurrentCulture;
set => _culture = value;
}
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
{
string text;
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
{
value = value.ToUniversalTime();
}
text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
writer.WriteStringValue(text);
}
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string? dateText = reader.GetString();
if (string.IsNullOrEmpty(dateText) == false)
{
if (!string.IsNullOrEmpty(_dateTimeFormat))
{
return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
}
else
{
return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
}
}
else
{
return default(DateTimeOffset);
}
}
public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
}
}
#pragma warning restore CS8618
#pragma warning restore CS8601
#pragma warning restore CS8603
OfferCategoryEvent
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "OfferCategoryEvent.json",
"description": "OfferCategoryEvent schema",
"type": "object",
"allOf": [
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "EventBase.json",
"description": "Details for Shipping Order JSON schema",
"type": "object",
"properties": {
"AggregateId": {
"description": "Unique ID for shipping order within Integration Broker",
"type": "string",
"format": "{FulfillmentSystemId}-{FulfillmentSystemCustomerId}-{ShippingOrderId}"
},
"CorrelationId": {"description": "Unique ID for SOB-external event trigger", "type": "string"},
"AggregateType": {"description": "Type of event schema", "type": "string"},
"EventActionUser": {
"description": "Username of user who triggered event",
"type": ["string", "null"],
"veraCoreSource": "SHPACK_UserName in warehouse DB. SHPACK in the OMS contains a SeqId for the warehouse table."
},
"EventDateTimeUtc": {
"description": "UTC based datetime of when event was triggered",
"type": "string"
},
"EventName": {"description": "Name of triggered event", "type": "string"},
"EventNameValuePairs": { "type": ["array", "null"], "items": {"type": "object"} },
"EventPublisherApp": {
"description": "Name of source application that published event",
"type": "string"
},
"EventSchemaVersion": {"description": "Version of event schema being used", "type": "string"},
"EventSource": {"description": "Name of system where event was triggered", "type": "string"}
},
"required": [
"AggregateId", "AggregateType", "CorrelationId", "EventDateTimeUtc", "EventName",
"EventPublisherApp", "EventSchemaVersion", "EventSource"
]
},
{
"type": "object",
"properties": {
"OfferCategory": {
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "OfferCategory.json",
"description": "OfferCategory properties",
"type": "object",
"properties": {
"CustomerId": {"description": "SOB unique ID of customer", "type": "string"},
"OfferCategoryId": {"description": "SOB globally-unique ID of category", "type": "string"},
"ParentId": {
"description": "SOB unique ID of the parent category, if there is one",
"type": ["string", "null"]
},
"Name": {"description": "Name to identify category", "type": "string"}
},
"required": ["OfferCategoryId", "CustomerId", "Name"]
}
},
"required": ["OfferCategory"]
},
{
"type": "object",
"properties": {
"EventName": {
"description": "Name of triggered event",
"type": "string",
"enum": ["Offer Category Created", "Offer Category Updated", "Offer Category Deleted"]
}
}
}
],
"examples": [
{
"AggregateId": "6-mzvanhki-4-C-5606-0046-03",
"CorrelationId": "282so37c-sac5-77s3-1ow7-74u10g0386cq",
"AggregateType": "OfferCategory",
"EventActionUser": null,
"EventDateTimeUtc": "2024-11-22T22:16:00.263",
"EventName": "Offer Category Created",
"EventNameValuePairs": null,
"EventPublisherApp": "OfferBroker Category Event Publisher",
"EventSchemaVersion": "1.0",
"EventSource": "OfferBroker",
"OfferCategory": {
"CustomerId": "customer-123",
"OfferCategoryId": "category-456",
"ParentId": null,
"Name": "Electronics"
}
}
]
}