Skip to content

Commit

Permalink
[chore] Add missing docstrings (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwithan8 authored Nov 29, 2023
1 parent 45f3e65 commit f32b21b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
13 changes: 12 additions & 1 deletion EasyPost/Hooks.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// Class representing a set of callbacks to use for introspecting API requests made by an <see cref="EasyPostClient"/>.
/// </summary>
public class Hooks
{
/// <summary>
Expand All @@ -20,6 +23,10 @@ public class Hooks
public EventHandler<OnRequestResponseReceivedEventArgs>? OnRequestResponseReceived { get; set; }
}

/// <summary>
/// Represents a set of <see cref="EventArgs"/> containing information about an in-flight HTTP request.
/// This set is passed into the <see cref="Hooks.OnRequestExecuting"/> event handler.
/// </summary>
public class OnRequestExecutingEventArgs : EventArgs
{
/// <summary>
Expand Down Expand Up @@ -71,6 +78,10 @@ internal OnRequestExecutingEventArgs(HttpRequestMessage request, int timestamp,
}
}

/// <summary>
/// Represents a set of <see cref="EventArgs"/> containing information about an HTTP response received by the client.
/// This set is passed into the <see cref="Hooks.OnRequestResponseReceived"/> event handler.
/// </summary>
public class OnRequestResponseReceivedEventArgs : EventArgs
{
/// <summary>
Expand Down
26 changes: 26 additions & 0 deletions EasyPost/Models/API/CarrierAccountType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,44 @@

namespace EasyPost.Models.API;

/// <summary>
/// Enums representing specific carrier account types.
/// </summary>
public class CarrierAccountType : ValueEnum
{
/// <summary>
/// Represents a FedEx carrier account.
/// </summary>
public static readonly CarrierAccountType FedEx = new CarrierAccountType(26, "FedexAccount");

/// <summary>
/// Represents a FedEx SmartPost carrier account.
/// </summary>
public static readonly CarrierAccountType FedExSmartPost = new CarrierAccountType(30, "FedexSmartpostAccount");

/// <summary>
/// Represents a UPS carrier account.
/// </summary>
public static readonly CarrierAccountType Ups = new CarrierAccountType(59, "UpsAccount");

/// <summary>
/// Constructor for CarrierAccountType enum.
/// </summary>
/// <param name="id">Internal ID of the enum. Must be unique among all enums of this specific type.</param>
/// <param name="name">Name of the carrier account type. Stored as the value associated with this enum.</param>
private CarrierAccountType(int id, string name)
: base(id, name)
{
}

/// <summary>
/// Gets the name of this <see cref="CarrierAccountType"/>.
/// </summary>
public string Name => (string)Value;

/// <summary>
/// Gets all <see cref="CarrierAccountType"/> enums.
/// </summary>
/// <returns></returns>
public static IEnumerable<CarrierAccountType> All() => GetAll<CarrierAccountType>();
}
2 changes: 2 additions & 0 deletions EasyPost/Parameters/BaseParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, object?>(), keys, value);
}
#pragma warning restore CA1854

object? subDirectory = dictionary[key];
if (subDirectory is Dictionary<string, object?> subDictionary)
Expand Down
12 changes: 12 additions & 0 deletions EasyPost/Parameters/IBaseParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@

namespace EasyPost.Parameters
{
/// <summary>
/// Base interface for all EasyPost API parameters.
/// </summary>
public interface IBaseParameters
{
/// <summary>
/// Convert this object to a <see cref="Dictionary{TKey,TValue}"/>.
/// </summary>
/// <returns></returns>
public Dictionary<string, object> ToDictionary();

/// <summary>
/// Convert this object to a sub-<see cref="Dictionary{TKey,TValue}"/> based on the parent parameter object type.
/// </summary>
/// <param name="parentParameterObjectType"></param>
/// <returns></returns>
public Dictionary<string, object> ToSubDictionary(Type parentParameterObjectType);
}
}

0 comments on commit f32b21b

Please sign in to comment.