Skip to content

CreateOfferRequest

Properties

  • omsOfferId (['string', 'null'])Unique offer identifier assigned by the OMS.
  • xmPieTemplateId (['string', 'null'])
  • xmPieUStoreId (['string', 'null'])
  • description (['string', 'null'])
  • accessGroups (['array', 'null'])

    • Items (string)
  • additionalPropsRequiredOnOrder (['array', 'null'])

    • Items (object)Cannot contain additional properties.

      • type (string)Default: "string".
      • hint (['string', 'null'])
      • label (['string', 'null'])
      • name (string, required)
      • value (['string', 'null'])
  • availableEndDate (['string', 'null'])Timestamp of when offer is no longer available. This should be in UTC.

  • availableStartDate (['string', 'null'])Timestamp of when offer is available. This should be in UTC.
  • categoryIds (['array', 'null'])

    • Items (string)
  • comments (['string', 'null'])

  • defaultPrice (['number', 'null'], format: double)
  • deliveryScheduleCron (['string', 'null'])
  • doSuppressShippingAndHandling (['boolean', 'null'])
  • fixedOrderQuantities (['array', 'null'])

    • Items (number, format: double)
  • fullImageUrl (['string', 'null'])

  • isActive (['boolean', 'null'])
  • isAvailableViaCoopFunds (['boolean', 'null'])
  • isInventoried (['boolean', 'null'])
  • isTaxable (['boolean', 'null'])
  • lastUpdatedDateTimeUtc (['string', 'null'])If provided, must not be in the future.
  • number (string)Required. Offer number. Must not be empty.
  • offerType (string)Required. Must be one of: Direct Mail, Download, Drop Ship, Email, Omnichannel, Product List, VDM. Must be one of: ["Direct Mail", "Download", "Drop Ship", "Email", "Omnichannel", "Product List", "VDM"].
  • omniChannel (['object', 'null'])Cannot contain additional properties.

    • offers (['array', 'null'])

      • Items (object)Cannot contain additional properties.

        • offerId (['string', 'null'])
        • deliveryChannel (['string', 'null'])
  • onlyShipMethodsAvailable (['array', 'null'])

    • Items (string)
  • orderMaximum (['integer', 'null'], format: int32)Minimum: 1.

  • orderMinimum (['integer', 'null'], format: int32)Minimum: 1.
  • pdfUrl (['string', 'null'])
  • priceClasses (['array', 'null'])

    • Items (object)Cannot contain additional properties.

      • name (string)
      • price (['number', 'null'], format: double)
      • priceTiers (['array', 'null'])

        • Items (object)Cannot contain additional properties.

          • maximumQuantity (['integer', 'null'], format: int32)
          • minimumQuantity (['integer', 'null'], format: int32)
          • pageCounts (['array', 'null'])

            • Items (object)Cannot contain additional properties.

              • maximumPages (['integer', 'null'], format: int32)
              • minimumPages (['integer', 'null'], format: int32)
              • price (['number', 'null'], format: double)
          • price (number, format: double, required)

  • productClusters (['array', 'null'])Required if offerType is 'Product List'. Must contain at least one ProductCluster with at least one Product, each with a non-empty productId and pageCount >= 1 if provided.

    • Items (object)Cannot contain additional properties.

      • id (['string', 'null'])
      • products (['array', 'null'])Length must be at least 1.

        • Items (object)Cannot contain additional properties.

          • productId (string, required)
          • associatedFileName (['string', 'null'])
          • pageCount (['integer', 'null'], format: int32)
          • productQuantityInOffer (integer, format: int32, required)
          • surcharge (['number', 'null'], format: double)
  • requiresApproval (['boolean', 'null'])

  • secureEmailBody (['string', 'null'])
  • secureEmailSubject (['string', 'null'])
  • surcharge (['number', 'null'], format: double)
  • thumbnailUrl (['string', 'null'])
  • unitOfMeasure (['string', 'null'])
  • weightInPounds (['number', 'null'], format: double)

Quicktype Command

