GetCalculateOfferPricingRequest
Properties
-
offers(array)List of offers to calculate pricing for. At least one offer must be provided. Length must be at least 1.-
Items (object)Cannot contain additional properties.
offerId(string, required)Offer ID. Required, must not be empty.pageCount(['integer', 'null'], format: int32)Page count (used only if tiers and page count tiers exist). Must be >= 1 when provided. Minimum:1.-
productIds(['array', 'null'])Optional product IDs for product-list type offers.- Items (string)
-
quantity(integer, format: int32, required)Quantity to order. Must be >= 0. Minimum:0.
-
-
priceClasses(['array', 'null'])Preferred price classes (priority order). Nullable.- Items (string)
Quicktype Command
quicktype \
--framework SystemTextJson \
--lang cs \
--number-type double \
--src-lang schema \
--no-check-required \
--density dense \
--features complete \
--namespace OtpSchema.Api.OfferBroker.GetCalculateOfferPricingRequest \
--src .working/build/internal/json-schema-for-cs/GetCalculateOfferPricingRequest.json -o .working/build/internal/csharp/OtpSchema/Api/OfferBroker/GetCalculateOfferPricingRequest.cs
GetCalculateOfferPricingRequest
// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
// using OtpSchema.Api.OfferBroker.GetCalculateOfferPricingRequest;
//
// var getCalculateOfferPricingRequest = GetCalculateOfferPricingRequest.FromJson(jsonString);
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8603
namespace OtpSchema.Api.OfferBroker.GetCalculateOfferPricingRequest
{
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 GetCalculateOfferPricingRequest
{
[J("offers")] public Offer[]? Offers { get; set; } // List of offers to calculate pricing for. At least one offer must be provided.
[J("priceClasses")] public string[]? PriceClasses { get; set; } // Preferred price classes (priority order). Nullable.
}
public partial class Offer
{
[J("offerId")][JsonConverter(typeof(MinMaxLengthCheckConverter))] public string OfferId { get; set; } // Offer ID. Required, must not be empty.
[J("pageCount")] public long? PageCount { get; set; } // Page count (used only if tiers and page count tiers exist). Must be >= 1 when provided.
[J("productIds")] public string[]? ProductIds { get; set; } // Optional product IDs for product-list type offers.
[J("quantity")] public long Quantity { get; set; } // Quantity to order. Must be >= 0.
}
public partial class GetCalculateOfferPricingRequest
{
public static GetCalculateOfferPricingRequest FromJson(string json) => JsonSerializer.Deserialize<GetCalculateOfferPricingRequest>(json, OtpSchema.Api.OfferBroker.GetCalculateOfferPricingRequest.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this GetCalculateOfferPricingRequest self) => JsonSerializer.Serialize(self, OtpSchema.Api.OfferBroker.GetCalculateOfferPricingRequest.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
{
Converters =
{
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();
}
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
GetCalculateOfferPricingRequest
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "GetCalculateOfferPricingRequest.json",
"type": "object",
"additionalProperties": false,
"properties": {
"offers": {
"description": "List of offers to calculate pricing for. At least one offer must be provided.",
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"offerId": {
"description": "Offer ID. Required, must not be empty.",
"type": "string",
"minLength": 1
},
"pageCount": {
"description": "Page count (used only if tiers and page count tiers exist). Must be >= 1 when provided.",
"type": ["integer", "null"],
"format": "int32",
"minimum": 1
},
"productIds": {
"description": "Optional product IDs for product-list type offers.",
"type": ["array", "null"],
"items": {"type": "string"}
},
"quantity": {
"description": "Quantity to order. Must be >= 0.",
"type": "integer",
"format": "int32",
"minimum": 0
}
},
"required": ["offerId", "quantity"]
},
"minItems": 1
},
"priceClasses": {
"description": "Preferred price classes (priority order). Nullable.",
"type": ["array", "null"],
"items": {"type": "string"}
}
},
"required": ["offers"]
}