CalculateOfferPricingResponse
Properties
-
data(['object', 'null'])Cannot contain additional properties.customerId(string, required)The customer ID for which pricing was calculated.-
offers(array, required)List of calculated offer pricing results.-
Items (object)Cannot contain additional properties.
offerId(string, required)The offer ID.extendedPrice(number, format: double, required)Total price (unitPrice * quantity).pageCount(['integer', 'null'], format: int32)Page count if applicable.priceClass(['string', 'null'])The price class applied.-
productIds(['array', 'null'])Product IDs if specified.- Items (string)
-
quantity(integer, format: int32, required)The quantity requested. unitPrice(number, format: double, required)Price per unit.
-
-
totalExtendedPrice(number, format: double, required)Sum of all extended prices.
-
failureMessages(array)- Items (string)
-
informationalMessages(array)- Items (string)
-
operationWasSuccessful(boolean)
Quicktype Command
quicktype \
--framework SystemTextJson \
--lang cs \
--number-type double \
--src-lang schema \
--no-check-required \
--density dense \
--features complete \
--namespace OtpSchema.Api.OfferBroker.CalculateOfferPricingResponse \
--src .working/build/internal/json-schema-for-cs/CalculateOfferPricingResponse.json -o .working/build/internal/csharp/OtpSchema/Api/OfferBroker/CalculateOfferPricingResponse.cs
CalculateOfferPricingResponse
// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
// using OtpSchema.Api.OfferBroker.CalculateOfferPricingResponse;
//
// var calculateOfferPricingResponse = CalculateOfferPricingResponse.FromJson(jsonString);
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8603
namespace OtpSchema.Api.OfferBroker.CalculateOfferPricingResponse
{
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 CalculateOfferPricingResponse
{
[J("data")] public Data Data { get; set; }
[J("failureMessages")] public string[]? FailureMessages { get; set; }
[J("informationalMessages")] public string[]? InformationalMessages { get; set; }
[J("operationWasSuccessful")] public bool OperationWasSuccessful { get; set; }
}
public partial class Data
{
[J("customerId")] public string CustomerId { get; set; } // The customer ID for which pricing was calculated.
[J("offers")] public Offer[]? Offers { get; set; } // List of calculated offer pricing results.
[J("totalExtendedPrice")] public double TotalExtendedPrice { get; set; } // Sum of all extended prices.
}
public partial class Offer
{
[J("extendedPrice")] public double ExtendedPrice { get; set; } // Total price (unitPrice * quantity).
[J("offerId")] public string OfferId { get; set; } // The offer ID.
[J("pageCount")] public long? PageCount { get; set; } // Page count if applicable.
[J("priceClass")] public string PriceClass { get; set; } // The price class applied.
[J("productIds")] public string[]? ProductIds { get; set; } // Product IDs if specified.
[J("quantity")] public long Quantity { get; set; } // The quantity requested.
[J("unitPrice")] public double UnitPrice { get; set; } // Price per unit.
}
public partial class CalculateOfferPricingResponse
{
public static CalculateOfferPricingResponse FromJson(string json) => JsonSerializer.Deserialize<CalculateOfferPricingResponse>(json, OtpSchema.Api.OfferBroker.CalculateOfferPricingResponse.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this CalculateOfferPricingResponse self) => JsonSerializer.Serialize(self, OtpSchema.Api.OfferBroker.CalculateOfferPricingResponse.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
{
Converters =
{
new DateOnlyConverter(),
new TimeOnlyConverter(),
IsoDateTimeOffsetConverter.Singleton
},
};
}
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
CalculateOfferPricingResponse
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "CalculateOfferPricingResponse.json",
"type": "object",
"additionalProperties": false,
"properties": {
"data": {
"type": ["object", "null"],
"additionalProperties": false,
"properties": {
"customerId": {
"description": "The customer ID for which pricing was calculated.",
"type": "string"
},
"offers": {
"description": "List of calculated offer pricing results.",
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"offerId": {"description": "The offer ID.", "type": "string"},
"extendedPrice": {
"description": "Total price (unitPrice * quantity).",
"type": "number",
"format": "double"
},
"pageCount": {
"description": "Page count if applicable.",
"type": ["integer", "null"],
"format": "int32"
},
"priceClass": { "description": "The price class applied.", "type": ["string", "null"] },
"productIds": {
"description": "Product IDs if specified.",
"type": ["array", "null"],
"items": {"type": "string"}
},
"quantity": {"description": "The quantity requested.", "type": "integer", "format": "int32"},
"unitPrice": {"description": "Price per unit.", "type": "number", "format": "double"}
},
"required": ["offerId", "quantity", "unitPrice", "extendedPrice"]
}
},
"totalExtendedPrice": {
"description": "Sum of all extended prices.",
"type": "number",
"format": "double"
}
},
"required": ["customerId", "offers", "totalExtendedPrice"]
},
"failureMessages": { "type": "array", "items": {"type": "string"} },
"informationalMessages": { "type": "array", "items": {"type": "string"} },
"operationWasSuccessful": {"type": "boolean"}
},
"required": ["failureMessages", "informationalMessages", "operationWasSuccessful", "data"]
}