quicktype \
    --framework SystemTextJson  \
    --lang cs  \
    --number-type double  \
    --src-lang schema  \
    --no-check-required  \
    --density dense  \
    --features complete  \
    --namespace OtpSchema.Api.OfferBroker.CreateOfferRequest  \
    --src .working/build/internal/json-schema-for-cs/CreateOfferRequest.json -o .working/build/internal/csharp/OtpSchema/Api/OfferBroker/CreateOfferRequest.cs
CreateOfferRequest
// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
//    using OtpSchema.Api.OfferBroker.CreateOfferRequest;
//
//    var createOfferRequest = CreateOfferRequest.FromJson(jsonString);
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8603

namespace OtpSchema.Api.OfferBroker.CreateOfferRequest
{
    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;

    public partial class CreateOfferRequest
    {
        [J("accessGroups")]                                              public string[] AccessGroups { get; set; }                                          
        [J("additionalPropsRequiredOnOrder")]                            public AdditionalPropsRequiredOnOrder[] AdditionalPropsRequiredOnOrder { get; set; }
        [J("availableEndDate")]                                          public string AvailableEndDate { get; set; }                                         // Timestamp of when offer is no longer available.  This should be in UTC.
        [J("availableStartDate")]                                        public string AvailableStartDate { get; set; }                                       // Timestamp of when offer is available.  This should be in UTC.
        [J("categoryIds")]                                               public string[] CategoryIds { get; set; }                                           
        [J("comments")]                                                  public string Comments { get; set; }                                                
        [J("defaultPrice")]                                              public double? DefaultPrice { get; set; }                                           
        [J("deliveryScheduleCron")]                                      public string DeliveryScheduleCron { get; set; }                                    
        [J("description")]                                               public string Description { get; set; }                                             
        [J("doSuppressShippingAndHandling")]                             public bool? DoSuppressShippingAndHandling { get; set; }                            
        [J("fixedOrderQuantities")]                                      public double[] FixedOrderQuantities { get; set; }                                  
        [J("fullImageUrl")]                                              public string FullImageUrl { get; set; }                                            
        [J("isActive")]                                                  public bool? IsActive { get; set; }                                                 
        [J("isAvailableViaCoopFunds")]                                   public bool? IsAvailableViaCoopFunds { get; set; }                                  
        [J("isInventoried")]                                             public bool? IsInventoried { get; set; }                                            
        [J("isTaxable")]                                                 public bool? IsTaxable { get; set; }                                                
        [J("lastUpdatedDateTimeUtc")]                                    public string LastUpdatedDateTimeUtc { get; set; }                                   // If provided, must not be in the future.
        [J("number")][JsonConverter(typeof(MinMaxLengthCheckConverter))] public string Number { get; set; }                                                   // Required. Offer number. Must not be empty.
        [J("offerType")]                                                 public OfferType OfferType { get; set; }                                             // Required. Must be one of: Direct Mail, Download, Drop Ship, Email, Omnichannel, Product; List, VDM.
        [J("omniChannel")]                                               public OmniChannel OmniChannel { get; set; }                                        
        [J("omsOfferId")]                                                public string OmsOfferId { get; set; }                                               // Unique offer identifier assigned by the OMS.
        [J("onlyShipMethodsAvailable")]                                  public string[] OnlyShipMethodsAvailable { get; set; }                              
        [J("orderMaximum")]                                              public long? OrderMaximum { get; set; }                                             
        [J("orderMinimum")]                                              public long? OrderMinimum { get; set; }                                             
        [J("pdfUrl")]                                                    public string PdfUrl { get; set; }                                                  
        [J("priceClasses")]                                              public PriceClass[] PriceClasses { get; set; }                                      
        [J("productClusters")]                                           public ProductCluster[] ProductClusters { get; set; }                                // Required if offerType is 'Product List'. Must contain at least one ProductCluster with at; least one Product, each with a non-empty productId and pageCount >= 1 if provided.
        [J("requiresApproval")]                                          public bool? RequiresApproval { get; set; }                                         
        [J("secureEmailBody")]                                           public string SecureEmailBody { get; set; }                                         
        [J("secureEmailSubject")]                                        public string SecureEmailSubject { get; set; }                                      
        [J("surcharge")]                                                 public double? Surcharge { get; set; }                                              
        [J("thumbnailUrl")]                                              public string ThumbnailUrl { get; set; }                                            
        [J("unitOfMeasure")]                                             public string UnitOfMeasure { get; set; }                                           
        [J("weightInPounds")]                                            public double? WeightInPounds { get; set; }                                         
        [J("xmPieTemplateId")]                                           public string XmPieTemplateId { get; set; }                                         
        [J("xmPieUStoreId")]                                             public string XmPieUStoreId { get; set; }                                           
    }

