From f32b21b447f069cfaa93da26e0abdacf0c0a3fe1 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 29 Nov 2023 14:59:03 -0700 Subject: [PATCH] [chore] Add missing docstrings (#522) --- EasyPost/Hooks.cs | 13 +++++++++++- EasyPost/Models/API/CarrierAccountType.cs | 26 +++++++++++++++++++++++ EasyPost/Parameters/BaseParameters.cs | 2 ++ EasyPost/Parameters/IBaseParameters.cs | 12 +++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/EasyPost/Hooks.cs b/EasyPost/Hooks.cs index dbdf10d33..78aea32bc 100644 --- a/EasyPost/Hooks.cs +++ b/EasyPost/Hooks.cs @@ -1,11 +1,14 @@ using System; -using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Net.Http.Headers; +using EasyPost._base; namespace EasyPost; +/// +/// Class representing a set of callbacks to use for introspecting API requests made by an . +/// public class Hooks { /// @@ -20,6 +23,10 @@ public class Hooks public EventHandler? OnRequestResponseReceived { get; set; } } +/// +/// Represents a set of containing information about an in-flight HTTP request. +/// This set is passed into the event handler. +/// public class OnRequestExecutingEventArgs : EventArgs { /// @@ -71,6 +78,10 @@ internal OnRequestExecutingEventArgs(HttpRequestMessage request, int timestamp, } } +/// +/// Represents a set of containing information about an HTTP response received by the client. +/// This set is passed into the event handler. +/// public class OnRequestResponseReceivedEventArgs : EventArgs { /// diff --git a/EasyPost/Models/API/CarrierAccountType.cs b/EasyPost/Models/API/CarrierAccountType.cs index 82b3cd33c..ac40be843 100644 --- a/EasyPost/Models/API/CarrierAccountType.cs +++ b/EasyPost/Models/API/CarrierAccountType.cs @@ -3,18 +3,44 @@ namespace EasyPost.Models.API; +/// +/// Enums representing specific carrier account types. +/// public class CarrierAccountType : ValueEnum { + /// + /// Represents a FedEx carrier account. + /// public static readonly CarrierAccountType FedEx = new CarrierAccountType(26, "FedexAccount"); + + /// + /// Represents a FedEx SmartPost carrier account. + /// public static readonly CarrierAccountType FedExSmartPost = new CarrierAccountType(30, "FedexSmartpostAccount"); + + /// + /// Represents a UPS carrier account. + /// public static readonly CarrierAccountType Ups = new CarrierAccountType(59, "UpsAccount"); + /// + /// Constructor for CarrierAccountType enum. + /// + /// Internal ID of the enum. Must be unique among all enums of this specific type. + /// Name of the carrier account type. Stored as the value associated with this enum. private CarrierAccountType(int id, string name) : base(id, name) { } + /// + /// Gets the name of this . + /// public string Name => (string)Value; + /// + /// Gets all enums. + /// + /// public static IEnumerable All() => GetAll(); } diff --git a/EasyPost/Parameters/BaseParameters.cs b/EasyPost/Parameters/BaseParameters.cs index d1249ef56..70680f375 100644 --- a/EasyPost/Parameters/BaseParameters.cs +++ b/EasyPost/Parameters/BaseParameters.cs @@ -231,10 +231,12 @@ private void Add(RequestParameterAttribute requestParameterAttribute, object? va // Get the key and update the list of keys string key = keys[0]; keys = keys.Skip(1).ToArray(); +#pragma warning disable CA1854 // Don't want to use TryGetValue because no need for value if (!dictionary.ContainsKey(key)) { dictionary[key] = UpdateDictionary(new Dictionary(), keys, value); } +#pragma warning restore CA1854 object? subDirectory = dictionary[key]; if (subDirectory is Dictionary subDictionary) diff --git a/EasyPost/Parameters/IBaseParameters.cs b/EasyPost/Parameters/IBaseParameters.cs index 53776873e..40dca45da 100644 --- a/EasyPost/Parameters/IBaseParameters.cs +++ b/EasyPost/Parameters/IBaseParameters.cs @@ -12,10 +12,22 @@ namespace EasyPost.Parameters { + /// + /// Base interface for all EasyPost API parameters. + /// public interface IBaseParameters { + /// + /// Convert this object to a . + /// + /// public Dictionary ToDictionary(); + /// + /// Convert this object to a sub- based on the parent parameter object type. + /// + /// + /// public Dictionary ToSubDictionary(Type parentParameterObjectType); } }