/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; namespace QuantConnect.Brokerages.Authentication { /// /// Represents the base request for obtaining an access token, including brokerage and account information. /// public abstract class AccessTokenMetaDataRequest { /// /// Gets the name of the brokerage associated with the access token request. /// The value is normalized to lowercase. /// public string Brokerage { get; } /// /// Gets the account identifier (e.g., account number) associated with the brokerage. /// public string AccountId { get; } /// /// Initializes a new instance of the class. /// /// The name of the brokerage making the request. Will be normalized to lowercase. /// The account number or identifier associated with the brokerage. protected AccessTokenMetaDataRequest(string brokerage, string accountId) { #pragma warning disable CA1308 // Normalize strings to uppercase Brokerage = brokerage.ToLowerInvariant(); #pragma warning restore CA1308 // Normalize strings to uppercase AccountId = accountId; } /// /// Serializes the request into a compact JSON string with camelCase property naming. /// /// A JSON string representing the current request. public string ToJson() { return JsonConvert.SerializeObject(this, new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver(), Formatting = Formatting.None }); } } }