    public partial class AdditionalPropsRequiredOnOrder
    {
        [J("hint")]                                                              public string Hint { get; set; } 
        [J("label")]                                                             public string Label { get; set; }
        [J("name")]                                                              public string Name { get; set; } 
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)][J("type")] public string Type { get; set; } 
        [J("value")]                                                             public string Value { get; set; }
    }

    public partial class OmniChannel
    {
        [J("offers")] public Offer[] Offers { get; set; }
    }

    public partial class Offer
    {
        [J("deliveryChannel")] public string DeliveryChannel { get; set; }
        [J("offerId")]         public string OfferId { get; set; }        
    }

    public partial class PriceClass
    {
        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)][J("name")] public string Name { get; set; }           
        [J("price")]                                                             public double? Price { get; set; }         
        [J("priceTiers")]                                                        public PriceTier[] PriceTiers { get; set; }
    }

    public partial class PriceTier
    {
        [J("maximumQuantity")] public long? MaximumQuantity { get; set; } 
        [J("minimumQuantity")] public long? MinimumQuantity { get; set; } 
        [J("pageCounts")]      public PageCount[] PageCounts { get; set; }
        [J("price")]           public double Price { get; set; }          
    }

    public partial class PageCount
    {
        [J("maximumPages")] public long? MaximumPages { get; set; }
        [J("minimumPages")] public long? MinimumPages { get; set; }
        [J("price")]        public double? Price { get; set; }     
    }

    public partial class ProductCluster
    {
        [J("id")]       public string Id { get; set; }         
        [J("products")] public Product[] Products { get; set; }
    }

    public partial class Product
    {
        [J("associatedFileName")]     public string AssociatedFileName { get; set; }  
        [J("pageCount")]              public long? PageCount { get; set; }            
        [J("productId")]              public string ProductId { get; set; }           
        [J("productQuantityInOffer")] public long ProductQuantityInOffer { get; set; }
        [J("surcharge")]              public double? Surcharge { get; set; }          
    }

    /// <summary>Required. Must be one of: Direct Mail, Download, Drop Ship, Email, Omnichannel, Product; List, VDM.</summary>
    public enum OfferType { DirectMail, Download, DropShip, Email, Omnichannel, ProductList, Vdm };

    public partial class CreateOfferRequest
    {
        public static CreateOfferRequest FromJson(string json) => JsonSerializer.Deserialize<CreateOfferRequest>(json, OtpSchema.Api.OfferBroker.CreateOfferRequest.Converter.Settings);
    }

    public static class Serialize
    {
        public static string ToJson(this CreateOfferRequest self) => JsonSerializer.Serialize(self, OtpSchema.Api.OfferBroker.CreateOfferRequest.Converter.Settings);
    }

    internal static class Converter
    {
        public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
        {
            Converters =
            {
                OfferTypeConverter.Singleton,
                new DateOnlyConverter(),
                new TimeOnlyConverter(),
                IsoDateTimeOffsetConverter.Singleton
            },
        };
    }

    internal class MinMaxLengthCheckConverter : JsonConverter<string>
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var value = reader.GetString();
            if (value != null && value.Length >= 1)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
        {
            if (value != null && value.Length >= 1)
            {
                JsonSerializer.Serialize(writer, value, options);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter Singleton = new MinMaxLengthCheckConverter();
    }

    internal class OfferTypeConverter : JsonConverter<OfferType>
    {
        public override bool CanConvert(Type t) => t == typeof(OfferType);

        public override OfferType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var value = reader.GetString();
            switch (value)
            {
                case "Direct Mail":
                    return OfferType.DirectMail;
                case "Download":
                    return OfferType.Download;
                case "Drop Ship":
                    return OfferType.DropShip;
                case "Email":
                    return OfferType.Email;
                case "Omnichannel":
                    return OfferType.Omnichannel;
                case "Product List":
                    return OfferType.ProductList;
                case "VDM":
                    return OfferType.Vdm;
            }
            throw new Exception("Cannot unmarshal type OfferType");
        }

        public override void Write(Utf8JsonWriter writer, OfferType value, JsonSerializerOptions options)
        {
            switch (value)
            {
                case OfferType.DirectMail:
                    JsonSerializer.Serialize(writer, "Direct Mail", options);
                    return;
                case OfferType.Download:
                    JsonSerializer.Serialize(writer, "Download", options);
                    return;
                case OfferType.DropShip:
                    JsonSerializer.Serialize(writer, "Drop Ship", options);
                    return;
                case OfferType.Email:
                    JsonSerializer.Serialize(writer, "Email", options);
                    return;
                case OfferType.Omnichannel:
                    JsonSerializer.Serialize(writer, "Omnichannel", options);
                    return;
                case OfferType.ProductList:
                    JsonSerializer.Serialize(writer, "Product List", options);
                    return;
                case OfferType.Vdm:
                    JsonSerializer.Serialize(writer, "VDM", options);
                    return;
            }
            throw new Exception("Cannot marshal type OfferType");
        }

        public static readonly OfferTypeConverter Singleton = new OfferTypeConverter();
    }

    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

