Skip to content

GetCustomerTokenRequest

Properties

  • sourceSystemId (['integer', 'null'], format: int32)This is an automatically generated field added by middleware. It is considered read-only.
  • clientName (string)
  • password (string)

Examples

{
    "clientName": "Tliw1cu7ad6qbrpBncV1aCoFhQUqVMYn",
    "password": "l0RHIXhw50egq65DkO3YpawB999UOw1VRgsIlaw8LZQKdS3h5gW-LoJ7wmQTSJLZ"
}

Quicktype Command

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

namespace OtpSchema.Api.IdentityBroker.GetCustomerTokenRequest
{
    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 GetCustomerTokenRequest
    {
        [J("clientName")]     public string ClientName { get; set; }   
        [J("password")]       public string Password { get; set; }     
        [J("sourceSystemId")] public long? SourceSystemId { get; set; } // This is an automatically generated field added by middleware.  It is considered read-only
    }

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

    public static class Serialize
    {
        public static string ToJson(this GetCustomerTokenRequest self) => JsonSerializer.Serialize(self, OtpSchema.Api.IdentityBroker.GetCustomerTokenRequest.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

GetCustomerTokenRequest
{
  "$schema": "http://json-schema.org/draft-07/schema#", 
  "$id": "GetCustomerTokenRequest.json", 
  "type": "object", 
  "additionalProperties": false, 
  "properties": {
    "sourceSystemId": {
      "description": "This is an automatically generated field added by middleware.  It is considered read-only", 
      "type": ["integer", "null"], 
      "format": "int32", 
      "readonly": true
    }, 
    "clientName": {"type": "string"}, 
    "password": {"type": "string"}
  }, 
  "required": ["clientName", "password"], 
  "examples": [
    {
      "clientName": "Tliw1cu7ad6qbrpBncV1aCoFhQUqVMYn", 
      "password": "l0RHIXhw50egq65DkO3YpawB999UOw1VRgsIlaw8LZQKdS3h5gW-LoJ7wmQTSJLZ"
    }
  ]
}