Skip to content

InternalCalculateOfferPricingResponse

Properties

  • data (['object', 'null'])Response data containing calculated pricing. Cannot contain additional properties.

    • customerId (string, required)Customer ID used for pricing calculation.
    • offers (array, required)List of calculated offer pricing details.

      • Items (object)Cannot contain additional properties.

        • offerId (string, required)Offer ID.
        • extendedPrice (number, format: double, required)Extended price (unit price * quantity + surcharges). Minimum: 0.
        • pageCount (['integer', 'null'], format: int32)Page count used for pricing. Minimum: 1.
        • priceClass (['string', 'null'])Price class applied.
        • productIds (['array', 'null'])Product IDs included in pricing.

          • Items (string)
        • quantity (integer, format: int32, required)Quantity ordered. Minimum: 1.

        • unitPrice (number, format: double, required)Unit price per item. Minimum: 0.
    • totalExtendedPrice (number, format: double, required)Total extended price for all offers. Minimum: 0.

  • 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.InternalCalculateOfferPricingResponse  \
    --src .working/build/internal/json-schema-for-cs/InternalCalculateOfferPricingResponse.json -o .working/build/internal/csharp/OtpSchema/Api/OfferBroker/InternalCalculateOfferPricingResponse.cs
InternalCalculateOfferPricingResponse
// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
//    using OtpSchema.Api.OfferBroker.InternalCalculateOfferPricingResponse;
//
//    var internalCalculateOfferPricingResponse = InternalCalculateOfferPricingResponse.FromJson(jsonString);
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8603

namespace OtpSchema.Api.OfferBroker.InternalCalculateOfferPricingResponse
{
    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 InternalCalculateOfferPricingResponse
    {
        [J("data")]                   public Data Data { get; set; }                      // Response data containing calculated pricing.
        [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; }         // Customer ID used for pricing calculation.
        [J("offers")]                                                               public Offer[]? Offers { get; set; }            // List of calculated offer pricing details.
        [J("totalExtendedPrice")][JsonConverter(typeof(MinMaxValueCheckConverter))] public double TotalExtendedPrice { get; set; } // Total extended price for all offers.
    }

    public partial class Offer
    {
        [J("extendedPrice")][JsonConverter(typeof(MinMaxValueCheckConverter))] public double ExtendedPrice { get; set; } // Extended price (unit price * quantity + surcharges).
        [J("offerId")][JsonConverter(typeof(MinMaxLengthCheckConverter))]      public string OfferId { get; set; }       // Offer ID.
        [J("pageCount")]                                                       public long? PageCount { get; set; }      // Page count used for pricing.
        [J("priceClass")]                                                      public string PriceClass { get; set; }    // Price class applied.
        [J("productIds")]                                                      public string[]? ProductIds { get; set; }  // Product IDs included in pricing.
        [J("quantity")]                                                        public long Quantity { get; set; }        // Quantity ordered.
        [J("unitPrice")][JsonConverter(typeof(MinMaxValueCheckConverter))]     public double UnitPrice { get; set; }     // Unit price per item.
    }

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

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

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

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

        public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var value = reader.GetDouble();
            if (value >= 0)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type double");
        }

        public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
        {
            if (value >= 0)
            {
                JsonSerializer.Serialize(writer, value, options);
                return;
            }
            throw new Exception("Cannot marshal type double");
        }

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

    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

InternalCalculateOfferPricingResponse
{
  "$schema": "http://json-schema.org/draft-07/schema#", 
  "$id": "InternalCalculateOfferPricingResponse.json", 
  "type": "object", 
  "additionalProperties": false, 
  "properties": {
    "data": {
      "description": "Response data containing calculated pricing.", 
      "type": ["object", "null"], 
      "additionalProperties": false, 
      "properties": {
        "customerId": {"description": "Customer ID used for pricing calculation.", "type": "string"}, 
        "offers": {
          "description": "List of calculated offer pricing details.", 
          "type": "array", 
          "items": {
            "type": "object", 
            "additionalProperties": false, 
            "properties": {
              "offerId": {"description": "Offer ID.", "type": "string", "minLength": 1}, 
              "extendedPrice": {
                "description": "Extended price (unit price * quantity + surcharges).", 
                "type": "number", 
                "format": "double", 
                "minimum": 0
              }, 
              "pageCount": {
                "description": "Page count used for pricing.", 
                "type": ["integer", "null"], 
                "format": "int32", 
                "minimum": 1
              }, 
              "priceClass": { "description": "Price class applied.", "type": ["string", "null"] }, 
              "productIds": {
                "description": "Product IDs included in pricing.", 
                "type": ["array", "null"], 
                "items": {"type": "string"}
              }, 
              "quantity": {
                "description": "Quantity ordered.", 
                "type": "integer", 
                "format": "int32", 
                "minimum": 1
              }, 
              "unitPrice": {
                "description": "Unit price per item.", 
                "type": "number", 
                "format": "double", 
                "minimum": 0
              }
            }, 
            "required": ["offerId", "quantity", "unitPrice", "extendedPrice"]
          }
        }, 
        "totalExtendedPrice": {
          "description": "Total extended price for all offers.", 
          "type": "number", 
          "format": "double", 
          "minimum": 0
        }
      }, 
      "required": ["customerId", "offers", "totalExtendedPrice"]
    }, 
    "failureMessages": { "type": "array", "items": {"type": "string"} }, 
    "informationalMessages": { "type": "array", "items": {"type": "string"} }, 
    "operationWasSuccessful": {"type": "boolean"}
  }, 
  "required": ["failureMessages", "informationalMessages", "operationWasSuccessful", "data"]
}