Skip to content

Commit 23d2f04

Browse files
author
ducksoop
committed
docs: add documentation to code
Added extensive xmldocs to every class.
1 parent 046a0c6 commit 23d2f04

17 files changed

+356
-7
lines changed
Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
namespace QuickbaseNet.Errors
22
{
3+
/// <summary>
4+
/// Represents an error in the QuickBase API.
5+
/// </summary>
36
public class QuickbaseError
47
{
8+
/// <summary>
9+
/// Represents no error.
10+
/// </summary>
511
public static readonly QuickbaseError None = new QuickbaseError(string.Empty, string.Empty, string.Empty, QuickbaseErrorType.Failure);
12+
13+
/// <summary>
14+
/// Represents an error indicating a null value was provided.
15+
/// </summary>
616
public static readonly QuickbaseError NullValue = new QuickbaseError("Error.NullValue", "Null value was provided", string.Empty, QuickbaseErrorType.Failure);
717

18+
/// <summary>
19+
/// Initializes a new instance of the QuickbaseError class.
20+
/// </summary>
21+
/// <param name="code">The error code.</param>
22+
/// <param name="message">The error message.</param>
23+
/// <param name="description">The error description.</param>
24+
/// <param name="quickbaseErrorType">The type of the error.</param>
825
public QuickbaseError(string code, string message, string description, QuickbaseErrorType quickbaseErrorType)
926
{
1027
Code = code;
@@ -13,24 +30,64 @@ public QuickbaseError(string code, string message, string description, Quickbase
1330
Type = quickbaseErrorType;
1431
}
1532

33+
/// <summary>
34+
/// Gets the error code.
35+
/// </summary>
1636
public string Code { get; private set; }
1737

38+
/// <summary>
39+
/// Gets the error message.
40+
/// </summary>
1841
public string Message { get; private set; }
1942

43+
/// <summary>
44+
/// Gets the error description.
45+
/// </summary>
2046
public string Description { get; private set; }
2147

48+
/// <summary>
49+
/// Gets the type of the error.
50+
/// </summary>
2251
public QuickbaseErrorType Type { get; private set; }
2352

53+
/// <summary>
54+
/// Creates a new QuickbaseError representing a not found error.
55+
/// </summary>
56+
/// <param name="code">The error code.</param>
57+
/// <param name="message">The error message.</param>
58+
/// <param name="description">The error description.</param>
59+
/// <returns>A QuickbaseError representing a not found error.</returns>
2460
public static QuickbaseError NotFound(string code, string message, string description) =>
2561
new QuickbaseError(code, message, description, QuickbaseErrorType.NotFound);
2662

63+
/// <summary>
64+
/// Creates a new QuickbaseError representing a failure error.
65+
/// </summary>
66+
/// <param name="code">The error code.</param>
67+
/// <param name="message">The error message.</param>
68+
/// <param name="description">The error description.</param>
69+
/// <returns>A QuickbaseError representing a failure error.</returns>
2770
public static QuickbaseError Failure(string code, string message, string description) =>
2871
new QuickbaseError(code, message, description, QuickbaseErrorType.Failure);
2972

73+
/// <summary>
74+
/// Creates a new QuickbaseError representing a client error.
75+
/// </summary>
76+
/// <param name="code">The error code.</param>
77+
/// <param name="message">The error message.</param>
78+
/// <param name="description">The error description.</param>
79+
/// <returns>A QuickbaseError representing a client error.</returns>
3080
public static QuickbaseError ClientError(string code, string message, string description) =>
3181
new QuickbaseError(code, message, description, QuickbaseErrorType.ClientError);
3282

83+
/// <summary>
84+
/// Creates a new QuickbaseError representing a server error.
85+
/// </summary>
86+
/// <param name="code">The error code.</param>
87+
/// <param name="message">The error message.</param>
88+
/// <param name="description">The error description.</param>
89+
/// <returns>A QuickbaseError representing a server error.</returns>
3390
public static QuickbaseError ServerError(string code, string message, string description) =>
3491
new QuickbaseError(code, message, description, QuickbaseErrorType.ServerError);
3592
}
36-
}
93+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
namespace QuickbaseNet.Errors
22
{
3+
/// <summary>
4+
/// Represents the type of QuickBase API error.
5+
/// </summary>
36
public enum QuickbaseErrorType
47
{
8+
/// <summary>
9+
/// Indicates a general failure error.
10+
/// </summary>
511
Failure = 0,
12+
13+
/// <summary>
14+
/// Indicates a not found error.
15+
/// </summary>
616
NotFound = 1,
17+
18+
/// <summary>
19+
/// Indicates a client error.
20+
/// </summary>
721
ClientError = 3,
22+
23+
/// <summary>
24+
/// Indicates a server error.
25+
/// </summary>
826
ServerError = 4
927
}
1028
}

QuickbaseNet/Helpers/QuickbaseCommandBuilder.cs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,43 @@
55

66
namespace QuickbaseNet.Helpers
77
{
8+
/// <summary>
9+
/// Helper class for building QuickBase API commands.
10+
/// </summary>
811
public class QuickbaseCommandBuilder
912
{
1013
private string _tableId;
1114
private string _whereClauseForDeletion;
1215
private readonly List<Dictionary<string, FieldValue>> _records = new List<Dictionary<string, FieldValue>>();
1316
private int[] _fieldsToReturn;
1417

18+
/// <summary>
19+
/// Specifies the table to operate on.
20+
/// </summary>
21+
/// <param name="tableId">The ID of the QuickBase table.</param>
22+
/// <returns>The current instance of QuickbaseCommandBuilder.</returns>
1523
public QuickbaseCommandBuilder ForTable(string tableId)
1624
{
1725
_tableId = tableId;
1826
return this;
1927
}
2028

29+
/// <summary>
30+
/// Specifies which fields to return after the operation.
31+
/// </summary>
32+
/// <param name="fieldIds">The IDs of the fields to return.</param>
33+
/// <returns>The current instance of QuickbaseCommandBuilder.</returns>
2134
public QuickbaseCommandBuilder ReturnFields(params int[] fieldIds)
2235
{
2336
_fieldsToReturn = fieldIds;
2437
return this;
2538
}
2639

40+
/// <summary>
41+
/// Adds a new record to the command being built.
42+
/// </summary>
43+
/// <param name="config">Action to configure the new record.</param>
44+
/// <returns>The current instance of QuickbaseCommandBuilder.</returns>
2745
public QuickbaseCommandBuilder AddNewRecord(Action<RecordBuilder> config)
2846
{
2947
var recordBuilder = new RecordBuilder();
@@ -32,23 +50,38 @@ public QuickbaseCommandBuilder AddNewRecord(Action<RecordBuilder> config)
3250
return this;
3351
}
3452

53+
/// <summary>
54+
/// Updates an existing record in the command being built.
55+
/// </summary>
56+
/// <param name="recordId">The ID of the record to update.</param>
57+
/// <param name="config">Action to configure the updated record.</param>
58+
/// <returns>The current instance of QuickbaseCommandBuilder.</returns>
3559
public QuickbaseCommandBuilder UpdateRecord(int recordId, Action<RecordBuilder> config)
3660
{
3761
var recordBuilder = new RecordBuilder();
3862
config(recordBuilder);
3963

4064
// Assuming '3' is the default key field ID for record ID
41-
recordBuilder.AddField("3", recordId.ToString());
65+
recordBuilder.AddField(3, recordId.ToString());
4266
_records.Add(recordBuilder.Build());
4367
return this;
4468
}
4569

70+
/// <summary>
71+
/// Specifies deletion criteria for records.
72+
/// </summary>
73+
/// <param name="whereClause">The deletion criteria.</param>
74+
/// <returns>The current instance of QuickbaseCommandBuilder.</returns>
4675
public QuickbaseCommandBuilder WithDeletionCriteria(string whereClause)
4776
{
4877
_whereClauseForDeletion = whereClause;
4978
return this;
5079
}
5180

81+
/// <summary>
82+
/// Builds an insert or update command.
83+
/// </summary>
84+
/// <returns>An InsertOrUpdateRecordRequest object representing the command.</returns>
5285
public InsertOrUpdateRecordRequest BuildInsertUpdateCommand()
5386
{
5487
return new InsertOrUpdateRecordRequest
@@ -59,6 +92,10 @@ public InsertOrUpdateRecordRequest BuildInsertUpdateCommand()
5992
};
6093
}
6194

95+
/// <summary>
96+
/// Builds a delete command.
97+
/// </summary>
98+
/// <returns>A DeleteRecordRequest object representing the command.</returns>
6299
public DeleteRecordRequest BuildDeleteCommand()
63100
{
64101
return new DeleteRecordRequest
@@ -68,16 +105,30 @@ public DeleteRecordRequest BuildDeleteCommand()
68105
};
69106
}
70107

108+
/// <summary>
109+
/// Builder class for constructing record objects.
110+
/// </summary>
71111
public class RecordBuilder
72112
{
73113
private readonly Dictionary<string, FieldValue> _fields = new Dictionary<string, FieldValue>();
74114

115+
/// <summary>
116+
/// Adds a field to the record being built.
117+
/// </summary>
118+
/// <typeparam name="T">The type of the field value.</typeparam>
119+
/// <param name="fieldId">The ID of the field.</param>
120+
/// <param name="value">The value of the field.</param>
121+
/// <returns>The current instance of RecordBuilder.</returns>
75122
public RecordBuilder AddField<T>(int fieldId, T value)
76123
{
77-
_fields[fieldId.ToString()] = new FieldValue { Value = value };
124+
_fields[fieldId.ToString()] = new FieldValue { Value = value };
78125
return this;
79126
}
80127

128+
/// <summary>
129+
/// Builds the record.
130+
/// </summary>
131+
/// <returns>A dictionary representing the record.</returns>
81132
public Dictionary<string, FieldValue> Build()
82133
{
83134
return _fields;

QuickbaseNet/Helpers/QuickbaseQueryBuilder.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace QuickbaseNet.Helpers
77
{
8+
/// <summary>
9+
/// Helper class for building QuickBase API queries.
10+
/// </summary>
811
public class QuickbaseQueryBuilder
912
{
1013
private string _from;
@@ -13,24 +16,45 @@ public class QuickbaseQueryBuilder
1316
private List<SortByItem> _sortBy;
1417
private List<GroupByItem> _groupBy;
1518

19+
/// <summary>
20+
/// Specifies the table to query.
21+
/// </summary>
22+
/// <param name="from">The ID or name of the QuickBase table.</param>
23+
/// <returns>The current instance of QuickbaseQueryBuilder.</returns>
1624
public QuickbaseQueryBuilder From(string from)
1725
{
1826
_from = from;
1927
return this;
2028
}
2129

30+
/// <summary>
31+
/// Specifies which fields to select in the query result.
32+
/// </summary>
33+
/// <param name="fields">The IDs of the fields to select.</param>
34+
/// <returns>The current instance of QuickbaseQueryBuilder.</returns>
2235
public QuickbaseQueryBuilder Select(params int[] fields)
2336
{
2437
_select = fields.ToList();
2538
return this;
2639
}
2740

41+
/// <summary>
42+
/// Specifies the WHERE clause of the query.
43+
/// </summary>
44+
/// <param name="where">The WHERE clause.</param>
45+
/// <returns>The current instance of QuickbaseQueryBuilder.</returns>
2846
public QuickbaseQueryBuilder Where(string where)
2947
{
3048
_where = where;
3149
return this;
3250
}
3351

52+
/// <summary>
53+
/// Specifies the fields to sort the query result by.
54+
/// </summary>
55+
/// <param name="fieldId">The ID of the field to sort by.</param>
56+
/// <param name="order">The sorting order ("ASC" for ascending, "DESC" for descending).</param>
57+
/// <returns>The current instance of QuickbaseQueryBuilder.</returns>
3458
public QuickbaseQueryBuilder SortBy(int fieldId, string order)
3559
{
3660
if (_sortBy == null)
@@ -40,6 +64,12 @@ public QuickbaseQueryBuilder SortBy(int fieldId, string order)
4064
return this;
4165
}
4266

67+
/// <summary>
68+
/// Specifies the fields to group the query result by.
69+
/// </summary>
70+
/// <param name="fieldId">The ID of the field to group by.</param>
71+
/// <param name="grouping">The grouping criteria.</param>
72+
/// <returns>The current instance of QuickbaseQueryBuilder.</returns>
4373
public QuickbaseQueryBuilder GroupBy(int fieldId, string grouping)
4474
{
4575
if (_groupBy == null)
@@ -49,6 +79,10 @@ public QuickbaseQueryBuilder GroupBy(int fieldId, string grouping)
4979
return this;
5080
}
5181

82+
/// <summary>
83+
/// Builds the query.
84+
/// </summary>
85+
/// <returns>A QuickbaseQueryRequest object representing the query.</returns>
5286
public QuickbaseQueryRequest Build()
5387
{
5488
return new QuickbaseQueryRequest
@@ -61,4 +95,4 @@ public QuickbaseQueryRequest Build()
6195
};
6296
}
6397
}
64-
}
98+
}

QuickbaseNet/Models/Field.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22

33
namespace QuickbaseNet.Models
44
{
5+
/// <summary>
6+
/// Represents a field in a QuickBase table.
7+
/// </summary>
58
public class Field
69
{
10+
/// <summary>
11+
/// Gets or sets the ID of the field.
12+
/// </summary>
713
[JsonProperty("id")]
814
public int Id { get; set; }
15+
16+
/// <summary>
17+
/// Gets or sets the label of the field.
18+
/// </summary>
919
[JsonProperty("label")]
1020
public string Label { get; set; }
21+
22+
/// <summary>
23+
/// Gets or sets the type of the field.
24+
/// </summary>
1125
[JsonProperty("type")]
1226
public string Type { get; set; }
1327
}

QuickbaseNet/Models/FieldValue.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,22 @@
33

44
namespace QuickbaseNet.Models
55
{
6+
/// <summary>
7+
/// Represents a value of a field in a QuickBase record.
8+
/// </summary>
69
public class FieldValue
710
{
11+
/// <summary>
12+
/// Gets or sets the value of the field.
13+
/// </summary>
814
[JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)]
915
public object Value { get; set; }
1016

17+
/// <summary>
18+
/// Gets the strongly-typed value of the field.
19+
/// </summary>
20+
/// <typeparam name="T">The type to convert the value to.</typeparam>
21+
/// <returns>The strongly-typed value of the field.</returns>
1122
public T GetValue<T>()
1223
{
1324
return Value == null ? default : (T)Convert.ChangeType(Value, typeof(T));

0 commit comments

Comments
 (0)