CreateOfferRequest
{
  "$schema": "http://json-schema.org/draft-07/schema#", 
  "$id": "CreateOfferRequest.json", 
  "type": "object", 
  "allOf": [
    {
      "if": { "properties": { "offerType": {"const": "Product List"} } }, 
      "then": {
        "properties": { "productClusters": {"minItems": 1} }, 
        "required": ["productClusters"]
      }
    }
  ], 
  "additionalProperties": false, 
  "properties": {
    "omsOfferId": {
      "description": "Unique offer identifier assigned by the OMS.", 
      "type": ["string", "null"]
    }, 
    "xmPieTemplateId": { "type": ["string", "null"] }, 
    "xmPieUStoreId": { "type": ["string", "null"] }, 
    "description": { "type": ["string", "null"] }, 
    "accessGroups": { "type": ["array", "null"], "items": {"type": "string"} }, 
    "additionalPropsRequiredOnOrder": {
      "type": ["array", "null"], 
      "items": {
        "type": "object", 
        "additionalProperties": false, 
        "properties": {
          "type": {"type": "string", "default": "string"}, 
          "hint": { "type": ["string", "null"] }, 
          "label": { "type": ["string", "null"] }, 
          "name": {"type": "string"}, 
          "value": { "type": ["string", "null"] }
        }, 
        "required": ["name"]
      }
    }, 
    "availableEndDate": {
      "description": "Timestamp of when offer is no longer available.  This should be in UTC.", 
      "type": ["string", "null"]
    }, 
    "availableStartDate": {
      "description": "Timestamp of when offer is available.  This should be in UTC.", 
      "type": ["string", "null"]
    }, 
    "categoryIds": { "type": ["array", "null"], "items": {"type": "string"} }, 
    "comments": { "type": ["string", "null"] }, 
    "defaultPrice": { "type": ["number", "null"], "format": "double" }, 
    "deliveryScheduleCron": { "type": ["string", "null"] }, 
    "doSuppressShippingAndHandling": { "type": ["boolean", "null"] }, 
    "fixedOrderQuantities": { "type": ["array", "null"], "items": {"type": "number", "format": "double"} }, 
    "fullImageUrl": { "type": ["string", "null"] }, 
    "isActive": { "type": ["boolean", "null"] }, 
    "isAvailableViaCoopFunds": { "type": ["boolean", "null"] }, 
    "isInventoried": { "type": ["boolean", "null"] }, 
    "isTaxable": { "type": ["boolean", "null"] }, 
    "lastUpdatedDateTimeUtc": {
      "description": "If provided, must not be in the future.", 
      "type": ["string", "null"]
    }, 
    "number": {
      "description": "Required. Offer number. Must not be empty.", 
      "type": "string", 
      "minLength": 1
    }, 
    "offerType": {
      "description": "Required. Must be one of: Direct Mail, Download, Drop Ship, Email, Omnichannel, Product List, VDM.", 
      "type": "string", 
      "enum": [
        "Direct Mail", "Download", "Drop Ship", "Email", "Omnichannel", "Product List", 
        "VDM"
      ], 
      "minLength": 1
    }, 
    "omniChannel": {
      "type": ["object", "null"], 
      "additionalProperties": false, 
      "properties": {
        "offers": {
          "type": ["array", "null"], 
          "items": {
            "type": "object", 
            "additionalProperties": false, 
            "properties": {
              "offerId"        : { "type": ["string", "null"] }, 
              "deliveryChannel": { "type": ["string", "null"] }
            }
          }
        }
      }
    }, 
    "onlyShipMethodsAvailable": { "type": ["array", "null"], "items": {"type": "string"} }, 
    "orderMaximum": { "type": ["integer", "null"], "format": "int32", "minimum": 1 }, 
    "orderMinimum": { "type": ["integer", "null"], "format": "int32", "minimum": 1 }, 
    "pdfUrl": { "type": ["string", "null"] }, 
    "priceClasses": {
      "type": ["array", "null"], 
      "items": {
        "type": "object", 
        "additionalProperties": false, 
        "properties": {
          "name": {"type": "string"}, 
          "price": { "type": ["number", "null"], "format": "double" }, 
          "priceTiers": {
            "type": ["array", "null"], 
            "items": {
              "type": "object", 
              "additionalProperties": false, 
              "properties": {
                "maximumQuantity": { "type": ["integer", "null"], "format": "int32" }, 
                "minimumQuantity": { "type": ["integer", "null"], "format": "int32" }, 
                "pageCounts": {
                  "type": ["array", "null"], 
                  "items": {
                    "type": "object", 
                    "additionalProperties": false, 
                    "properties": {
                      "maximumPages": { "type": ["integer", "null"], "format": "int32"  }, 
                      "minimumPages": { "type": ["integer", "null"], "format": "int32"  }, 
                      "price"       : { "type": ["number", "null"] , "format": "double" }
                    }
                  }
                }, 
                "price": {"type": "number", "format": "double"}
              }, 
              "required": ["price"]
            }
          }
        }
      }
    }, 
    "productClusters": {
      "description": "Required if offerType is 'Product List'. Must contain at least one ProductCluster with at least one Product, each with a non-empty productId and pageCount >= 1 if provided.", 
      "type": ["array", "null"], 
      "items": {
        "type": "object", 
        "additionalProperties": false, 
        "properties": {
          "id": { "type": ["string", "null"] }, 
          "products": {
            "type": ["array", "null"], 
            "items": {
              "type": "object", 
              "additionalProperties": false, 
              "properties": {
                "productId"             : { "type": "string"                                }, 
                "associatedFileName"    : { "type": ["string", "null"]                      }, 
                "pageCount"             : { "type": ["integer", "null"], "format": "int32"  }, 
                "productQuantityInOffer": { "type": "integer"          , "format": "int32"  }, 
                "surcharge"             : { "type": ["number", "null"] , "format": "double" }
              }, 
              "required": ["productId", "productQuantityInOffer"]
            }, 
            "minItems": 1
          }
        }
      }
    }, 
    "requiresApproval": { "type": ["boolean", "null"] }, 
    "secureEmailBody": { "type": ["string", "null"] }, 
    "secureEmailSubject": { "type": ["string", "null"] }, 
    "surcharge": { "type": ["number", "null"], "format": "double" }, 
    "thumbnailUrl": { "type": ["string", "null"] }, 
    "unitOfMeasure": { "type": ["string", "null"] }, 
    "weightInPounds": { "type": ["number", "null"], "format": "double" }
  }, 
  "required": ["number", "offerType"]
}