From de2ab62262bdc4c8f36df61d73af9158e3b42e6a Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Sat, 10 Dec 2022 22:31:51 -0600 Subject: [PATCH 001/168] fix: Modifed the FieldsController.cs for the test server to not return a field test data based on concrete classes and enums from the sdk itself. Instead the fields returned are generic objects that represent a field data set you'd get back from the api. This way I can add additional fields to the dataset that demonstrate the FormulaOutputType enum contains incorrect values for date and number. --- .../Controllers/FieldsController.cs | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs b/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs index 9e1c9ac..f546ca8 100644 --- a/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs +++ b/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs @@ -24,7 +24,7 @@ public IActionResult GetById(int fieldId) [HttpPost("batch-get")] public IActionResult GetBatchById([FromBody, MinLength(1)] int[] fieldIds) { - var getFieldsResponse = new GetFieldsResponse + var getFieldsResponse = new { Items = GetTestFields() }; @@ -38,7 +38,7 @@ public IActionResult GetByAppId(int appId, [FromQuery] PagingRequest pagingReque pagingRequest ??= new PagingRequest(); var items = GetTestFields(); - var getResponse = new GetPagedFieldsResponse + var getResponse = new { Items = items.Take(pagingRequest.PageSize).ToList(), PageNumber = pagingRequest.PageNumber, @@ -49,33 +49,33 @@ public IActionResult GetByAppId(int appId, [FromQuery] PagingRequest pagingReque return Ok(getResponse); } - private static List GetTestFields() + private static List GetTestFields() { - return new List + return new List { - new Field + new { AppId = 1, Id = 1, IsRequired = true, IsUnique = true, Name = "Regular field", - Status = Enums.FieldStatus.Enabled, - Type = Enums.FieldType.Text, + Status = "Enabled", + Type = "Text", }, - new ListField + new { AppId = 1, Id = 1, IsRequired = true, IsUnique = false, Name = "List field", - Status = Enums.FieldStatus.Enabled, - Type = Enums.FieldType.List, - Multiplicity = Enums.Multiplicity.MultiSelect, - Values = new List + Status = "Enabled", + Type = "List", + Multiplicity = "MultiSelect", + Values = new List { - new ListValue + new { Color = "#ffffff", Id = Guid.NewGuid(), @@ -83,7 +83,7 @@ private static List GetTestFields() NumericValue = 1m, SortOrder = 1, }, - new ListValue + new { Color = "#ffffff", Id = Guid.NewGuid(), @@ -93,38 +93,38 @@ private static List GetTestFields() }, }, }, - new FormulaField + new { AppId = 1, Id = 1, IsRequired = true, IsUnique = false, Name = "List field", - Status = Enums.FieldStatus.Enabled, - Type = Enums.FieldType.Formula, - OutputType = Enums.FormulaOutputType.Date, - Values = new List + Status = "Enabled", + Type = "Formula", + OutputType = "List", + Values = new List { - new ListValue + new { Color = "#ffffff", Id = Guid.NewGuid(), - Name = "First Formula", + Name = "List Value", NumericValue = 1m, SortOrder = 1, }, }, }, - new ReferenceField + new { AppId = 1, Id = 1, IsRequired = true, IsUnique = false, Name = "List field", - Status = Enums.FieldStatus.Enabled, - Type = Enums.FieldType.Reference, - Multiplicity = Enums.Multiplicity.SingleSelect, + Status = "Enabled", + Type = "Reference", + Multiplicity = "SingleSelect", } }; } From a3d2687f435d6c14b95e8615333b20cd70ea4755 Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Sat, 10 Dec 2022 22:40:19 -0600 Subject: [PATCH 002/168] fix: Added objects to the field data set returned by the FieldsController.cs that include a formula field with each possible output type. These additional fields cause by the GetFieldsAsync and GetFieldsForAppAsync tests in OnspringClientFieldTests to fail because the OutputType values of Numeric and DateAndTime can't be deserialized to any of the existing FormulaOutputType enum values. --- .../Controllers/FieldsController.cs | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs b/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs index f546ca8..139b8d7 100644 --- a/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs +++ b/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs @@ -1,10 +1,13 @@ using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; using Onspring.API.SDK.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Xml.Linq; namespace Onspring.API.SDK.Tests.TestServer.Controllers { @@ -97,9 +100,9 @@ private static List GetTestFields() { AppId = 1, Id = 1, - IsRequired = true, + IsRequired = false, IsUnique = false, - Name = "List field", + Name = "List Formula Field", Status = "Enabled", Type = "Formula", OutputType = "List", @@ -116,6 +119,42 @@ private static List GetTestFields() }, }, new + { + AppId = 1, + Id = 1, + IsRequired = false, + IsUnique = false, + Name = "Date/Time Formula Field", + Status = "Enabled", + Type = "Formula", + OutputType = "DateAndTime", + Values = new List(), + }, + new + { + AppId = 1, + Id = 1, + IsRequired = false, + IsUnique = false, + Name = "Numeric Formula Field", + Status = "Enabled", + Type = "Formula", + OutputType = "Numeric", + Values = new List(), + }, + new + { + AppId = 1, + Id = 1, + IsRequired = false, + IsUnique = false, + Name = "Text Formula Field", + Status = "Enabled", + Type = "Formula", + OutputType = "Text", + Values = new List(), + }, + new { AppId = 1, Id = 1, From c344a662bccfcc5dbe8d215b6337625d14dc00e6 Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Sat, 10 Dec 2022 22:44:12 -0600 Subject: [PATCH 003/168] fix: Changed named value Date in FormulaOutputType enum to DateAndTime which is the actual value that the Onspring API will return for formula fields with their output type configured as date/time. --- Onspring.API.SDK/Enums/FormulaOutputType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK/Enums/FormulaOutputType.cs b/Onspring.API.SDK/Enums/FormulaOutputType.cs index b7e77b6..cefb978 100644 --- a/Onspring.API.SDK/Enums/FormulaOutputType.cs +++ b/Onspring.API.SDK/Enums/FormulaOutputType.cs @@ -12,7 +12,7 @@ public enum FormulaOutputType { Text = 0, Number = 1, - Date = 2, + DateAndTime = 2, List = 3, } } \ No newline at end of file From a9a60c083ecdf92ccfae8566830758918db132b8 Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Sat, 10 Dec 2022 22:46:53 -0600 Subject: [PATCH 004/168] fix: Changed named value Number in FormulaOutputType enum to Numeric which is the actual value that the Onspring API will return for formula fields with their output type configured as numeric. NOTE: All tests now passing again. --- Onspring.API.SDK/Enums/FormulaOutputType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK/Enums/FormulaOutputType.cs b/Onspring.API.SDK/Enums/FormulaOutputType.cs index cefb978..95fed52 100644 --- a/Onspring.API.SDK/Enums/FormulaOutputType.cs +++ b/Onspring.API.SDK/Enums/FormulaOutputType.cs @@ -11,7 +11,7 @@ namespace Onspring.API.SDK.Enums public enum FormulaOutputType { Text = 0, - Number = 1, + Numeric = 1, DateAndTime = 2, List = 3, } From 008bf864dd05d5711e78ab0ebae742c3ca384c89 Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Sun, 15 Jan 2023 02:03:08 -0600 Subject: [PATCH 005/168] fix: modified FormulaOutputType List enum to have proper name ListValue. fix: modified response data in test controller to respond with proper OutputType value for list formula field. --- .../TestServer/Controllers/FieldsController.cs | 7 ++----- Onspring.API.SDK/Enums/FormulaOutputType.cs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs b/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs index 139b8d7..394c95f 100644 --- a/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs +++ b/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs @@ -1,17 +1,14 @@ using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json; using Onspring.API.SDK.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Xml.Linq; namespace Onspring.API.SDK.Tests.TestServer.Controllers { - [ApiController, Route("[controller]")] + [ApiController, Route("[controller]")] [ExcludeFromCodeCoverage] [SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Just a test controller. Not an API that gets shipped.")] [SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "Just a test controller. Not an API that gets shipped.")] @@ -105,7 +102,7 @@ private static List GetTestFields() Name = "List Formula Field", Status = "Enabled", Type = "Formula", - OutputType = "List", + OutputType = "ListValue", Values = new List { new diff --git a/Onspring.API.SDK/Enums/FormulaOutputType.cs b/Onspring.API.SDK/Enums/FormulaOutputType.cs index 95fed52..2f408f3 100644 --- a/Onspring.API.SDK/Enums/FormulaOutputType.cs +++ b/Onspring.API.SDK/Enums/FormulaOutputType.cs @@ -13,6 +13,6 @@ public enum FormulaOutputType Text = 0, Numeric = 1, DateAndTime = 2, - List = 3, + ListValue = 3, } } \ No newline at end of file From f9e7e607a80aae24ee239769a9c61ad1caba43fb Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Sun, 15 Jan 2023 02:18:29 -0600 Subject: [PATCH 006/168] feat: added ReferencedAppId property to ReferenceField class --- Onspring.API.SDK/Models/ReferenceField.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK/Models/ReferenceField.cs b/Onspring.API.SDK/Models/ReferenceField.cs index 72d776b..1e8c74d 100644 --- a/Onspring.API.SDK/Models/ReferenceField.cs +++ b/Onspring.API.SDK/Models/ReferenceField.cs @@ -13,5 +13,6 @@ namespace Onspring.API.SDK.Models public class ReferenceField: Field { public Multiplicity Multiplicity { get; set; } + public int ReferencedAppId { get; set; } } } \ No newline at end of file From 97e6e7392968bea408a05f58944012b43aef8b5c Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Tue, 17 Jan 2023 00:25:05 -0600 Subject: [PATCH 007/168] fix: add SurveyDelegation to FieldType enum --- Onspring.API.SDK/Enums/FieldType.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK/Enums/FieldType.cs b/Onspring.API.SDK/Enums/FieldType.cs index bd9d443..82c8e07 100644 --- a/Onspring.API.SDK/Enums/FieldType.cs +++ b/Onspring.API.SDK/Enums/FieldType.cs @@ -21,6 +21,7 @@ public enum FieldType SurveyGroupScoring = 600, SurveyCampaign = 601, SurveyUnifiedAnswer = 602, + SurveyDelegation = 603, Attachment = 800, Image = 801, Formula = 900, From 3fc3c0a9a986af8bf7bf4f2ab79f411363bb3243 Mon Sep 17 00:00:00 2001 From: StevanFreeborn Date: Tue, 17 Jan 2023 00:28:43 -0600 Subject: [PATCH 008/168] fix: added support for survey delegation field. fix: added field to test FieldsController to verify deserializing works for survey delegation field --- .../TestServer/Controllers/FieldsController.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs b/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs index 394c95f..88666c2 100644 --- a/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs +++ b/Onspring.API.SDK.Tests/TestServer/Controllers/FieldsController.cs @@ -161,6 +161,17 @@ private static List GetTestFields() Status = "Enabled", Type = "Reference", Multiplicity = "SingleSelect", + }, + new + { + AppId = 1, + Id = 1, + IsRequired = false, + IsUnique = false, + Name = "Delegation", + Status = "Enabled", + Type = "SurveyDelegation", + Multiplicity = "SingleSelect", } }; } From fe9ab65654421f99004afa2abac64e1aeb684cb1 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:59:18 -0500 Subject: [PATCH 009/168] chore: upgrade test project to target dotnet 7 and upgraded package references to latest versions --- .../Onspring.API.SDK.Tests.csproj | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index 59477c5..5cc9914 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -1,7 +1,7 @@  - net5.0 + net7 false @@ -11,13 +11,13 @@ - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -26,19 +26,19 @@ - + - - Always - - - Always - - - Always - + + Always + + + Always + + + Always + From 8566db9b5ecc422d57ad78adeb68944b73311359 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:10:18 -0500 Subject: [PATCH 010/168] feat: add OnspringRequest model --- Onspring.API.SDK/Models/OnspringRequest.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Onspring.API.SDK/Models/OnspringRequest.cs diff --git a/Onspring.API.SDK/Models/OnspringRequest.cs b/Onspring.API.SDK/Models/OnspringRequest.cs new file mode 100644 index 0000000..e4518b6 --- /dev/null +++ b/Onspring.API.SDK/Models/OnspringRequest.cs @@ -0,0 +1,11 @@ +namespace Onspring.API.SDK.Models +{ + public class OnspringRequest + { + private readonly IOnspringClient _client; + internal OnspringRequest(IOnspringClient client) + { + _client = client; + } + } +} \ No newline at end of file From 00096af9e7369c12a6c99d5ab3194899db72f020 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:11:04 -0500 Subject: [PATCH 011/168] feat: add method to OnspringClient that allows constructing an instance of an OnspringRequest --- Onspring.API.SDK/OnspringClient.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index e9c3a8f..8220c73 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -71,6 +71,17 @@ public OnspringClient(OnspringClientConfiguration clientConfig) HttpClient = HttpClientFactory.GetHttpClient(clientConfig.BaseAddress); } + // ------------------------------------ Fluent Interface ------------------------------------ + + /// + /// Creates a new instance of the class, which provides a fluent interface for building a request to the Onspring API. + /// + /// A new instance. + public OnspringRequest CreateRequest() + { + return new OnspringRequest(this); + } + // ------------------------------------ Diagnostic ------------------------------------ #region Diagnostic From 1b6959acafb735e6909d04e5233d45c8d22a3efb Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:12:19 -0500 Subject: [PATCH 012/168] test: add test to verify create request method returns an OnspringRequest --- .../Tests/OnspringClientFluentTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs new file mode 100644 index 0000000..032c2f5 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs @@ -0,0 +1,18 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Tests.Tests +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringClientFluentTests + { + [TestMethod] + public void CreateRequest_WhenCalled_ItShouldReturnAnInstanceOfAnOnspringRequest() + { + var client = new OnspringClient("https://api.onspring.com", "apiKey"); + var request = client.CreateRequest(); + Assert.IsInstanceOfType(request, typeof(OnspringRequest)); + } + } +} \ No newline at end of file From 3c38cc4dfead4c61d4e376a49ec55e6be33258f3 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:13:47 -0500 Subject: [PATCH 013/168] chore: stub out tests for OnspringRequest model --- Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs new file mode 100644 index 0000000..62187ec --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs @@ -0,0 +1,10 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Onspring.API.SDK.Tests.Tests +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringRequestTests + { + } +} \ No newline at end of file From 157f3a183d77e779847e4b3712340f25fd919b0a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:23:29 -0500 Subject: [PATCH 014/168] refactor: move OnspringRequest under fluent namespace --- Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs | 2 +- Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs | 1 + Onspring.API.SDK/Models/{ => Fluent}/OnspringRequest.cs | 2 +- Onspring.API.SDK/OnspringClient.cs | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) rename Onspring.API.SDK/Models/{ => Fluent}/OnspringRequest.cs (77%) diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs index 032c2f5..4b0f279 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs +++ b/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests { diff --git a/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs index 62187ec..87e662d 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Tests.Tests { diff --git a/Onspring.API.SDK/Models/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs similarity index 77% rename from Onspring.API.SDK/Models/OnspringRequest.cs rename to Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index e4518b6..fcf8bf9 100644 --- a/Onspring.API.SDK/Models/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -1,4 +1,4 @@ -namespace Onspring.API.SDK.Models +namespace Onspring.API.SDK.Models.Fluent { public class OnspringRequest { diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index 8220c73..5ac42c8 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -3,6 +3,7 @@ using Onspring.API.SDK.Helpers; using Onspring.API.SDK.Http; using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; using Onspring.API.SDK.Validation; using System; using System.Collections.Generic; From 1dcfb18d79b6559f6237bf7f93652d99257b9b57 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:00:37 -0500 Subject: [PATCH 015/168] chore: add generate editorcongfig --- .editorconfig | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2d85cea --- /dev/null +++ b/.editorconfig @@ -0,0 +1,230 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = false + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_operators = false +csharp_style_expression_bodied_properties = true + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true +csharp_style_prefer_readonly_struct_member = true + +# Code-block preferences +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true +csharp_style_namespace_declarations = block_scoped +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_primary_constructors = true +csharp_style_prefer_top_level_statements = true + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case From 96d577920c7598bf93c13f835e3c1a7b3fe5488a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:02:20 -0500 Subject: [PATCH 016/168] style: fix spacing --- .../Tests/OnspringClientFluentTests.cs | 18 +++++++++--------- .../Tests/OnspringRequestTests.cs | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs index 4b0f279..ce7b0b5 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs +++ b/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs @@ -4,15 +4,15 @@ namespace Onspring.API.SDK.Tests.Tests { - [TestClass, ExcludeFromCodeCoverage] - public class OnspringClientFluentTests - { - [TestMethod] - public void CreateRequest_WhenCalled_ItShouldReturnAnInstanceOfAnOnspringRequest() + [TestClass, ExcludeFromCodeCoverage] + public class OnspringClientFluentTests { - var client = new OnspringClient("https://api.onspring.com", "apiKey"); - var request = client.CreateRequest(); - Assert.IsInstanceOfType(request, typeof(OnspringRequest)); + [TestMethod] + public void CreateRequest_WhenCalled_ItShouldReturnAnInstanceOfAnOnspringRequest() + { + var client = new OnspringClient("https://api.onspring.com", "apiKey"); + var request = client.CreateRequest(); + Assert.IsInstanceOfType(request, typeof(OnspringRequest)); + } } - } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs index 87e662d..1e7d6ca 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs @@ -4,8 +4,8 @@ namespace Onspring.API.SDK.Tests.Tests { - [TestClass, ExcludeFromCodeCoverage] - public class OnspringRequestTests - { - } + [TestClass, ExcludeFromCodeCoverage] + public class OnspringRequestTests + { + } } \ No newline at end of file From 7c0dcffdb6c003a4c10a0a19e9156db9f2433b52 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:47:11 -0500 Subject: [PATCH 017/168] feat: add fluent interface for getting records from an app --- .../Fluent/OnspringClientRecordsTests.cs | 46 +++++++++++++++ .../Tests/OnspringClientFluentTests.cs | 18 ------ .../Tests/OnspringClientTests.cs | 9 +++ .../Tests/OnspringRequestTests.cs | 11 ---- .../Fluent/IGetRecordsByAppRequestBuilder.cs | 14 +++++ .../Fluent/IGetRecordsRequestBuilder.cs | 7 +++ .../Interfaces/Fluent/IOnspringRequest.cs | 7 +++ .../Fluent/GetRecordsByAppRequestBuilder.cs | 59 +++++++++++++++++++ .../Models/Fluent/GetRecordsRequestBuilder.cs | 18 ++++++ .../Models/Fluent/OnspringRequest.cs | 19 ++++-- Onspring.API.SDK/OnspringClient.cs | 3 +- 11 files changed, 175 insertions(+), 36 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs delete mode 100644 Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs delete mode 100644 Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs new file mode 100644 index 0000000..667e99a --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs @@ -0,0 +1,46 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Tests.Infrastructure; +using Onspring.API.SDK.Tests.Infrastructure.Helpers; +using Onspring.API.SDK.Tests.Infrastructure.Http; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Threading.Tasks; + +namespace Onspring.API.SDK.Tests.Tests.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringClientRecordsTests + { + private const int _appIdWithRecords = 1; + private const int _fieldId = 1; + + private static OnspringClient _apiClient; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var testConfiguration = TestConfiguration.LoadFromContext(testContext); + var httpClient = HttpClientFactory.GetHttpClient(testConfiguration); + + _apiClient = new OnspringClient(testConfiguration.ApiKey, httpClient); + } + + [TestMethod] + public async Task GetRecordsByApp() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords) + .ForPage(1) + .WithPageSize(50) + .WithFieldIds(new[] { 1, 2, 3 }) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs deleted file mode 100644 index ce7b0b5..0000000 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientFluentTests.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Onspring.API.SDK.Models.Fluent; - -namespace Onspring.API.SDK.Tests.Tests -{ - [TestClass, ExcludeFromCodeCoverage] - public class OnspringClientFluentTests - { - [TestMethod] - public void CreateRequest_WhenCalled_ItShouldReturnAnInstanceOfAnOnspringRequest() - { - var client = new OnspringClient("https://api.onspring.com", "apiKey"); - var request = client.CreateRequest(); - Assert.IsInstanceOfType(request, typeof(OnspringRequest)); - } - } -} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringClientTests.cs index 4ef17d4..c0fed3f 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/OnspringClientTests.cs @@ -1,4 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models.Fluent; using Onspring.API.SDK.Tests.Infrastructure; using System; using System.Diagnostics.CodeAnalysis; @@ -100,5 +101,13 @@ public void InvalidConstructor_HttpClient_NoBaseAddress() { var _ = new OnspringClient(_testConfiguration.ApiKey, new HttpClient()); } + + [TestMethod] + public void CreateRequest_WhenCalled_ItShouldReturnAnInstanceOfAnOnspringRequest() + { + var client = new OnspringClient(_testConfiguration.ApiKey, new HttpClient { BaseAddress = new Uri(_testConfiguration.BaseAddress) }); + var request = client.CreateRequest(); + Assert.IsInstanceOfType(request, typeof(OnspringRequest)); + } } } diff --git a/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs deleted file mode 100644 index 1e7d6ca..0000000 --- a/Onspring.API.SDK.Tests/Tests/OnspringRequestTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Onspring.API.SDK.Models; - -namespace Onspring.API.SDK.Tests.Tests -{ - [TestClass, ExcludeFromCodeCoverage] - public class OnspringRequestTests - { - } -} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs new file mode 100644 index 0000000..1c0522c --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetRecordsByAppRequestBuilder + { + Task> SendAsync(); + IGetRecordsByAppRequestBuilder ForPage(int pageNumber); + IGetRecordsByAppRequestBuilder WithPageSize(int pageSize); + IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs new file mode 100644 index 0000000..355ad78 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetRecordsRequestBuilder + { + IGetRecordsByAppRequestBuilder FromApp(int appId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs new file mode 100644 index 0000000..60d44da --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IOnspringRequest + { + IGetRecordsRequestBuilder ToGetRecords(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs new file mode 100644 index 0000000..627cf97 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetRecordsByAppRequestBuilder : IGetRecordsByAppRequestBuilder + { + private readonly IOnspringClient _client; + private readonly int _appId; + private IEnumerable _fieldIds = Enumerable.Empty(); + private DataFormat _dataFormat = DataFormat.Raw; + private int _pageNumber = 1; + private int _pageSize = 50; + + internal GetRecordsByAppRequestBuilder(IOnspringClient client, int appId) + { + _client = client; + _appId = appId; + } + + public IGetRecordsByAppRequestBuilder ForPage(int pageNumber) + { + _pageNumber = pageNumber; + return this; + } + + public IGetRecordsByAppRequestBuilder WithPageSize(int pageSize) + { + _pageSize = pageSize; + return this; + } + + public IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds) + { + _fieldIds = fieldIds; + return this; + } + + async public Task> SendAsync() + { + return await _client.GetRecordsForAppAsync( + new GetRecordsByAppRequest + { + AppId = _appId, + FieldIds = _fieldIds.ToList(), + DataFormat = _dataFormat, + PagingRequest = new PagingRequest + { + PageNumber = _pageNumber, + PageSize = _pageSize + } + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs new file mode 100644 index 0000000..ccfde6c --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs @@ -0,0 +1,18 @@ +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetRecordsRequestBuilder : IGetRecordsRequestBuilder + { + private readonly IOnspringClient _client; + internal GetRecordsRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetRecordsByAppRequestBuilder FromApp(int appId) + { + return new GetRecordsByAppRequestBuilder(_client, appId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index fcf8bf9..baba6f7 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -1,11 +1,18 @@ +using Onspring.API.SDK.Interfaces.Fluent; + namespace Onspring.API.SDK.Models.Fluent { - public class OnspringRequest - { - private readonly IOnspringClient _client; - internal OnspringRequest(IOnspringClient client) + public class OnspringRequest : IOnspringRequest { - _client = client; + private readonly IOnspringClient _client; + internal OnspringRequest(IOnspringClient client) + { + _client = client; + } + + public IGetRecordsRequestBuilder ToGetRecords() + { + return new GetRecordsRequestBuilder(_client); + } } - } } \ No newline at end of file diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index 5ac42c8..6143dda 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -2,6 +2,7 @@ using Onspring.API.SDK.Extensions; using Onspring.API.SDK.Helpers; using Onspring.API.SDK.Http; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; using Onspring.API.SDK.Validation; @@ -78,7 +79,7 @@ public OnspringClient(OnspringClientConfiguration clientConfig) /// Creates a new instance of the class, which provides a fluent interface for building a request to the Onspring API. /// /// A new instance. - public OnspringRequest CreateRequest() + public IOnspringRequest CreateRequest() { return new OnspringRequest(this); } From 3713821a4c6ad880c46705c6122a426537cbac67 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:28:05 -0500 Subject: [PATCH 018/168] fix: add missing WithFormat method. feat: add overload for SendAsync method --- .../Fluent/OnspringClientRecordsTests.cs | 24 ++++++++++--- .../Fluent/IGetRecordsByAppRequestBuilder.cs | 5 +++ .../Interfaces/Fluent/IOnspringRequest.cs | 4 +++ .../Fluent/GetRecordsByAppRequestBuilder.cs | 34 +++++++++++++++++++ .../Models/Fluent/OnspringRequest.cs | 2 ++ 5 files changed, 65 insertions(+), 4 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs index 667e99a..5dc392b 100644 --- a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs @@ -1,12 +1,9 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using Onspring.API.SDK.Models; +using Onspring.API.SDK.Enums; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; -using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Fluent @@ -38,9 +35,28 @@ public async Task GetRecordsByApp() .ForPage(1) .WithPageSize(50) .WithFieldIds(new[] { 1, 2, 3 }) + .WithFormat(DataFormat.Formatted) .SendAsync(); AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task GetRecordsByApp_WithOptions() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords) + .SendAsync(opts => + { + opts.PageNumber = 50; + opts.PageSize = 50; + opts.DataFormat = DataFormat.Formatted; + opts.FieldIds = new[] { 1, 2, 3 }; + }); + + AssertHelper.AssertSuccess(apiResponse); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs index 1c0522c..1c3cc76 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs @@ -1,14 +1,19 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; +using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; +using static Onspring.API.SDK.Models.Fluent.GetRecordsByAppRequestBuilder; namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetRecordsByAppRequestBuilder { Task> SendAsync(); + Task> SendAsync(Action options); IGetRecordsByAppRequestBuilder ForPage(int pageNumber); IGetRecordsByAppRequestBuilder WithPageSize(int pageSize); IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds); + IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index 60d44da..3ff89e9 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -1,3 +1,7 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + namespace Onspring.API.SDK.Interfaces.Fluent { public interface IOnspringRequest diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs index 627cf97..0f96db8 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -39,6 +40,12 @@ public IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds) return this; } + public IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat) + { + _dataFormat = dataFormat; + return this; + } + async public Task> SendAsync() { return await _client.GetRecordsForAppAsync( @@ -55,5 +62,32 @@ async public Task> SendAsync() } ); } + + async public Task> SendAsync(Action options) + { + var opts = new GetRecordsByAppRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetRecordsForAppAsync( + new GetRecordsByAppRequest + { + AppId = _appId, + FieldIds = opts.FieldIds.ToList(), + DataFormat = opts.DataFormat, + PagingRequest = new PagingRequest + { + PageNumber = opts.PageNumber, + PageSize = opts.PageSize, + } + } + ); + } + + public class GetRecordsByAppRequestBuilderOptions + { + public IEnumerable FieldIds = Enumerable.Empty(); + public DataFormat DataFormat = DataFormat.Raw; + public int PageNumber { get; set; } = 1; + public int PageSize = 50; + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index baba6f7..2bc8a3a 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -1,3 +1,5 @@ +using System; +using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent From d63cf916616b5df7c0ad81e77ed4ad4f7856cfc1 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 16:02:55 -0500 Subject: [PATCH 019/168] fix: remove other builder models --- .../Fluent/IGetRecordsByAppRequestBuilder.cs | 2 +- .../Fluent/GetRecordsByAppRequestBuilder.cs | 93 ------------------- .../GetRecordsByAppRequestBuilderOptions.cs | 14 +++ .../Models/Fluent/GetRecordsRequestBuilder.cs | 18 ---- .../Models/Fluent/OnspringRequest.cs | 86 ++++++++++++++++- 5 files changed, 99 insertions(+), 114 deletions(-) delete mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs delete mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs index 1c3cc76..21715db 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; -using static Onspring.API.SDK.Models.Fluent.GetRecordsByAppRequestBuilder; +using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs deleted file mode 100644 index 0f96db8..0000000 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Interfaces.Fluent; - -namespace Onspring.API.SDK.Models.Fluent -{ - public class GetRecordsByAppRequestBuilder : IGetRecordsByAppRequestBuilder - { - private readonly IOnspringClient _client; - private readonly int _appId; - private IEnumerable _fieldIds = Enumerable.Empty(); - private DataFormat _dataFormat = DataFormat.Raw; - private int _pageNumber = 1; - private int _pageSize = 50; - - internal GetRecordsByAppRequestBuilder(IOnspringClient client, int appId) - { - _client = client; - _appId = appId; - } - - public IGetRecordsByAppRequestBuilder ForPage(int pageNumber) - { - _pageNumber = pageNumber; - return this; - } - - public IGetRecordsByAppRequestBuilder WithPageSize(int pageSize) - { - _pageSize = pageSize; - return this; - } - - public IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds) - { - _fieldIds = fieldIds; - return this; - } - - public IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat) - { - _dataFormat = dataFormat; - return this; - } - - async public Task> SendAsync() - { - return await _client.GetRecordsForAppAsync( - new GetRecordsByAppRequest - { - AppId = _appId, - FieldIds = _fieldIds.ToList(), - DataFormat = _dataFormat, - PagingRequest = new PagingRequest - { - PageNumber = _pageNumber, - PageSize = _pageSize - } - } - ); - } - - async public Task> SendAsync(Action options) - { - var opts = new GetRecordsByAppRequestBuilderOptions(); - options.Invoke(opts); - return await _client.GetRecordsForAppAsync( - new GetRecordsByAppRequest - { - AppId = _appId, - FieldIds = opts.FieldIds.ToList(), - DataFormat = opts.DataFormat, - PagingRequest = new PagingRequest - { - PageNumber = opts.PageNumber, - PageSize = opts.PageSize, - } - } - ); - } - - public class GetRecordsByAppRequestBuilderOptions - { - public IEnumerable FieldIds = Enumerable.Empty(); - public DataFormat DataFormat = DataFormat.Raw; - public int PageNumber { get; set; } = 1; - public int PageSize = 50; - } - } -} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs new file mode 100644 index 0000000..6909bbf --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Linq; +using Onspring.API.SDK.Enums; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetRecordsByAppRequestBuilderOptions + { + public IEnumerable FieldIds = Enumerable.Empty(); + public DataFormat DataFormat = DataFormat.Raw; + public int PageNumber { get; set; } = 1; + public int PageSize = 50; + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs deleted file mode 100644 index ccfde6c..0000000 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Onspring.API.SDK.Interfaces.Fluent; - -namespace Onspring.API.SDK.Models.Fluent -{ - public class GetRecordsRequestBuilder : IGetRecordsRequestBuilder - { - private readonly IOnspringClient _client; - internal GetRecordsRequestBuilder(IOnspringClient client) - { - _client = client; - } - - public IGetRecordsByAppRequestBuilder FromApp(int appId) - { - return new GetRecordsByAppRequestBuilder(_client, appId); - } - } -} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 2bc8a3a..2e9debf 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -1,20 +1,102 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; +using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { - public class OnspringRequest : IOnspringRequest + public class OnspringRequest : + IOnspringRequest, + IGetRecordsRequestBuilder, + IGetRecordsByAppRequestBuilder { private readonly IOnspringClient _client; + private int _appId; + private IEnumerable _fieldIds = Enumerable.Empty(); + private DataFormat _dataFormat = DataFormat.Raw; + private int _pageNumber = 1; + private int _pageSize = 50; + internal OnspringRequest(IOnspringClient client) { _client = client; } + #region records + public IGetRecordsRequestBuilder ToGetRecords() { - return new GetRecordsRequestBuilder(_client); + return this; + } + + public IGetRecordsByAppRequestBuilder FromApp(int appId) + { + _appId = appId; + return this; + } + + public IGetRecordsByAppRequestBuilder ForPage(int pageNumber) + { + _pageNumber = pageNumber; + return this; + } + + public IGetRecordsByAppRequestBuilder WithPageSize(int pageSize) + { + _pageSize = pageSize; + return this; + } + + public IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds) + { + _fieldIds = fieldIds; + return this; + } + + public IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat) + { + _dataFormat = dataFormat; + return this; + } + + async public Task> SendAsync() + { + return await _client.GetRecordsForAppAsync( + new GetRecordsByAppRequest + { + AppId = _appId, + FieldIds = _fieldIds.ToList(), + DataFormat = _dataFormat, + PagingRequest = new PagingRequest + { + PageNumber = _pageNumber, + PageSize = _pageSize + } + } + ); + } + + async public Task> SendAsync(Action options) + { + var opts = new GetRecordsByAppRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetRecordsForAppAsync( + new GetRecordsByAppRequest + { + AppId = _appId, + FieldIds = opts.FieldIds.ToList(), + DataFormat = opts.DataFormat, + PagingRequest = new PagingRequest + { + PageNumber = opts.PageNumber, + PageSize = opts.PageSize, + } + } + ); } + + #endregion } } \ No newline at end of file From ba496f179e552fe14312b00cc8d807f98b1ffc50 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:02:45 -0500 Subject: [PATCH 020/168] feat: add fluent interface for getting a record by id --- .../Fluent/OnspringClientRecordsTests.cs | 31 ++++++- .../Fluent/IGetRecordByIdRequestBuilder.cs | 17 ++++ .../Fluent/IGetRecordsByAppRequestBuilder.cs | 1 + .../Fluent/GetRecordByIdRequestBuilder.cs | 65 ++++++++++++++ .../GetRecordByIdRequestBuilderOptions.cs | 12 +++ .../Fluent/GetRecordsByAppRequestBuilder.cs | 90 +++++++++++++++++++ .../GetRecordsByAppRequestBuilderOptions.cs | 6 +- .../Models/Fluent/GetRecordsRequestBuilder.cs | 18 ++++ .../Models/Fluent/OnspringRequest.cs | 86 +----------------- 9 files changed, 238 insertions(+), 88 deletions(-) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs index 5dc392b..fafd301 100644 --- a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs @@ -1,3 +1,4 @@ +using Microsoft.VisualBasic; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Tests.Infrastructure; @@ -42,7 +43,7 @@ public async Task GetRecordsByApp() } [TestMethod] - public async Task GetRecordsByApp_WithOptions() + public async Task GetRecordsByApp_UsingOptions() { var apiResponse = await _apiClient .CreateRequest() @@ -58,5 +59,33 @@ public async Task GetRecordsByApp_WithOptions() AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task GetRecordById() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords) + .WithId(1) + .WithFieldIds(new[] { 1, 2, 3 }) + .WithFormat(DataFormat.Formatted) + .SendAsync(); + } + + [TestMethod] + public async Task GetRecordById_UsingOptions() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords) + .WithId(1) + .SendAsync(options => + { + options.FieldIds = new[] { 1, 2, 3 }; + options.DataFormat = DataFormat.Formatted; + }); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs new file mode 100644 index 0000000..1cb2174 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetRecordByIdRequestBuilder + { + Task> SendAsync(); + Task> SendAsync(Action options); + IGetRecordByIdRequestBuilder WithFieldIds(IEnumerable fieldIds); + IGetRecordByIdRequestBuilder WithFormat(DataFormat dataFormat); + } +} diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs index 21715db..7602b8c 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs @@ -15,5 +15,6 @@ public interface IGetRecordsByAppRequestBuilder IGetRecordsByAppRequestBuilder WithPageSize(int pageSize); IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds); IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat); + IGetRecordByIdRequestBuilder WithId(int recordId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs new file mode 100644 index 0000000..368cf88 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetRecordByIdRequestBuilder : IGetRecordByIdRequestBuilder + { + private readonly IOnspringClient _client; + private readonly int _appId; + private readonly int _recordId; + private IEnumerable _fieldIds = Enumerable.Empty(); + private DataFormat _dataFormat = DataFormat.Raw; + + public GetRecordByIdRequestBuilder(IOnspringClient client, int appId, int recordId) + { + _client = client; + _appId = appId; + _recordId = recordId; + } + + public IGetRecordByIdRequestBuilder WithFieldIds(IEnumerable fieldIds) + { + _fieldIds = fieldIds; + return this; + } + + public IGetRecordByIdRequestBuilder WithFormat(DataFormat dataFormat) + { + _dataFormat = dataFormat; + return this; + } + + async public Task> SendAsync() + { + return await _client.GetRecordAsync( + new GetRecordRequest + { + AppId = _appId, + RecordId = _recordId, + FieldIds = _fieldIds.ToList(), + DataFormat = _dataFormat, + } + ); + } + + async public Task> SendAsync(Action options) + { + var opts = new GetRecordByIdRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetRecordAsync( + new GetRecordRequest + { + AppId = _appId, + RecordId = _recordId, + FieldIds = opts.FieldIds.ToList(), + DataFormat = opts.DataFormat, + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs new file mode 100644 index 0000000..12c5289 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Linq; +using Onspring.API.SDK.Enums; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetRecordByIdRequestBuilderOptions + { + public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + public DataFormat DataFormat { get; set; } = DataFormat.Raw; + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs new file mode 100644 index 0000000..fd4c985 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public partial class GetRecordsByAppRequestBuilder : IGetRecordsByAppRequestBuilder + { + private readonly IOnspringClient _client; + private readonly int _appId; + private IEnumerable _fieldIds = Enumerable.Empty(); + private DataFormat _dataFormat = DataFormat.Raw; + private int _pageNumber = 1; + private int _pageSize = 50; + + internal GetRecordsByAppRequestBuilder(IOnspringClient client, int appId) + { + _client = client; + _appId = appId; + } + + public IGetRecordsByAppRequestBuilder ForPage(int pageNumber) + { + _pageNumber = pageNumber; + return this; + } + + public IGetRecordsByAppRequestBuilder WithPageSize(int pageSize) + { + _pageSize = pageSize; + return this; + } + + public IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds) + { + _fieldIds = fieldIds; + return this; + } + + public IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat) + { + _dataFormat = dataFormat; + return this; + } + + public IGetRecordByIdRequestBuilder WithId(int recordId) + { + return new GetRecordByIdRequestBuilder(_client, _appId, recordId); + } + + async public Task> SendAsync() + { + return await _client.GetRecordsForAppAsync( + new GetRecordsByAppRequest + { + AppId = _appId, + FieldIds = _fieldIds.ToList(), + DataFormat = _dataFormat, + PagingRequest = new PagingRequest + { + PageNumber = _pageNumber, + PageSize = _pageSize + } + } + ); + } + + async public Task> SendAsync(Action options) + { + var opts = new GetRecordsByAppRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetRecordsForAppAsync( + new GetRecordsByAppRequest + { + AppId = _appId, + FieldIds = opts.FieldIds.ToList(), + DataFormat = opts.DataFormat, + PagingRequest = new PagingRequest + { + PageNumber = opts.PageNumber, + PageSize = opts.PageSize, + } + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs index 6909bbf..03af7a6 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs @@ -6,9 +6,9 @@ namespace Onspring.API.SDK.Models.Fluent { public class GetRecordsByAppRequestBuilderOptions { - public IEnumerable FieldIds = Enumerable.Empty(); - public DataFormat DataFormat = DataFormat.Raw; + public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + public DataFormat DataFormat { get; set; } = DataFormat.Raw; public int PageNumber { get; set; } = 1; - public int PageSize = 50; + public int PageSize { get; set; } = 50; } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs new file mode 100644 index 0000000..ccfde6c --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs @@ -0,0 +1,18 @@ +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetRecordsRequestBuilder : IGetRecordsRequestBuilder + { + private readonly IOnspringClient _client; + internal GetRecordsRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetRecordsByAppRequestBuilder FromApp(int appId) + { + return new GetRecordsByAppRequestBuilder(_client, appId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 2e9debf..2bc8a3a 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -1,102 +1,20 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; -using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { - public class OnspringRequest : - IOnspringRequest, - IGetRecordsRequestBuilder, - IGetRecordsByAppRequestBuilder + public class OnspringRequest : IOnspringRequest { private readonly IOnspringClient _client; - private int _appId; - private IEnumerable _fieldIds = Enumerable.Empty(); - private DataFormat _dataFormat = DataFormat.Raw; - private int _pageNumber = 1; - private int _pageSize = 50; - internal OnspringRequest(IOnspringClient client) { _client = client; } - #region records - public IGetRecordsRequestBuilder ToGetRecords() { - return this; - } - - public IGetRecordsByAppRequestBuilder FromApp(int appId) - { - _appId = appId; - return this; - } - - public IGetRecordsByAppRequestBuilder ForPage(int pageNumber) - { - _pageNumber = pageNumber; - return this; - } - - public IGetRecordsByAppRequestBuilder WithPageSize(int pageSize) - { - _pageSize = pageSize; - return this; - } - - public IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds) - { - _fieldIds = fieldIds; - return this; - } - - public IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat) - { - _dataFormat = dataFormat; - return this; - } - - async public Task> SendAsync() - { - return await _client.GetRecordsForAppAsync( - new GetRecordsByAppRequest - { - AppId = _appId, - FieldIds = _fieldIds.ToList(), - DataFormat = _dataFormat, - PagingRequest = new PagingRequest - { - PageNumber = _pageNumber, - PageSize = _pageSize - } - } - ); - } - - async public Task> SendAsync(Action options) - { - var opts = new GetRecordsByAppRequestBuilderOptions(); - options.Invoke(opts); - return await _client.GetRecordsForAppAsync( - new GetRecordsByAppRequest - { - AppId = _appId, - FieldIds = opts.FieldIds.ToList(), - DataFormat = opts.DataFormat, - PagingRequest = new PagingRequest - { - PageNumber = opts.PageNumber, - PageSize = opts.PageSize, - } - } - ); + return new GetRecordsRequestBuilder(_client); } - - #endregion } } \ No newline at end of file From 99dd51925c2655266c69feb1bc7397a56e80fdca Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:07:30 -0500 Subject: [PATCH 021/168] chore: remove unused usings --- Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs | 4 ---- Onspring.API.SDK/Models/Fluent/OnspringRequest.cs | 2 -- 2 files changed, 6 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index 3ff89e9..60d44da 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -1,7 +1,3 @@ -using System; -using System.Threading.Tasks; -using Onspring.API.SDK.Models; - namespace Onspring.API.SDK.Interfaces.Fluent { public interface IOnspringRequest diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 2bc8a3a..baba6f7 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -1,5 +1,3 @@ -using System; -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent From 067ef492e4772c8eb085f82f140969d777f1df3e Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 15 Sep 2023 08:35:38 -0500 Subject: [PATCH 022/168] style: fix spacing --- Onspring.API.SDK/Models/Fluent/OnspringRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index baba6f7..fcdaf9c 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -5,6 +5,7 @@ namespace Onspring.API.SDK.Models.Fluent public class OnspringRequest : IOnspringRequest { private readonly IOnspringClient _client; + internal OnspringRequest(IOnspringClient client) { _client = client; From de53a0165bc7c787d73abdbe75beeb99af5c030d Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:50:24 -0500 Subject: [PATCH 023/168] chore: add .vscode settings and extensions --- .vscode/extensions.json | 10 ++++++++++ .vscode/settings.json | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..6b35d50 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "ms-dotnettools.csdevkit", + "formulahendry.dotnet-test-explorer", + "EditorConfig.EditorConfig", + "oderwat.indent-rainbow", + "aliasadidev.nugetpackagemanagergui", + "github.vscode-github-actions" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bdf1da0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet-test-explorer.testArguments": "--settings runsettings/internal.runsettings" +} From e1ea831287d5ad9b712651c2e85ff4352167d946 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:02:41 -0500 Subject: [PATCH 024/168] feat: add fluent interface for getting records by ids --- .vscode/settings.json | 3 +- .../Fluent/OnspringClientRecordsTests.cs | 54 +++++++++++++-- .../Fluent/IGetRecordsByAppRequestBuilder.cs | 1 + .../Fluent/IGetRecordsByIdsRequestBuilder.cs | 17 +++++ .../Fluent/GetRecordsByAppRequestBuilder.cs | 5 ++ .../Fluent/GetRecordsByIdsRequestBuilder.cs | 65 +++++++++++++++++++ .../GetRecordsByIdsRequestBuilderOptions.cs | 12 ++++ 7 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilderOptions.cs diff --git a/.vscode/settings.json b/.vscode/settings.json index bdf1da0..70fd490 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "dotnet-test-explorer.testArguments": "--settings runsettings/internal.runsettings" + "dotnet-test-explorer.testArguments": "--settings runsettings/internal.runsettings", + "omnisharp.testRunSettings": "C:\\Users\\sfree\\software_projects\\onspring-api-sdk\\Onspring.API.SDK.Tests\\bin\\Debug\\net7\\runsettings\\internal.runsettings" } diff --git a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs index fafd301..3510077 100644 --- a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs @@ -1,6 +1,6 @@ -using Microsoft.VisualBasic; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; @@ -29,35 +29,39 @@ public static void ClassInit(TestContext testContext) [TestMethod] public async Task GetRecordsByApp() { + var pagingRequest = new PagingRequest(1, 10); var apiResponse = await _apiClient .CreateRequest() .ToGetRecords() .FromApp(_appIdWithRecords) - .ForPage(1) - .WithPageSize(50) + .ForPage(pagingRequest.PageNumber) + .WithPageSize(pagingRequest.PageSize) .WithFieldIds(new[] { 1, 2, 3 }) .WithFormat(DataFormat.Formatted) .SendAsync(); AssertHelper.AssertSuccess(apiResponse); + AssertHelper.AssertCasting(apiResponse.Value.Items); } [TestMethod] public async Task GetRecordsByApp_UsingOptions() { + var pagingRequest = new PagingRequest(1, 10); var apiResponse = await _apiClient .CreateRequest() .ToGetRecords() .FromApp(_appIdWithRecords) .SendAsync(opts => { - opts.PageNumber = 50; - opts.PageSize = 50; + opts.PageNumber = pagingRequest.PageNumber; + opts.PageSize = pagingRequest.PageSize; opts.DataFormat = DataFormat.Formatted; opts.FieldIds = new[] { 1, 2, 3 }; }); AssertHelper.AssertSuccess(apiResponse); + AssertHelper.AssertCasting(apiResponse.Value.Items); } [TestMethod] @@ -71,6 +75,9 @@ public async Task GetRecordById() .WithFieldIds(new[] { 1, 2, 3 }) .WithFormat(DataFormat.Formatted) .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + AssertHelper.AssertCasting(apiResponse.Value); } [TestMethod] @@ -86,6 +93,43 @@ public async Task GetRecordById_UsingOptions() options.FieldIds = new[] { 1, 2, 3 }; options.DataFormat = DataFormat.Formatted; }); + + AssertHelper.AssertSuccess(apiResponse); + AssertHelper.AssertCasting(apiResponse.Value); + } + + [TestMethod] + public async Task GetRecordsByIds() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords) + .WithIds(new[] { 1, 2, 3 }) + .WithFieldIds(new[] { 1, 2, 3 }) + .WithFormat(DataFormat.Formatted) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + AssertHelper.AssertCasting(apiResponse.Value.Items); + } + + [TestMethod] + public async Task GetRecordsByIds_UsingOptions() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords) + .WithIds(new[] { 1, 2, 3 }) + .SendAsync(options => + { + options.DataFormat = DataFormat.Formatted; + options.FieldIds = new[] { 1, 2, 3 }; + }); + + AssertHelper.AssertSuccess(apiResponse); + AssertHelper.AssertCasting(apiResponse.Value.Items); } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs index 7602b8c..7e2042f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs @@ -16,5 +16,6 @@ public interface IGetRecordsByAppRequestBuilder IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds); IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat); IGetRecordByIdRequestBuilder WithId(int recordId); + IGetRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs new file mode 100644 index 0000000..7d3a66e --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetRecordsByIdsRequestBuilder + { + Task> SendAsync(); + Task> SendAsync(Action options); + IGetRecordsByIdsRequestBuilder WithFieldIds(IEnumerable fieldIds); + IGetRecordsByIdsRequestBuilder WithFormat(DataFormat dataFormat); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs index fd4c985..4234718 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs @@ -51,6 +51,11 @@ public IGetRecordByIdRequestBuilder WithId(int recordId) return new GetRecordByIdRequestBuilder(_client, _appId, recordId); } + public IGetRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds) + { + return new GetRecordsByIdsRequestBuilder(_client, _appId, recordIds); + } + async public Task> SendAsync() { return await _client.GetRecordsForAppAsync( diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs new file mode 100644 index 0000000..8146563 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetRecordsByIdsRequestBuilder : IGetRecordsByIdsRequestBuilder + { + private readonly IOnspringClient _client; + private readonly int _appId; + private readonly IEnumerable _recordIds; + private IEnumerable _fieldIds = Enumerable.Empty(); + private DataFormat _dataFormat = DataFormat.Raw; + + public GetRecordsByIdsRequestBuilder(IOnspringClient client, int appId, IEnumerable recordIds) + { + _client = client; + _appId = appId; + _recordIds = recordIds; + } + + public IGetRecordsByIdsRequestBuilder WithFieldIds(IEnumerable fieldIds) + { + _fieldIds = fieldIds; + return this; + } + + public IGetRecordsByIdsRequestBuilder WithFormat(DataFormat dataFormat) + { + _dataFormat = dataFormat; + return this; + } + + async public Task> SendAsync() + { + return await _client.GetRecordsAsync( + new GetRecordsRequest + { + AppId = _appId, + RecordIds = _recordIds.ToList(), + FieldIds = _fieldIds.ToList(), + DataFormat = _dataFormat, + } + ); + } + + async public Task> SendAsync(Action options) + { + var opts = new GetRecordsByIdsRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetRecordsAsync( + new GetRecordsRequest + { + AppId = _appId, + RecordIds = _recordIds.ToList(), + FieldIds = opts.FieldIds.ToList(), + DataFormat = opts.DataFormat, + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilderOptions.cs new file mode 100644 index 0000000..03aac97 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilderOptions.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Linq; +using Onspring.API.SDK.Enums; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetRecordsByIdsRequestBuilderOptions + { + public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + public DataFormat DataFormat { get; set; } = DataFormat.Raw; + } +} \ No newline at end of file From 78558ca47b1f6fed5a0139543fe21d61513621c1 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:31:48 -0500 Subject: [PATCH 025/168] tests: moved tests into integration namespace --- .../Fluent/OnspringClientRecordsTests.cs | 19 ++++++++++++++----- .../OnspringClientAppsTests.cs | 2 +- .../OnspringClientConfigurationTests.cs | 2 +- .../OnspringClientDiagnosticTests.cs | 2 +- .../OnspringClientFieldTests.cs | 2 +- .../OnspringClientFilesTests.cs | 2 +- .../OnspringClientListsTests.cs | 2 +- .../OnspringClientRecordsTests.cs | 3 +-- .../OnspringClientReportsTests.cs | 2 +- .../{ => Integration}/OnspringClientTests.cs | 2 +- 10 files changed, 23 insertions(+), 15 deletions(-) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/Fluent/OnspringClientRecordsTests.cs (87%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientAppsTests.cs (95%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientConfigurationTests.cs (93%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientDiagnosticTests.cs (92%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientFieldTests.cs (94%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientFilesTests.cs (95%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientListsTests.cs (95%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientRecordsTests.cs (96%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientReportsTests.cs (93%) rename Onspring.API.SDK.Tests/Tests/{ => Integration}/OnspringClientTests.cs (96%) diff --git a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs similarity index 87% rename from Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs index 3510077..d9929ef 100644 --- a/Onspring.API.SDK.Tests/Tests/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs @@ -7,7 +7,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; -namespace Onspring.API.SDK.Tests.Tests.Fluent +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientRecordsTests @@ -52,11 +52,11 @@ public async Task GetRecordsByApp_UsingOptions() .CreateRequest() .ToGetRecords() .FromApp(_appIdWithRecords) + .ForPage(1) .SendAsync(opts => { - opts.PageNumber = pagingRequest.PageNumber; opts.PageSize = pagingRequest.PageSize; - opts.DataFormat = DataFormat.Formatted; + opts.Format = DataFormat.Formatted; opts.FieldIds = new[] { 1, 2, 3 }; }); @@ -91,7 +91,7 @@ public async Task GetRecordById_UsingOptions() .SendAsync(options => { options.FieldIds = new[] { 1, 2, 3 }; - options.DataFormat = DataFormat.Formatted; + options.Format = DataFormat.Formatted; }); AssertHelper.AssertSuccess(apiResponse); @@ -124,12 +124,21 @@ public async Task GetRecordsByIds_UsingOptions() .WithIds(new[] { 1, 2, 3 }) .SendAsync(options => { - options.DataFormat = DataFormat.Formatted; + options.Format = DataFormat.Formatted; options.FieldIds = new[] { 1, 2, 3 }; }); AssertHelper.AssertSuccess(apiResponse); AssertHelper.AssertCasting(apiResponse.Value.Items); } + + [TestMethod] + public async Task QueryRecords() + { + var apiResponse = _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs similarity index 95% rename from Onspring.API.SDK.Tests/Tests/OnspringClientAppsTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs index ecb9076..caac92d 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs @@ -7,7 +7,7 @@ using System.Net; using System.Threading.Tasks; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientAppsTests diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientConfigurationTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientConfigurationTests.cs similarity index 93% rename from Onspring.API.SDK.Tests/Tests/OnspringClientConfigurationTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientConfigurationTests.cs index 3450a59..21fdda0 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientConfigurationTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientConfigurationTests.cs @@ -2,7 +2,7 @@ using System; using System.Diagnostics.CodeAnalysis; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientConfigurationTests diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientDiagnosticTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientDiagnosticTests.cs similarity index 92% rename from Onspring.API.SDK.Tests/Tests/OnspringClientDiagnosticTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientDiagnosticTests.cs index e9ae9a0..f1ae1f4 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientDiagnosticTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientDiagnosticTests.cs @@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientDiagnosticTests diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientFieldTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs similarity index 94% rename from Onspring.API.SDK.Tests/Tests/OnspringClientFieldTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs index 82ef52b..8d118c7 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientFieldTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Threading.Tasks; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientFieldTests diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientFilesTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFilesTests.cs similarity index 95% rename from Onspring.API.SDK.Tests/Tests/OnspringClientFilesTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFilesTests.cs index 16e57f8..eeb3996 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientFilesTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFilesTests.cs @@ -8,7 +8,7 @@ using System.IO; using System.Threading.Tasks; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientFilesTests diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientListsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientListsTests.cs similarity index 95% rename from Onspring.API.SDK.Tests/Tests/OnspringClientListsTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientListsTests.cs index 8c61d61..dc5ec4c 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientListsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientListsTests.cs @@ -7,7 +7,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientListsTests diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs similarity index 96% rename from Onspring.API.SDK.Tests/Tests/OnspringClientRecordsTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs index 8a123cb..676fc7c 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs @@ -6,10 +6,9 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Threading.Tasks; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientRecordsTests diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs similarity index 93% rename from Onspring.API.SDK.Tests/Tests/OnspringClientReportsTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs index f0296b1..c488f4a 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs @@ -6,7 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientReportsTests diff --git a/Onspring.API.SDK.Tests/Tests/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs similarity index 96% rename from Onspring.API.SDK.Tests/Tests/OnspringClientTests.cs rename to Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs index c0fed3f..6524b8a 100644 --- a/Onspring.API.SDK.Tests/Tests/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs @@ -5,7 +5,7 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; -namespace Onspring.API.SDK.Tests.Tests +namespace Onspring.API.SDK.Tests.Tests.Integration { [TestClass, ExcludeFromCodeCoverage] public class OnspringClientTests From 0458c1f233b4085940187cc1bca3e64f6e50ff7f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:33:01 -0500 Subject: [PATCH 026/168] feat: add custom filter operator enum --- Onspring.API.SDK/Enums/FilterOperator.cs | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Onspring.API.SDK/Enums/FilterOperator.cs diff --git a/Onspring.API.SDK/Enums/FilterOperator.cs b/Onspring.API.SDK/Enums/FilterOperator.cs new file mode 100644 index 0000000..1d1523d --- /dev/null +++ b/Onspring.API.SDK/Enums/FilterOperator.cs @@ -0,0 +1,54 @@ +using System; + +namespace Onspring.API.SDK.Enums +{ + public abstract class Enumeration : IComparable + { + public string Name { get; private set; } + + public int Id { get; private set; } + + protected Enumeration(int id, string name) => (Id, Name) = (id, name); + + public override string ToString() => Name; + + public override bool Equals(object obj) + { + if (obj is Enumeration otherValue) + { + var typeMatches = GetType().Equals(obj.GetType()); + var valueMatches = Id.Equals(otherValue.Id); + + return typeMatches && valueMatches; + } + + return false; + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + public int CompareTo(object other) => Id.CompareTo(((Enumeration)other).Id); + } + + public class FilterOperator : Enumeration + { + public static FilterOperator Equal { get; } = new FilterOperator(1, "eq"); + public static FilterOperator NotEqual { get; } = new FilterOperator(2, "ne"); + public static FilterOperator Contains { get; } = new FilterOperator(3, "contains"); + public static FilterOperator IsNull { get; } = new FilterOperator(4, "isnull"); + public static FilterOperator NotNull { get; } = new FilterOperator(5, "notnull"); + public static FilterOperator GreaterThan { get; } = new FilterOperator(6, "gt"); + public static FilterOperator LessThan { get; } = new FilterOperator(7, "lt"); + public static FilterOperator And { get; } = new FilterOperator(8, "and"); + public static FilterOperator Or { get; } = new FilterOperator(9, "or"); + public static FilterOperator Not { get; } = new FilterOperator(10, "not"); + + private FilterOperator(int id, string name) : base(id, name) + { + } + } + +} \ No newline at end of file From 24df711ac2041e368757cb05c12855afd9c7a6f8 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:33:30 -0500 Subject: [PATCH 027/168] feat: add filter model --- Onspring.API.SDK/Models/Filter.cs | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Onspring.API.SDK/Models/Filter.cs diff --git a/Onspring.API.SDK/Models/Filter.cs b/Onspring.API.SDK/Models/Filter.cs new file mode 100644 index 0000000..6a7d2f7 --- /dev/null +++ b/Onspring.API.SDK/Models/Filter.cs @@ -0,0 +1,46 @@ +using System; +using Onspring.API.SDK.Enums; + +namespace Onspring.API.SDK.Models +{ + public class Filter + { + public int FieldId { get; private set; } + public FilterOperator Operator { get; private set; } + public object Value { get; private set; } + + internal Filter() { } + + public Filter(int fieldId, FilterOperator filterOperator, object value) + { + if (value == null && filterOperator != FilterOperator.IsNull && filterOperator != FilterOperator.NotNull) + { + throw new ArgumentException("Value cannot be null for this operator"); + } + + FieldId = fieldId; + Operator = filterOperator; + Value = value; + } + + public override string ToString() + { + if (Value == null) + { + return $"{FieldId} {Operator}"; + } + + if (Value is DateTime dateTime) + { + return $"{FieldId} {Operator} datetime'{dateTime:yyyy-MM-ddTHH:mm:ss.fff}'"; + } + + if (Value is string stringValue) + { + return $"{FieldId} {Operator} '{stringValue}'"; + } + + return $"{FieldId} {Operator} {Value}"; + } + } +} \ No newline at end of file From ffd42451e2fc169b3e1c78381dbe4d2d7cdad2dd Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:34:58 -0500 Subject: [PATCH 028/168] refactor: make interface force user to specific call path --- .../Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs index 7e2042f..1ecd6be 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs @@ -9,13 +9,10 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetRecordsByAppRequestBuilder { - Task> SendAsync(); - Task> SendAsync(Action options); - IGetRecordsByAppRequestBuilder ForPage(int pageNumber); - IGetRecordsByAppRequestBuilder WithPageSize(int pageSize); - IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds); - IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat); + IGetRecordsByAppPagedRequestBuilder ForPage(int pageNumber); IGetRecordByIdRequestBuilder WithId(int recordId); IGetRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds); + IQueryRecordsByAppPagedRequestBuilder WithFilter(string filter); + IQueryRecordsByAppPagedRequestBuilder WithFilter(Action filter); } } \ No newline at end of file From 6fa0e1fde6c5dda107b2d08c2bb23bc2e9078f3b Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:35:32 -0500 Subject: [PATCH 029/168] refactor: make private readonly fields public props with private setters --- .../Fluent/GetRecordByIdRequestBuilder.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs index 368cf88..d9e8d81 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs @@ -10,27 +10,27 @@ namespace Onspring.API.SDK.Models.Fluent public class GetRecordByIdRequestBuilder : IGetRecordByIdRequestBuilder { private readonly IOnspringClient _client; - private readonly int _appId; - private readonly int _recordId; - private IEnumerable _fieldIds = Enumerable.Empty(); - private DataFormat _dataFormat = DataFormat.Raw; + public int AppId { get; private set; } + public int RecordId { get; private set; } + public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); + public DataFormat Format { get; private set; } = DataFormat.Raw; - public GetRecordByIdRequestBuilder(IOnspringClient client, int appId, int recordId) + internal GetRecordByIdRequestBuilder(IOnspringClient client, int appId, int recordId) { _client = client; - _appId = appId; - _recordId = recordId; + AppId = appId; + RecordId = recordId; } public IGetRecordByIdRequestBuilder WithFieldIds(IEnumerable fieldIds) { - _fieldIds = fieldIds; + FieldIds = fieldIds; return this; } public IGetRecordByIdRequestBuilder WithFormat(DataFormat dataFormat) { - _dataFormat = dataFormat; + Format = dataFormat; return this; } @@ -39,10 +39,10 @@ async public Task> SendAsync() return await _client.GetRecordAsync( new GetRecordRequest { - AppId = _appId, - RecordId = _recordId, - FieldIds = _fieldIds.ToList(), - DataFormat = _dataFormat, + AppId = AppId, + RecordId = RecordId, + FieldIds = FieldIds.ToList(), + DataFormat = Format, } ); } @@ -54,10 +54,10 @@ async public Task> SendAsync(Action Date: Sun, 17 Sep 2023 21:35:53 -0500 Subject: [PATCH 030/168] refactor: rename format property --- .../Models/Fluent/GetRecordByIdRequestBuilderOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs index 12c5289..2b97cd5 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs @@ -7,6 +7,6 @@ namespace Onspring.API.SDK.Models.Fluent public class GetRecordByIdRequestBuilderOptions { public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); - public DataFormat DataFormat { get; set; } = DataFormat.Raw; + public DataFormat Format { get; set; } = DataFormat.Raw; } } \ No newline at end of file From c934c03638c4b412fb49eb098bf58de6b41ca7f9 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:36:42 -0500 Subject: [PATCH 031/168] refactor: remove unnecessary properties from model --- .../IGetRecordsByAppPagedRequestBuilder.cs | 18 ++++ .../IQueryRecordsByAppPagedRequestBuilder.cs | 14 +++ .../GetRecordsByAppPagedRequestBuilder.cs | 80 +++++++++++++++++ ...RecordsByAppPagedRequestBuilderOptions.cs} | 5 +- .../Fluent/GetRecordsByAppRequestBuilder.cs | 76 +++------------- .../Fluent/GetRecordsByIdsRequestBuilder.cs | 32 +++---- .../GetRecordsByIdsRequestBuilderOptions.cs | 2 +- .../Models/Fluent/GetRecordsRequestBuilder.cs | 1 + .../QueryRecordsByAppPagedRequestBuilder.cs | 87 +++++++++++++++++++ ...yRecordsByAppPagedRequestBuilderOptions.cs | 14 +++ 10 files changed, 246 insertions(+), 83 deletions(-) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilder.cs rename Onspring.API.SDK/Models/Fluent/{GetRecordsByAppRequestBuilderOptions.cs => GetRecordsByAppPagedRequestBuilderOptions.cs} (59%) create mode 100644 Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs new file mode 100644 index 0000000..0d47209 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetRecordsByAppPagedRequestBuilder + { + Task> SendAsync(); + Task> SendAsync(Action options); + IGetRecordsByAppPagedRequestBuilder WithPageSize(int pageSize); + IGetRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds); + IGetRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs new file mode 100644 index 0000000..dda5ced --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Onspring.API.SDK.Enums; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IQueryRecordsByAppPagedRequestBuilder + { + IQueryRecordsByAppPagedRequestBuilder ForPageNumber(int pageNumber); + IQueryRecordsByAppPagedRequestBuilder WithPageSize(int pageSize); + IQueryRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds); + IQueryRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat); + + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilder.cs new file mode 100644 index 0000000..7e35c94 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilder.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public partial class GetRecordsByAppPagedRequestBuilder : IGetRecordsByAppPagedRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + public int PageNumber { get; private set; } + public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); + public DataFormat Format { get; private set; } = DataFormat.Raw; + public int PageSize { get; private set; } = 50; + + internal GetRecordsByAppPagedRequestBuilder(IOnspringClient client, int appId, int pageNumber) + { + _client = client; + AppId = appId; + PageNumber = pageNumber; + } + + public IGetRecordsByAppPagedRequestBuilder WithPageSize(int pageSize) + { + PageSize = pageSize; + return this; + } + + public IGetRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds) + { + FieldIds = fieldIds; + return this; + } + + public IGetRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat) + { + Format = dataFormat; + return this; + } + + async public Task> SendAsync() + { + return await _client.GetRecordsForAppAsync( + new GetRecordsByAppRequest + { + AppId = AppId, + FieldIds = FieldIds.ToList(), + DataFormat = Format, + PagingRequest = new PagingRequest + { + PageNumber = PageNumber, + PageSize = PageSize + } + } + ); + } + + async public Task> SendAsync(Action options) + { + var opts = new GetRecordsByAppPagedRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetRecordsForAppAsync( + new GetRecordsByAppRequest + { + AppId = AppId, + FieldIds = opts.FieldIds.ToList(), + DataFormat = opts.Format, + PagingRequest = new PagingRequest + { + PageNumber = PageNumber, + PageSize = opts.PageSize, + } + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilderOptions.cs similarity index 59% rename from Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs rename to Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilderOptions.cs index 03af7a6..34412e2 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilderOptions.cs @@ -4,11 +4,10 @@ namespace Onspring.API.SDK.Models.Fluent { - public class GetRecordsByAppRequestBuilderOptions + public class GetRecordsByAppPagedRequestBuilderOptions { public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); - public DataFormat DataFormat { get; set; } = DataFormat.Raw; - public int PageNumber { get; set; } = 1; + public DataFormat Format { get; set; } = DataFormat.Raw; public int PageSize { get; set; } = 50; } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs index 4234718..99057b4 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs @@ -1,95 +1,45 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { - public partial class GetRecordsByAppRequestBuilder : IGetRecordsByAppRequestBuilder + public class GetRecordsByAppRequestBuilder : IGetRecordsByAppRequestBuilder { private readonly IOnspringClient _client; - private readonly int _appId; - private IEnumerable _fieldIds = Enumerable.Empty(); - private DataFormat _dataFormat = DataFormat.Raw; - private int _pageNumber = 1; - private int _pageSize = 50; + public int AppId { get; private set; } internal GetRecordsByAppRequestBuilder(IOnspringClient client, int appId) { _client = client; - _appId = appId; + AppId = appId; } - public IGetRecordsByAppRequestBuilder ForPage(int pageNumber) + public IGetRecordsByAppPagedRequestBuilder ForPage(int pageNumber) { - _pageNumber = pageNumber; - return this; - } - - public IGetRecordsByAppRequestBuilder WithPageSize(int pageSize) - { - _pageSize = pageSize; - return this; - } - - public IGetRecordsByAppRequestBuilder WithFieldIds(IEnumerable fieldIds) - { - _fieldIds = fieldIds; - return this; - } - - public IGetRecordsByAppRequestBuilder WithFormat(DataFormat dataFormat) - { - _dataFormat = dataFormat; - return this; + return new GetRecordsByAppPagedRequestBuilder(_client, AppId, pageNumber); } public IGetRecordByIdRequestBuilder WithId(int recordId) { - return new GetRecordByIdRequestBuilder(_client, _appId, recordId); + return new GetRecordByIdRequestBuilder(_client, AppId, recordId); } public IGetRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds) { - return new GetRecordsByIdsRequestBuilder(_client, _appId, recordIds); + return new GetRecordsByIdsRequestBuilder(_client, AppId, recordIds); } - async public Task> SendAsync() + public IQueryRecordsByAppPagedRequestBuilder WithFilter(string filter) { - return await _client.GetRecordsForAppAsync( - new GetRecordsByAppRequest - { - AppId = _appId, - FieldIds = _fieldIds.ToList(), - DataFormat = _dataFormat, - PagingRequest = new PagingRequest - { - PageNumber = _pageNumber, - PageSize = _pageSize - } - } - ); + return new QueryRecordsByAppPagedRequestBuilder(_client, AppId, filter); } - async public Task> SendAsync(Action options) + public IQueryRecordsByAppPagedRequestBuilder WithFilter(Action filter) { - var opts = new GetRecordsByAppRequestBuilderOptions(); - options.Invoke(opts); - return await _client.GetRecordsForAppAsync( - new GetRecordsByAppRequest - { - AppId = _appId, - FieldIds = opts.FieldIds.ToList(), - DataFormat = opts.DataFormat, - PagingRequest = new PagingRequest - { - PageNumber = opts.PageNumber, - PageSize = opts.PageSize, - } - } - ); + var queryFilter = new Filter(); + filter.Invoke(queryFilter); + return new QueryRecordsByAppPagedRequestBuilder(_client, AppId, queryFilter.ToString()); } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs index 8146563..486e720 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs @@ -10,27 +10,27 @@ namespace Onspring.API.SDK.Models.Fluent public class GetRecordsByIdsRequestBuilder : IGetRecordsByIdsRequestBuilder { private readonly IOnspringClient _client; - private readonly int _appId; - private readonly IEnumerable _recordIds; - private IEnumerable _fieldIds = Enumerable.Empty(); - private DataFormat _dataFormat = DataFormat.Raw; + public int AppId { get; private set; } + public IEnumerable RecordIds { get; private set; } + public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); + public DataFormat Format { get; private set; } = DataFormat.Raw; - public GetRecordsByIdsRequestBuilder(IOnspringClient client, int appId, IEnumerable recordIds) + internal GetRecordsByIdsRequestBuilder(IOnspringClient client, int appId, IEnumerable recordIds) { _client = client; - _appId = appId; - _recordIds = recordIds; + AppId = appId; + RecordIds = recordIds; } public IGetRecordsByIdsRequestBuilder WithFieldIds(IEnumerable fieldIds) { - _fieldIds = fieldIds; + FieldIds = fieldIds; return this; } public IGetRecordsByIdsRequestBuilder WithFormat(DataFormat dataFormat) { - _dataFormat = dataFormat; + Format = dataFormat; return this; } @@ -39,10 +39,10 @@ async public Task> SendAsync() return await _client.GetRecordsAsync( new GetRecordsRequest { - AppId = _appId, - RecordIds = _recordIds.ToList(), - FieldIds = _fieldIds.ToList(), - DataFormat = _dataFormat, + AppId = AppId, + RecordIds = RecordIds.ToList(), + FieldIds = FieldIds.ToList(), + DataFormat = Format, } ); } @@ -54,10 +54,10 @@ async public Task> SendAsync(Action FieldIds { get; set; } = Enumerable.Empty(); - public DataFormat DataFormat { get; set; } = DataFormat.Raw; + public DataFormat Format { get; set; } = DataFormat.Raw; } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs index ccfde6c..4e74e84 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs @@ -5,6 +5,7 @@ namespace Onspring.API.SDK.Models.Fluent public class GetRecordsRequestBuilder : IGetRecordsRequestBuilder { private readonly IOnspringClient _client; + internal GetRecordsRequestBuilder(IOnspringClient client) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilder.cs new file mode 100644 index 0000000..bb4e715 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilder.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class QueryRecordsByAppPagedRequestBuilder : IQueryRecordsByAppPagedRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + public string Filter { get; private set; } + public int PageNumber { get; private set; } = 1; + public int PageSize { get; private set; } = 50; + public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); + public DataFormat Format { get; private set; } = DataFormat.Raw; + + internal QueryRecordsByAppPagedRequestBuilder(IOnspringClient client, int appId, string filter) + { + _client = client; + AppId = appId; + Filter = filter; + } + + public IQueryRecordsByAppPagedRequestBuilder ForPageNumber(int pageNumber) + { + PageNumber = pageNumber; + return this; + } + + public IQueryRecordsByAppPagedRequestBuilder WithPageSize(int pageSize) + { + PageNumber = pageSize; + return this; + } + + public IQueryRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds) + { + FieldIds = fieldIds; + return this; + } + + public IQueryRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat) + { + Format = dataFormat; + return this; + } + + public async Task> SendAsync() + { + return await _client.QueryRecordsAsync( + new QueryRecordsRequest() + { + Filter = Filter, + FieldIds = FieldIds.ToList(), + DataFormat = Format, + }, + new PagingRequest() + { + PageNumber = PageNumber, + PageSize = PageSize + } + ); + } + + public async Task> SendAsync(Action options) + { + var opts = new QueryRecordsByAppPagedRequestBuilderOptions(); + options.Invoke(opts); + return await _client.QueryRecordsAsync( + new QueryRecordsRequest() + { + Filter = Filter, + FieldIds = opts.FieldIds.ToList(), + DataFormat = opts.Format, + }, + new PagingRequest() + { + PageNumber = opts.PageNumber, + PageSize = opts.PageSize + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs new file mode 100644 index 0000000..f11f9b1 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Linq; +using Onspring.API.SDK.Enums; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class QueryRecordsByAppPagedRequestBuilderOptions + { + public int PageNumber { get; private set; } = 1; + public int PageSize { get; private set; } = 50; + public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); + public DataFormat Format { get; private set; } = DataFormat.Raw; + } +} \ No newline at end of file From 3964899531beea066a7fd410251911e8e1812a38 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:54:03 -0500 Subject: [PATCH 032/168] tests: add tests for fluent interface to query records --- .../Fluent/OnspringClientRecordsTests.cs | 39 ++++++++++++++++++- .../IQueryRecordsByAppPagedRequestBuilder.cs | 6 +++ Onspring.API.SDK/Models/Filter.cs | 21 ++++++---- ...yRecordsByAppPagedRequestBuilderOptions.cs | 8 ++-- 4 files changed, 60 insertions(+), 14 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs index d9929ef..ab7b0b1 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Components.Forms; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; @@ -135,10 +136,44 @@ public async Task GetRecordsByIds_UsingOptions() [TestMethod] public async Task QueryRecords() { - var apiResponse = _apiClient + var apiResponse = await _apiClient .CreateRequest() .ToGetRecords() - .FromApp(_appIdWithRecords); + .FromApp(_appIdWithRecords) + .WithFilter($"{1} eq {1}") + .ForPageNumber(1) + .WithPageSize(50) + .WithFieldIds(new[] { 1, 2, 3 }) + .WithFormat(DataFormat.Formatted) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + AssertHelper.AssertCasting(apiResponse.Value.Items); + } + + [TestMethod] + public async Task QueryRecords_UsingOptions() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords) + .WithFilter(filter => + { + filter.FieldId = 1; + filter.Operator = FilterOperator.Equal; + filter.Value = 1; + }) + .SendAsync(options => + { + options.PageNumber = 1; + options.PageSize = 50; + options.FieldIds = new[] { 1, 2, 3 }; + options.Format = DataFormat.Formatted; + }); + + AssertHelper.AssertSuccess(apiResponse); + AssertHelper.AssertCasting(apiResponse.Value.Items); } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs index dda5ced..8d9de81 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs @@ -1,10 +1,16 @@ +using System; using System.Collections.Generic; +using System.Threading.Tasks; using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Interfaces.Fluent { public interface IQueryRecordsByAppPagedRequestBuilder { + Task> SendAsync(); + Task> SendAsync(Action options); IQueryRecordsByAppPagedRequestBuilder ForPageNumber(int pageNumber); IQueryRecordsByAppPagedRequestBuilder WithPageSize(int pageSize); IQueryRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds); diff --git a/Onspring.API.SDK/Models/Filter.cs b/Onspring.API.SDK/Models/Filter.cs index 6a7d2f7..247d0b9 100644 --- a/Onspring.API.SDK/Models/Filter.cs +++ b/Onspring.API.SDK/Models/Filter.cs @@ -5,19 +5,24 @@ namespace Onspring.API.SDK.Models { public class Filter { - public int FieldId { get; private set; } - public FilterOperator Operator { get; private set; } - public object Value { get; private set; } + public int FieldId { get; set; } + public FilterOperator Operator { get; set; } + public object Value + { + get { return Value; } + set + { + if (value == null && Operator != null && Operator != FilterOperator.IsNull && Operator != FilterOperator.NotNull) + { + throw new ArgumentException("Value cannot be null for this operator"); + } + } + } internal Filter() { } public Filter(int fieldId, FilterOperator filterOperator, object value) { - if (value == null && filterOperator != FilterOperator.IsNull && filterOperator != FilterOperator.NotNull) - { - throw new ArgumentException("Value cannot be null for this operator"); - } - FieldId = fieldId; Operator = filterOperator; Value = value; diff --git a/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs index f11f9b1..34b1917 100644 --- a/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs @@ -6,9 +6,9 @@ namespace Onspring.API.SDK.Models.Fluent { public class QueryRecordsByAppPagedRequestBuilderOptions { - public int PageNumber { get; private set; } = 1; - public int PageSize { get; private set; } = 50; - public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); - public DataFormat Format { get; private set; } = DataFormat.Raw; + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 50; + public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + public DataFormat Format { get; set; } = DataFormat.Raw; } } \ No newline at end of file From 878e1c0e1868da9defd3ff8a156ebe72f67ade03 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:58:12 -0500 Subject: [PATCH 033/168] fix: add private backing field --- Onspring.API.SDK/Models/Filter.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK/Models/Filter.cs b/Onspring.API.SDK/Models/Filter.cs index 247d0b9..45b488f 100644 --- a/Onspring.API.SDK/Models/Filter.cs +++ b/Onspring.API.SDK/Models/Filter.cs @@ -7,15 +7,20 @@ public class Filter { public int FieldId { get; set; } public FilterOperator Operator { get; set; } + + private object filterValue; + public object Value { - get { return Value; } + get { return filterValue; } set { if (value == null && Operator != null && Operator != FilterOperator.IsNull && Operator != FilterOperator.NotNull) { throw new ArgumentException("Value cannot be null for this operator"); } + + filterValue = value; } } From 8d4e9830d1ebad66c2c3c1520fc38989eec9a450 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:00:08 -0500 Subject: [PATCH 034/168] chore: add Nsubstitute as a dep for mocking --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index 5cc9914..b148e44 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -19,6 +19,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + From 3282bcdc2f761fde342de86dd0852728ab9d0235 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:01:24 -0500 Subject: [PATCH 035/168] chore: remove unused using --- .../Tests/Integration/Fluent/OnspringClientRecordsTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs index ab7b0b1..b418083 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs @@ -1,4 +1,3 @@ -using Microsoft.AspNetCore.Components.Forms; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; From 43a152efc6f91f211a035a4aef89023b5ed7b76b Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:26:52 -0500 Subject: [PATCH 036/168] tests: add unit tests for OnspringClient and OnspringRequest models --- .../Tests/Unit/Fluent/OnspringRequestTests.cs | 24 +++++++++++++++++++ .../Tests/Unit/OnspringClientTests.cs | 18 ++++++++++++++ Onspring.API.SDK/IOnspringClient.cs | 7 ++++++ .../Models/Fluent/OnspringRequest.cs | 2 ++ Onspring.API.SDK/OnspringClient.cs | 6 ++--- 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs new file mode 100644 index 0000000..a948df8 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs @@ -0,0 +1,24 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Unit.Fluent +{ + public class OnspringRequestTests + { + private static OnspringRequest _onspringRequest; + + [ClassInitialize] + public static void ClassInit() + { + _onspringRequest = new OnspringClient("https://api.onspring.com", "key").CreateRequest(); + } + + [TestMethod] + public void ToGetRecords_WhenCalled_ShouldReturnAGetRecordsRequestBuilderInstance() + { + var builder = _onspringRequest.ToGetRecords(); + + Assert.IsInstanceOfType(builder); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs new file mode 100644 index 0000000..67e197a --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs @@ -0,0 +1,18 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Unit +{ + [TestClass] + public class OnspringClientTests + { + [TestMethod] + public void CreateRequest_WhenCalled_ItShouldReturnAnOnspringRequestInstance() + { + var client = new OnspringClient("https://api.onspring.com", "key"); + var request = client.CreateRequest(); + + Assert.IsInstanceOfType(request); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index f519361..026564d 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -1,5 +1,6 @@ using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -11,6 +12,12 @@ namespace Onspring.API.SDK /// public interface IOnspringClient { + /// + /// Creates a new Onspring request which exposes a fluent interface for making a request to the Onspring API. + /// + /// An instance of . + OnspringRequest CreateRequest(); + /// /// Determines if the API is reachable. /// diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index fcdaf9c..3e85999 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -1,5 +1,7 @@ +using System.Runtime.CompilerServices; using Onspring.API.SDK.Interfaces.Fluent; +[assembly: InternalsVisibleTo("Onspring.API.SDK.Tests")] namespace Onspring.API.SDK.Models.Fluent { public class OnspringRequest : IOnspringRequest diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index 6143dda..caae960 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -76,10 +76,10 @@ public OnspringClient(OnspringClientConfiguration clientConfig) // ------------------------------------ Fluent Interface ------------------------------------ /// - /// Creates a new instance of the class, which provides a fluent interface for building a request to the Onspring API. + /// Creates a new Onspring request which exposes a fluent interface for making a request to the Onspring API. /// - /// A new instance. - public IOnspringRequest CreateRequest() + /// An instance of . + public OnspringRequest CreateRequest() { return new OnspringRequest(this); } From 538a14dc29eebe6abd8ea4940dceb359e0d46d7b Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:27:43 -0500 Subject: [PATCH 037/168] chore: remove internals visible attribute --- Onspring.API.SDK/Models/Fluent/OnspringRequest.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 3e85999..fcdaf9c 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -1,7 +1,5 @@ -using System.Runtime.CompilerServices; using Onspring.API.SDK.Interfaces.Fluent; -[assembly: InternalsVisibleTo("Onspring.API.SDK.Tests")] namespace Onspring.API.SDK.Models.Fluent { public class OnspringRequest : IOnspringRequest From 6fac46b53b206350e3312178a3dd958f9c126d15 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 22:42:06 -0500 Subject: [PATCH 038/168] tests: add tests for GetRecordsRequestBuilder --- .../Fluent/GetRecordsRequestBuilderTests.cs | 28 +++++++++++++++++++ .../Tests/Unit/Fluent/OnspringRequestTests.cs | 3 +- .../Fluent/IGetRecordsRequestBuilder.cs | 4 ++- .../Interfaces/Fluent/IOnspringRequest.cs | 4 ++- .../Models/Fluent/GetRecordsRequestBuilder.cs | 2 +- .../Models/Fluent/OnspringRequest.cs | 2 +- 6 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs new file mode 100644 index 0000000..f9607fb --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs @@ -0,0 +1,28 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Unit.Fluent +{ + public class GetRecordsRequestBuilderTests + { + private static GetRecordsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit() + { + _builder = new OnspringClient("https://api.onspring.com", "key") + .CreateRequest() + .ToGetRecords(); + } + + [TestMethod] + public void FromApp_WhenCalled_ShouldReturnAGetRecordsByAppRequestBuilderInstanceWithAppIdSetToCorrectValue() + { + var appId = 1; + var builder = _builder.FromApp(appId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(appId, builder.AppId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs index a948df8..a744c57 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs @@ -10,7 +10,8 @@ public class OnspringRequestTests [ClassInitialize] public static void ClassInit() { - _onspringRequest = new OnspringClient("https://api.onspring.com", "key").CreateRequest(); + _onspringRequest = new OnspringClient("https://api.onspring.com", "key") + .CreateRequest(); } [TestMethod] diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs index 355ad78..d1e1301 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs @@ -1,7 +1,9 @@ +using Onspring.API.SDK.Models.Fluent; + namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetRecordsRequestBuilder { - IGetRecordsByAppRequestBuilder FromApp(int appId); + GetRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index 60d44da..be7777d 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -1,7 +1,9 @@ +using Onspring.API.SDK.Models.Fluent; + namespace Onspring.API.SDK.Interfaces.Fluent { public interface IOnspringRequest { - IGetRecordsRequestBuilder ToGetRecords(); + GetRecordsRequestBuilder ToGetRecords(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs index 4e74e84..6bf10e8 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs @@ -11,7 +11,7 @@ internal GetRecordsRequestBuilder(IOnspringClient client) _client = client; } - public IGetRecordsByAppRequestBuilder FromApp(int appId) + public GetRecordsByAppRequestBuilder FromApp(int appId) { return new GetRecordsByAppRequestBuilder(_client, appId); } diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index fcdaf9c..684f78f 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -11,7 +11,7 @@ internal OnspringRequest(IOnspringClient client) _client = client; } - public IGetRecordsRequestBuilder ToGetRecords() + public GetRecordsRequestBuilder ToGetRecords() { return new GetRecordsRequestBuilder(_client); } From 9bfd9f5648c1e2ebbf5e9021aa19587cf41fc8bd Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 23:03:07 -0500 Subject: [PATCH 039/168] tests: fix namespace --- .../Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs | 2 +- .../Tests/Unit/Fluent/OnspringRequestTests.cs | 2 +- Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs index f9607fb..09c4f2c 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs @@ -1,7 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Models.Fluent; -namespace Onspring.API.SDK.Tests.Unit.Fluent +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { public class GetRecordsRequestBuilderTests { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs index a744c57..d8d2f64 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs @@ -1,7 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Models.Fluent; -namespace Onspring.API.SDK.Tests.Unit.Fluent +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { public class OnspringRequestTests { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs index 67e197a..2f26711 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs @@ -1,7 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Models.Fluent; -namespace Onspring.API.SDK.Tests.Unit +namespace Onspring.API.SDK.Tests.Tests.Unit { [TestClass] public class OnspringClientTests From b76d6b589bd8c4762a0570f3f76c4219f7299d47 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 23:04:44 -0500 Subject: [PATCH 040/168] tests: fix add missing attributes --- .../Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs | 2 ++ .../Tests/Unit/Fluent/OnspringRequestTests.cs | 2 ++ Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs index 09c4f2c..81324ea 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs @@ -1,8 +1,10 @@ +using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { + [TestClass, ExcludeFromCodeCoverage] public class GetRecordsRequestBuilderTests { private static GetRecordsRequestBuilder _builder; diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs index d8d2f64..88c6f32 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs @@ -1,8 +1,10 @@ +using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { + [TestClass, ExcludeFromCodeCoverage] public class OnspringRequestTests { private static OnspringRequest _onspringRequest; diff --git a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs index 2f26711..b6c3705 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs @@ -1,9 +1,10 @@ +using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit { - [TestClass] + [TestClass, ExcludeFromCodeCoverage] public class OnspringClientTests { [TestMethod] From 230106da9bb59f8beeb0265111fbe25443139a36 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 17 Sep 2023 23:08:48 -0500 Subject: [PATCH 041/168] tests: fix class init signature --- .../Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs | 2 +- .../Tests/Unit/Fluent/OnspringRequestTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs index 81324ea..6a2cbf3 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs @@ -10,7 +10,7 @@ public class GetRecordsRequestBuilderTests private static GetRecordsRequestBuilder _builder; [ClassInitialize] - public static void ClassInit() + public static void ClassInit(TestContext testContext) { _builder = new OnspringClient("https://api.onspring.com", "key") .CreateRequest() diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs index 88c6f32..00162a0 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs @@ -10,7 +10,7 @@ public class OnspringRequestTests private static OnspringRequest _onspringRequest; [ClassInitialize] - public static void ClassInit() + public static void ClassInit(TestContext testContext) { _onspringRequest = new OnspringClient("https://api.onspring.com", "key") .CreateRequest(); From bcc81f00d2b86cf5fa171d3a41d59a0423aef7de Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:42:26 -0500 Subject: [PATCH 042/168] fix: move return types back to interfaces that expose the public property getters --- .../Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs | 3 ++- .../Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs | 4 ++++ .../Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs | 5 +++++ .../Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs | 4 +--- .../Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs | 4 ++++ .../Interfaces/Fluent/IGetRecordsRequestBuilder.cs | 4 +--- Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs | 4 +--- Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs | 2 +- Onspring.API.SDK/Models/Fluent/OnspringRequest.cs | 2 +- 9 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs index 6a2cbf3..c28e585 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -7,7 +8,7 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent [TestClass, ExcludeFromCodeCoverage] public class GetRecordsRequestBuilderTests { - private static GetRecordsRequestBuilder _builder; + private static IGetRecordsRequestBuilder _builder; [ClassInitialize] public static void ClassInit(TestContext testContext) diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs index 1cb2174..eec66ec 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs @@ -9,6 +9,10 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetRecordByIdRequestBuilder { + int AppId { get; } + int RecordId { get; } + IEnumerable FieldIds { get; } + DataFormat Format { get; } Task> SendAsync(); Task> SendAsync(Action options); IGetRecordByIdRequestBuilder WithFieldIds(IEnumerable fieldIds); diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs index 0d47209..7157c65 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs @@ -9,6 +9,11 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetRecordsByAppPagedRequestBuilder { + int AppId { get; } + int PageNumber { get; } + IEnumerable FieldIds { get; } + DataFormat Format { get; } + int PageSize { get; } Task> SendAsync(); Task> SendAsync(Action options); IGetRecordsByAppPagedRequestBuilder WithPageSize(int pageSize); diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs index 1ecd6be..4fa0ec5 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs @@ -1,14 +1,12 @@ using System; using System.Collections.Generic; -using System.Threading.Tasks; -using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; -using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetRecordsByAppRequestBuilder { + int AppId { get; } IGetRecordsByAppPagedRequestBuilder ForPage(int pageNumber); IGetRecordByIdRequestBuilder WithId(int recordId); IGetRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds); diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs index 7d3a66e..5fa7ae0 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs @@ -9,6 +9,10 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetRecordsByIdsRequestBuilder { + int AppId { get; } + IEnumerable RecordIds { get; } + IEnumerable FieldIds { get; } + DataFormat Format { get; } Task> SendAsync(); Task> SendAsync(Action options); IGetRecordsByIdsRequestBuilder WithFieldIds(IEnumerable fieldIds); diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs index d1e1301..355ad78 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs @@ -1,9 +1,7 @@ -using Onspring.API.SDK.Models.Fluent; - namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetRecordsRequestBuilder { - GetRecordsByAppRequestBuilder FromApp(int appId); + IGetRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index be7777d..60d44da 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -1,9 +1,7 @@ -using Onspring.API.SDK.Models.Fluent; - namespace Onspring.API.SDK.Interfaces.Fluent { public interface IOnspringRequest { - GetRecordsRequestBuilder ToGetRecords(); + IGetRecordsRequestBuilder ToGetRecords(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs index 6bf10e8..4e74e84 100644 --- a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs @@ -11,7 +11,7 @@ internal GetRecordsRequestBuilder(IOnspringClient client) _client = client; } - public GetRecordsByAppRequestBuilder FromApp(int appId) + public IGetRecordsByAppRequestBuilder FromApp(int appId) { return new GetRecordsByAppRequestBuilder(_client, appId); } diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 684f78f..fcdaf9c 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -11,7 +11,7 @@ internal OnspringRequest(IOnspringClient client) _client = client; } - public GetRecordsRequestBuilder ToGetRecords() + public IGetRecordsRequestBuilder ToGetRecords() { return new GetRecordsRequestBuilder(_client); } From 7d4a5262220c8cc28fb1259b39b86c3207997e22 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:04:20 -0500 Subject: [PATCH 043/168] tests: update tests --- .../Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs | 8 ++++---- .../Tests/Unit/Fluent/OnspringRequestTests.cs | 5 +++-- Onspring.API.SDK/Onspring.API.SDK.csproj | 7 +++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs index c28e585..e72bb5f 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; @@ -8,14 +9,13 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent [TestClass, ExcludeFromCodeCoverage] public class GetRecordsRequestBuilderTests { - private static IGetRecordsRequestBuilder _builder; + private static GetRecordsRequestBuilder _builder; [ClassInitialize] public static void ClassInit(TestContext testContext) { - _builder = new OnspringClient("https://api.onspring.com", "key") - .CreateRequest() - .ToGetRecords(); + var apiClientMock = Substitute.For(); + _builder = new GetRecordsRequestBuilder(apiClientMock); } [TestMethod] diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs index 00162a0..4f348bb 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -12,8 +13,8 @@ public class OnspringRequestTests [ClassInitialize] public static void ClassInit(TestContext testContext) { - _onspringRequest = new OnspringClient("https://api.onspring.com", "key") - .CreateRequest(); + var apiClientMock = Substitute.For(); + _onspringRequest = new OnspringRequest(apiClientMock); } [TestMethod] diff --git a/Onspring.API.SDK/Onspring.API.SDK.csproj b/Onspring.API.SDK/Onspring.API.SDK.csproj index 426f4d2..c32bcdd 100644 --- a/Onspring.API.SDK/Onspring.API.SDK.csproj +++ b/Onspring.API.SDK/Onspring.API.SDK.csproj @@ -14,6 +14,13 @@ true Onspring; Onspring Technologies; Onspring SDK; Onspring API + + + + <_Parameter1>$(AssemblyName).Tests + + + From 16b58f029fbdc14b06020c9f269adf0bf8dd81a0 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:05:18 -0500 Subject: [PATCH 044/168] chore: add coverlet msbuild integration --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index b148e44..7502480 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -11,6 +11,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + From 2efb293b28b7dc7fea786f72e547866aa2761d04 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:12:46 -0500 Subject: [PATCH 045/168] chore: update csproj to generate coverlet coverage on test runs --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index 7502480..67a9108 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -12,8 +12,8 @@ - runtime; build; native; contentfiles; analyzers; buildtransitive - all + runtime; build; native; contentfiles; analyzers; buildtransitive + all @@ -26,6 +26,12 @@ + + true + ./TestResults/coverage/$(MSBuildProjectName)/ + opencover + + $(MSBuildProjectDirectory)\runsettings\internal.runsettings From 28fd6c4ae326abcd37d734885ad31a0e965cedfc Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:13:34 -0500 Subject: [PATCH 046/168] chore: add report generator as dep --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index 67a9108..ef7afd7 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -24,6 +24,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + From ca1b6b2a014f699ac5ae7ede5766cf86a7f62106 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:23:11 -0500 Subject: [PATCH 047/168] chore: add msbuild task to generate html coverage report --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index ef7afd7..abea2c6 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -33,6 +33,10 @@ opencover + + + + $(MSBuildProjectDirectory)\runsettings\internal.runsettings From 77dc592ffabbb25c17250b71ce5b2e79252f695d Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 19:21:55 -0500 Subject: [PATCH 048/168] chore: correct target framework --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index abea2c6..0a29a34 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -1,7 +1,7 @@  - net7 + net7.0 false From 5119b7022c2915eff16bf7c3b07c41e52c46f54a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 19:45:38 -0500 Subject: [PATCH 049/168] chore: update report coverage script --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index 0a29a34..26372b6 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -34,7 +34,7 @@ - + From d8e23b6d07a511a57bf5f2a24c86ff593eff4966 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 20:15:59 -0500 Subject: [PATCH 050/168] tests: add tests for filter operators --- .../Tests/Unit/FilterOperatorTests.cs | 311 ++++++++++++++++++ 1 file changed, 311 insertions(+) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs new file mode 100644 index 0000000..5299c0f --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs @@ -0,0 +1,311 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit +{ + [TestClass, ExcludeFromCodeCoverage] + public class FilterOperatorTests + { + [TestMethod] + public void Equal_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.Equal; + Assert.IsInstanceOfType(op); + Assert.AreEqual(1, op.Id); + Assert.AreEqual("eq", op.Name); + } + + [TestMethod] + public void Equal_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.Equal == FilterOperator.Equal; + Assert.IsTrue(result); + } + + [TestMethod] + public void Equal_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.Equal == FilterOperator.NotEqual; + Assert.IsFalse(result); + } + + [TestMethod] + public void Equal_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.Equal}"; + Assert.AreEqual("eq", op); + } + + [TestMethod] + public void NotEqual_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.NotEqual; + Assert.IsInstanceOfType(op); + Assert.AreEqual(2, op.Id); + Assert.AreEqual("ne", op.Name); + } + + [TestMethod] + public void NotEqual_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.NotEqual == FilterOperator.NotEqual; + Assert.IsTrue(result); + } + + [TestMethod] + public void NotEqual_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.NotEqual == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void NotEqual_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.NotEqual}"; + Assert.AreEqual("ne", op); + } + + [TestMethod] + public void Contains_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.Contains; + Assert.IsInstanceOfType(op); + Assert.AreEqual(3, op.Id); + Assert.AreEqual("contains", op.Name); + } + + [TestMethod] + public void Contains_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.Contains == FilterOperator.Contains; + Assert.IsTrue(result); + } + + [TestMethod] + public void Contains_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.Contains == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void Contains_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.Contains}"; + Assert.AreEqual("contains", op); + } + + [TestMethod] + public void IsNull_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.IsNull; + Assert.IsInstanceOfType(op); + Assert.AreEqual(4, op.Id); + Assert.AreEqual("isnull", op.Name); + } + + [TestMethod] + public void IsNull_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.IsNull == FilterOperator.IsNull; + Assert.IsTrue(result); + } + + [TestMethod] + public void IsNull_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.IsNull == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void IsNull_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.IsNull}"; + Assert.AreEqual("isnull", op); + } + + [TestMethod] + public void NotNull_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.NotNull; + Assert.IsInstanceOfType(op); + Assert.AreEqual(5, op.Id); + Assert.AreEqual("notnull", op.Name); + } + + [TestMethod] + public void NotNull_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.NotNull == FilterOperator.NotNull; + Assert.IsTrue(result); + } + + [TestMethod] + public void NotNull_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.NotNull == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void NotNull_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.NotNull}"; + Assert.AreEqual("notnull", op); + } + + [TestMethod] + public void GreaterThan_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.GreaterThan; + Assert.IsInstanceOfType(op); + Assert.AreEqual(6, op.Id); + Assert.AreEqual("gt", op.Name); + } + + [TestMethod] + public void GreaterThan_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.GreaterThan == FilterOperator.GreaterThan; + Assert.IsTrue(result); + } + + [TestMethod] + public void GreaterThan_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.GreaterThan == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void GreaterThan_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.GreaterThan}"; + Assert.AreEqual("gt", op); + } + + [TestMethod] + public void LessThan_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.LessThan; + Assert.IsInstanceOfType(op); + Assert.AreEqual(7, op.Id); + Assert.AreEqual("lt", op.Name); + } + + [TestMethod] + public void LessThan_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.LessThan == FilterOperator.LessThan; + Assert.IsTrue(result); + } + + [TestMethod] + public void LessThan_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.LessThan == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void LessThan_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.LessThan}"; + Assert.AreEqual("lt", op); + } + + [TestMethod] + public void And_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.And; + Assert.IsInstanceOfType(op); + Assert.AreEqual(8, op.Id); + Assert.AreEqual("and", op.Name); + } + + [TestMethod] + public void And_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.And == FilterOperator.And; + Assert.IsTrue(result); + } + + [TestMethod] + public void And_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.And == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void And_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.And}"; + Assert.AreEqual("and", op); + } + + [TestMethod] + public void Or_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.Or; + Assert.IsInstanceOfType(op); + Assert.AreEqual(9, op.Id); + Assert.AreEqual("or", op.Name); + } + + [TestMethod] + public void Or_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.Or == FilterOperator.Or; + Assert.IsTrue(result); + } + + [TestMethod] + public void Or_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.Or == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void Or_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.Or}"; + Assert.AreEqual("or", op); + } + + [TestMethod] + public void Not_WhenCalled_ItShouldReturnCorrectOperator() + { + var op = FilterOperator.Not; + Assert.IsInstanceOfType(op); + Assert.AreEqual(10, op.Id); + Assert.AreEqual("not", op.Name); + } + + [TestMethod] + public void Not_WhenComparedToItself_ItShouldReturnTrue() + { + var result = FilterOperator.Not == FilterOperator.Not; + Assert.IsTrue(result); + } + + [TestMethod] + public void Not_WhenComparedToAnotherOperator_ItShouldReturnFalse() + { + var result = FilterOperator.Not == FilterOperator.Equal; + Assert.IsFalse(result); + } + + [TestMethod] + public void Not_WhenToStringIsCalled_ItShouldReturnProperName() + { + var op = $"{FilterOperator.Not}"; + Assert.AreEqual("not", op); + } + } +} \ No newline at end of file From 97819554f36726e735a49948849f48ec13d0f090 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 20:55:49 -0500 Subject: [PATCH 051/168] tests: add tests for filter model --- .../Tests/Unit/FilterOperatorTests.cs | 1 - .../Tests/Unit/FilterTests.cs | 147 ++++++++++++++++++ 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs index 5299c0f..bb36fa8 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs @@ -1,7 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs new file mode 100644 index 0000000..e812d89 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs @@ -0,0 +1,147 @@ +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Tests.Tests.Unit +{ + [TestClass, ExcludeFromCodeCoverage] + public class FilterTests + { + [TestMethod] + public void Filter_ParameterlessConstructorWhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var filter = new Filter(); + Assert.AreEqual(0, filter.FieldId); + Assert.AreEqual(null, filter.Operator); + Assert.AreEqual(null, filter.Value); + } + + [TestMethod] + public void Filter_WhenActionInvokedOn_ItShouldAnInstanceWithPropertiesSet() + { + var fieldId = 1; + var op = FilterOperator.Equal; + var value = 1; + var filter = new Filter(); + var action = (Filter filter) => + { + filter.FieldId = 1; + filter.Operator = op; + filter.Value = value; + }; + + action.Invoke(filter); + + Assert.AreEqual(fieldId, filter.FieldId); + Assert.AreEqual(op, filter.Operator); + Assert.AreEqual(value, filter.Value); + } + + [TestMethod] + public void Filter_ConstructorWhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var fieldId = 1; + var op = FilterOperator.Equal; + var value = 1; + + var filter = new Filter(fieldId, op, value); + + Assert.AreEqual(fieldId, filter.FieldId); + Assert.AreEqual(op, filter.Operator); + Assert.AreEqual(value, filter.Value); + } + + [TestMethod] + public void Filter_ConstructorWhenCalledAndOperatorIsNotANullOperatorAndValueIsNull_ItShouldThrowException() + { + var action = () => new Filter(1, FilterOperator.And, null); + Assert.ThrowsException(action); + } + + [TestMethod] + public void Filter_ConstructorWhenCalledAndOperatorIsNotNullOperatorAndValueIsNull_ItShouldReturnAnInstanceWithPropertiesSet() + { + var fieldId = 1; + var op = FilterOperator.NotNull; + object value = null; + + var filter = new Filter(fieldId, op, value); + + Assert.AreEqual(fieldId, filter.FieldId); + Assert.AreEqual(op, filter.Operator); + Assert.AreEqual(value, filter.Value); + } + + [TestMethod] + public void Filter_ConstructorWhenCalledAndOperatorIsIsNullOperatorAndValueIsNull_ItShouldReturnAnInstanceWithPropertiesSet() + { + var fieldId = 1; + var op = FilterOperator.IsNull; + object value = null; + + var filter = new Filter(fieldId, op, value); + + Assert.AreEqual(fieldId, filter.FieldId); + Assert.AreEqual(op, filter.Operator); + Assert.AreEqual(value, filter.Value); + } + + [TestMethod] + public void Filter_WhenValueIsSetToNullAndOperatorIsNotANullOperator_ItShouldThrowAnException() + { + var filter = new Filter(1, FilterOperator.Equal, 1); + var action = () => filter.Value = null; + Assert.ThrowsException(action); + } + + [TestMethod] + public void Filter_WhenValueIsSetToNullAndOperatorIsNotNullOperator_ItShouldSetValueProperty() + { + var filter = new Filter(1, FilterOperator.NotNull, 1); + filter.Value = null; + Assert.AreEqual(null, filter.Value); + } + + [TestMethod] + public void Filter_WhenValueIsSetToNullAndOperatorIsIsNullOperator_ItShouldSetValueProperty() + { + var filter = new Filter(1, FilterOperator.IsNull, 1); + filter.Value = null; + Assert.AreEqual(null, filter.Value); + } + + [TestMethod] + public void Filter_ToStringWhenCalledAndValueIsNull_ItShouldReturnProperFilterString() + { + var filter = new Filter(1, FilterOperator.NotNull, null); + Assert.AreEqual("1 notnull", filter.ToString()); + } + + [TestMethod] + public void Filter_ToStringWhenCalledAndValueIsDateTime_ItShouldReturnProperFilterString() + { + var date = DateTime.UtcNow; + var filter = new Filter(1, FilterOperator.Equal, date); + Assert.AreEqual($"1 eq datetime'{date:O}'", $"{filter}"); + } + + [TestMethod] + public void Filter_ToStringWhenCalledAndValueIsString_ItShouldReturnProperFilterString() + { + var stringValue = "hello"; + var filter = new Filter(1, FilterOperator.Equal, stringValue); + Assert.AreEqual($"1 eq '{stringValue}'", filter.ToString()); + } + + [TestMethod] + public void Filter_ToStringWhenCalledAndValueIsNumber_ItShouldReturnProperFilterString() + { + var num = 1; + var filter = new Filter(1, FilterOperator.Equal, num); + Assert.AreEqual($"1 eq {num}", filter.ToString()); + } + } +} \ No newline at end of file From a5a2c54598bcf7f30dad9f694f6effb075a22752 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:03:05 -0500 Subject: [PATCH 052/168] fix: adjust format of datetime filter string --- Onspring.API.SDK/Models/Filter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK/Models/Filter.cs b/Onspring.API.SDK/Models/Filter.cs index 45b488f..a8217eb 100644 --- a/Onspring.API.SDK/Models/Filter.cs +++ b/Onspring.API.SDK/Models/Filter.cs @@ -42,7 +42,7 @@ public override string ToString() if (Value is DateTime dateTime) { - return $"{FieldId} {Operator} datetime'{dateTime:yyyy-MM-ddTHH:mm:ss.fff}'"; + return $"{FieldId} {Operator} datetime'{dateTime:O}'"; } if (Value is string stringValue) From 20dbccb15902fae6a25d2ae63cd1fe6b43908e2c Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:20:48 -0500 Subject: [PATCH 053/168] tests: add tests for GetRecordsByAppRequestBuilderTests --- .../GetRecordsByAppRequestBuilderTests.cs | 105 ++++++++++++++++++ .../Fluent/GetRecordsRequestBuilderTests.cs | 1 - .../IQueryRecordsByAppPagedRequestBuilder.cs | 6 + 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppRequestBuilderTests.cs new file mode 100644 index 0000000..55a3b3c --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppRequestBuilderTests.cs @@ -0,0 +1,105 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetRecordsByAppRequestBuilderTests + { + private static IOnspringClient _client; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + } + + [TestMethod] + public void Constructor_WhenCalled_ReturnsInstanceOfBuilder() + { + var appId = 1; + var builder = new GetRecordsByAppRequestBuilder(_client, appId); + + Assert.AreEqual(appId, builder.AppId); + } + + [TestMethod] + public void ForPage_WhenCalled_ReturnsInstanceOfPagedAppBuilderWithPropetiesSet() + { + var appId = 1; + var pageNumber = 1; + var builder = new GetRecordsByAppRequestBuilder(_client, appId); + + var pagedBuilder = builder.ForPage(pageNumber); + + Assert.IsInstanceOfType(pagedBuilder); + Assert.AreEqual(appId, pagedBuilder.AppId); + Assert.AreEqual(pageNumber, pagedBuilder.PageNumber); + } + + [TestMethod] + public void WithId_WhenCalled_ReturnsRecordByIdBuilderWithPropertiesSet() + { + var appId = 1; + var recordId = 1; + var builder = new GetRecordsByAppRequestBuilder(_client, appId); + + var recordByIdBuilder = builder.WithId(recordId); + + Assert.IsInstanceOfType(recordByIdBuilder); + Assert.AreEqual(appId, recordByIdBuilder.AppId); + Assert.AreEqual(recordId, recordByIdBuilder.RecordId); + } + + [TestMethod] + public void WithIds_WhenCalled_ReturnsRecordsByIdsBuilderWithPropertiesSet() + { + var appId = 1; + var recordIds = new[] { 1, 2, 3 }; + var builder = new GetRecordsByAppRequestBuilder(_client, appId); + + var recordsByIdsBuilder = builder.WithIds(recordIds); + + Assert.IsInstanceOfType(recordsByIdsBuilder); + Assert.AreEqual(appId, recordsByIdsBuilder.AppId); + Assert.AreEqual(recordIds, recordsByIdsBuilder.RecordIds); + } + + [TestMethod] + public void WithFilter_WhenCalledWithFilterString_ReturnsQueryRecordsBuilderWithPropertiesSet() + { + var appId = 1; + var filter = new Filter(1, FilterOperator.Equal, 1); + var builder = new GetRecordsByAppRequestBuilder(_client, appId); + + var queryRecordsBuilder = builder.WithFilter(filter.ToString()); + + Assert.IsInstanceOfType(queryRecordsBuilder); + Assert.AreEqual(appId, queryRecordsBuilder.AppId); + Assert.AreEqual(filter.ToString(), queryRecordsBuilder.Filter); + } + + [TestMethod] + public void WithFilter_WhenCalledWithFilterAction_ReturnsQueryRecordsBuilderWithPropertiesSet() + { + var appId = 1; + var filter = new Filter(1, FilterOperator.Equal, 1); + var builder = new GetRecordsByAppRequestBuilder(_client, appId); + + var queryRecordsBuilder = builder.WithFilter(f => + { + f.FieldId = filter.FieldId; + f.Operator = filter.Operator; + f.Value = filter.Value; + }); + + Assert.IsInstanceOfType(queryRecordsBuilder); + Assert.AreEqual(appId, queryRecordsBuilder.AppId); + Assert.AreEqual(filter.ToString(), queryRecordsBuilder.Filter); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs index e72bb5f..ddbaa94 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs @@ -1,7 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; -using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent diff --git a/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs index 8d9de81..f725f87 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs @@ -9,6 +9,12 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IQueryRecordsByAppPagedRequestBuilder { + int AppId { get; } + string Filter { get; } + int PageNumber { get; } + int PageSize { get; } + IEnumerable FieldIds { get; } + DataFormat Format { get; } Task> SendAsync(); Task> SendAsync(Action options); IQueryRecordsByAppPagedRequestBuilder ForPageNumber(int pageNumber); From df967cc218790f6d4d51f64f91096d52c06631a2 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:28:25 -0500 Subject: [PATCH 054/168] chore: stub out unit test classes --- .../GetRecordByIdRequestBuilderTests.cs | 21 +++++++++++++++++++ ...GetRecordsByAppPagedRequestBuilderTests.cs | 21 +++++++++++++++++++ .../GetRecordsByIdsRequestBuilderTests.cs | 21 +++++++++++++++++++ ...eryRecordsByAppPagedRequestBuilderTests.cs | 21 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/QueryRecordsByAppPagedRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs new file mode 100644 index 0000000..5c8d8c0 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs @@ -0,0 +1,21 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetRecordByIdRequestBuilderTests + { + private static IOnspringClient _client; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + } + + // TODO: Write tests + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs new file mode 100644 index 0000000..66a394d --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs @@ -0,0 +1,21 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetRecordsByAppPagedRequestBuilderTests + { + private static IOnspringClient _client; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + } + + // TODO: Write tests + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs new file mode 100644 index 0000000..a2b0d69 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs @@ -0,0 +1,21 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetRecordsByIdsRequestBuilderTests + { + private static IOnspringClient _client; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + } + + // TODO: Write tests + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/QueryRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/QueryRecordsByAppPagedRequestBuilderTests.cs new file mode 100644 index 0000000..dd7b01a --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/QueryRecordsByAppPagedRequestBuilderTests.cs @@ -0,0 +1,21 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class QueryRecordsByAppPagedRequestBuilderTests + { + private static IOnspringClient _client; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + } + + // TODO: Write tests + } +} \ No newline at end of file From 101e2cbcff61b13428c63f3e475597f11530aa95 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:02:17 -0500 Subject: [PATCH 055/168] tests: add tests for GetRecordByIdRequestBuilder --- .../GetRecordByIdRequestBuilderTests.cs | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs index 5c8d8c0..edecb9b 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs @@ -1,6 +1,11 @@ using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -9,13 +14,87 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent public class GetRecordByIdRequestBuilderTests { private static IOnspringClient _client; + private static GetRecordByIdRequestBuilder _builder; [ClassInitialize] public static void ClassInit(TestContext testContext) { _client = Substitute.For(); + _builder = new GetRecordByIdRequestBuilder(_client, 1, 1); } - // TODO: Write tests + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var appId = 1; + var recordId = 1; + var builder = new GetRecordByIdRequestBuilder(_client, appId, recordId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(appId, builder.AppId); + Assert.AreEqual(recordId, builder.RecordId); + Assert.AreEqual(Enumerable.Empty(), builder.FieldIds); + Assert.AreEqual(DataFormat.Raw, builder.Format); + } + + [TestMethod] + public void WithFieldIds_WhenCalled_ItShouldSetInstancesFieldIds() + { + var fieldIds = new[] { 1, 2, 4, }; + + _builder.WithFieldIds(fieldIds); + + Assert.AreEqual(fieldIds, _builder.FieldIds); + } + + [TestMethod] + public void WithFormat_WhenCalled_ItShouldSetInstancesFormat() + { + var fieldIds = new[] { 1, 2, 4, }; + + _builder.WithFormat(DataFormat.Formatted); + + Assert.AreEqual(DataFormat.Formatted, _builder.Format); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new ResultRecord(), + }; + + _client + .GetRecordAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + + [TestMethod] + public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new ResultRecord(), + }; + + _client + .GetRecordAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder + .SendAsync(options => + { + options.Format = DataFormat.Raw; + }); + + Assert.AreEqual(apiResponse, result); + } } } \ No newline at end of file From 85e3656f334947d8b6d26dfc26d08711b7a77fbe Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:02:50 -0500 Subject: [PATCH 056/168] tests: adjust indentation --- .../Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs index edecb9b..d8b9ddd 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs @@ -89,10 +89,10 @@ public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnApiResponse() .Returns(apiResponse); var result = await _builder - .SendAsync(options => - { - options.Format = DataFormat.Raw; - }); + .SendAsync(options => + { + options.Format = DataFormat.Raw; + }); Assert.AreEqual(apiResponse, result); } From 79344b820bfbee1a087be9a0080a617f98d605cd Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 20:30:07 -0500 Subject: [PATCH 057/168] tests: add tests for GetRecordsByAppPagedRequestBuilder --- ...GetRecordsByAppPagedRequestBuilderTests.cs | 94 ++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs index 66a394d..ea77d9b 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs @@ -1,6 +1,11 @@ using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -9,13 +14,100 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent public class GetRecordsByAppPagedRequestBuilderTests { private static IOnspringClient _client; + private static GetRecordsByAppPagedRequestBuilder _builder; [ClassInitialize] public static void ClassInit(TestContext testContext) { _client = Substitute.For(); + _builder = new GetRecordsByAppPagedRequestBuilder(_client, 1, 1); } - // TODO: Write tests + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var appId = 1; + var pageNumber = 1; + var builder = new GetRecordsByAppPagedRequestBuilder(_client, appId, pageNumber); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(appId, builder.AppId); + Assert.AreEqual(pageNumber, builder.PageNumber); + Assert.AreEqual(Enumerable.Empty(), builder.FieldIds); + Assert.AreEqual(DataFormat.Raw, builder.Format); + Assert.AreEqual(50, builder.PageSize); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldSetInstancesPageSize() + { + var pageSize = 1; + + _builder.WithPageSize(pageSize); + + Assert.AreEqual(pageSize, _builder.PageSize); + } + + + [TestMethod] + public void WithFieldIds_WhenCalled_ItShouldSetInstancesFieldIds() + { + var fieldIds = new int[] { 1, 2, 4 }; + + _builder.WithFieldIds(fieldIds); + + Assert.AreEqual(fieldIds, _builder.FieldIds); + } + + [TestMethod] + public void WithFormat_WhenCalled_ItShouldSetInstancesFormat() + { + var format = DataFormat.Formatted; + + _builder.WithFormat(format); + + Assert.AreEqual(format, _builder.Format); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetPagedRecordsResponse(), + }; + + _client + .GetRecordsForAppAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + + [TestMethod] + public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetPagedRecordsResponse(), + }; + + _client + .GetRecordsForAppAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(options => + { + options.PageSize = 10; + options.FieldIds = new[] { 1, 2, 3 }; + options.Format = DataFormat.Raw; + }); + + Assert.AreEqual(apiResponse, result); + } } } \ No newline at end of file From e434345c4bdadf97fa045a9e8c57081ffe4b1aad Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 20:42:10 -0500 Subject: [PATCH 058/168] tests: add tests for GetRecordsByIdsRequestBuilder --- .../GetRecordsByIdsRequestBuilderTests.cs | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs index a2b0d69..6b263ec 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs @@ -1,6 +1,11 @@ using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -9,13 +14,87 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent public class GetRecordsByIdsRequestBuilderTests { private static IOnspringClient _client; + private static GetRecordsByIdsRequestBuilder _builder; [ClassInitialize] public static void ClassInit(TestContext testContext) { _client = Substitute.For(); + _builder = new GetRecordsByIdsRequestBuilder(_client, 1, new[] { 1, 2, 3 }); } - // TODO: Write tests + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var appId = 1; + var recordIds = new[] { 1, 2, 3 }; + var builder = new GetRecordsByIdsRequestBuilder(_client, appId, recordIds); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(appId, builder.AppId); + Assert.AreEqual(recordIds, builder.RecordIds); + Assert.AreEqual(Enumerable.Empty(), builder.FieldIds); + Assert.AreEqual(DataFormat.Raw, builder.Format); + } + + [TestMethod] + public void WithFieldIds_WhenCalled_ItShouldSetInstancesFieldIds() + { + var fieldIds = new[] { 1, 2, 3 }; + + _builder.WithFieldIds(fieldIds); + + Assert.AreEqual(fieldIds, _builder.FieldIds); + } + + [TestMethod] + public void WithFormat_WhenCalled_ItShouldSetInstancesFormat() + { + var format = DataFormat.Formatted; + + _builder.WithFormat(format); + + Assert.AreEqual(format, _builder.Format); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetRecordsResponse(), + }; + + _client + .GetRecordsAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + + [TestMethod] + public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetRecordsResponse(), + }; + + _client + .GetRecordsAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(options => + { + options.FieldIds = new[] { 1, 2, 3 }; + options.Format = DataFormat.Raw; + }); + + Assert.AreEqual(apiResponse, result); + } } } \ No newline at end of file From 310d4ef52bbd076c928daf55fb5e188fa57fb0de Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 20:50:56 -0500 Subject: [PATCH 059/168] refactor: move models and interfaces into folders by area by method --- Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs | 1 + .../Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs | 7 +++++++ .../{ => Records/Get}/IGetRecordByIdRequestBuilder.cs | 0 .../Get}/IGetRecordsByAppPagedRequestBuilder.cs | 0 .../{ => Records/Get}/IGetRecordsByAppRequestBuilder.cs | 0 .../{ => Records/Get}/IGetRecordsByIdsRequestBuilder.cs | 0 .../Fluent/{ => Records/Get}/IGetRecordsRequestBuilder.cs | 0 .../Get}/IQueryRecordsByAppPagedRequestBuilder.cs | 0 Onspring.API.SDK/Models/Fluent/OnspringRequest.cs | 5 +++++ .../{ => Records/Get}/GetRecordByIdRequestBuilder.cs | 0 .../Get}/GetRecordByIdRequestBuilderOptions.cs | 0 .../Get}/GetRecordsByAppPagedRequestBuilder.cs | 0 .../Get}/GetRecordsByAppPagedRequestBuilderOptions.cs | 0 .../{ => Records/Get}/GetRecordsByAppRequestBuilder.cs | 0 .../{ => Records/Get}/GetRecordsByIdsRequestBuilder.cs | 0 .../Get}/GetRecordsByIdsRequestBuilderOptions.cs | 0 .../Fluent/{ => Records/Get}/GetRecordsRequestBuilder.cs | 0 17 files changed, 13 insertions(+) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs rename Onspring.API.SDK/Interfaces/Fluent/{ => Records/Get}/IGetRecordByIdRequestBuilder.cs (100%) rename Onspring.API.SDK/Interfaces/Fluent/{ => Records/Get}/IGetRecordsByAppPagedRequestBuilder.cs (100%) rename Onspring.API.SDK/Interfaces/Fluent/{ => Records/Get}/IGetRecordsByAppRequestBuilder.cs (100%) rename Onspring.API.SDK/Interfaces/Fluent/{ => Records/Get}/IGetRecordsByIdsRequestBuilder.cs (100%) rename Onspring.API.SDK/Interfaces/Fluent/{ => Records/Get}/IGetRecordsRequestBuilder.cs (100%) rename Onspring.API.SDK/Interfaces/Fluent/{ => Records/Get}/IQueryRecordsByAppPagedRequestBuilder.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/GetRecordByIdRequestBuilder.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/GetRecordByIdRequestBuilderOptions.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/GetRecordsByAppPagedRequestBuilder.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/GetRecordsByAppPagedRequestBuilderOptions.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/GetRecordsByAppRequestBuilder.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/GetRecordsByIdsRequestBuilder.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/GetRecordsByIdsRequestBuilderOptions.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/GetRecordsRequestBuilder.cs (100%) diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index 60d44da..d88ce14 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -3,5 +3,6 @@ namespace Onspring.API.SDK.Interfaces.Fluent public interface IOnspringRequest { IGetRecordsRequestBuilder ToGetRecords(); + IDeleteRecordsRequestBuilder ToDeleteRecords(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs new file mode 100644 index 0000000..2e86f16 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteRecordsRequestBuilder + { + + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/IGetRecordByIdRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppPagedRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByAppRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/IGetRecordsByIdsRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/IGetRecordsRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/IQueryRecordsByAppPagedRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index fcdaf9c..3ec6013 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -11,6 +11,11 @@ internal OnspringRequest(IOnspringClient client) _client = client; } + public IDeleteRecordsRequestBuilder ToDeleteRecords() + { + throw new NotImplementedException(); + } + public IGetRecordsRequestBuilder ToGetRecords() { return new GetRecordsRequestBuilder(_client); diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/GetRecordByIdRequestBuilderOptions.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/GetRecordsByAppPagedRequestBuilderOptions.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/GetRecordsByAppRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/GetRecordsByIdsRequestBuilderOptions.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs diff --git a/Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/GetRecordsRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsRequestBuilder.cs From 51b0951abb235acb79897a8c58f648cbfa85a9d2 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 21:24:04 -0500 Subject: [PATCH 060/168] feat: add models and interfaces for deleting records by id and ids --- Onspring.API.SDK/IOnspringClient.cs | 7 ++-- .../Delete/IDeleteRecordByIdRequestBuilder.cs | 12 +++++++ .../IDeleteRecordsByAppRequestBuilder.cs | 12 +++++++ .../IDeleteRecordsByIdsRequestBuilder.cs | 14 ++++++++ .../Delete/IDeleteRecordsRequestBuilder.cs | 2 +- .../Models/Fluent/OnspringRequest.cs | 2 +- .../Delete/DeleteRecordByIdRequestBuilder.cs | 24 +++++++++++++ .../DeleteRecordsByAppRequestBuilder.cs | 27 +++++++++++++++ .../DeleteRecordsByIdsRequestBuilder.cs | 34 +++++++++++++++++++ .../Delete/DeleteRecordsRequestBuilder.cs | 19 +++++++++++ Onspring.API.SDK/OnspringClient.cs | 7 ++-- 11 files changed, 150 insertions(+), 10 deletions(-) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index 026564d..b308219 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -1,4 +1,5 @@ using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; using System; @@ -13,10 +14,10 @@ namespace Onspring.API.SDK public interface IOnspringClient { /// - /// Creates a new Onspring request which exposes a fluent interface for making a request to the Onspring API. + /// Creates a new Onspring Request which exposes a fluent interface for making a request to the Onspring API. /// - /// An instance of . - OnspringRequest CreateRequest(); + /// An instance that implements the interface. + IOnspringRequest CreateRequest(); /// /// Determines if the API is reachable. diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs new file mode 100644 index 0000000..1b3b2a1 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteRecordByIdRequestBuilder + { + int AppId { get; } + int RecordId { get; } + Task SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs new file mode 100644 index 0000000..9e0b776 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteRecordsByAppRequestBuilder + { + int AppId { get; } + IDeleteRecordByIdRequestBuilder WithId(int recordId); + IDeleteRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs new file mode 100644 index 0000000..cbf3811 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteRecordsByIdsRequestBuilder + { + int AppId { get; } + IEnumerable RecordIds { get; } + Task SendAsync(); + + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs index 2e86f16..e87c4f9 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs @@ -2,6 +2,6 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IDeleteRecordsRequestBuilder { - + IDeleteRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 3ec6013..0381bb1 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -13,7 +13,7 @@ internal OnspringRequest(IOnspringClient client) public IDeleteRecordsRequestBuilder ToDeleteRecords() { - throw new NotImplementedException(); + return new DeleteRecordsRequestBuilder(_client); } public IGetRecordsRequestBuilder ToGetRecords() diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs new file mode 100644 index 0000000..034d7f5 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs @@ -0,0 +1,24 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class DeleteRecordByIdRequestBuilder : IDeleteRecordByIdRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + public int RecordId { get; private set; } + + internal DeleteRecordByIdRequestBuilder(IOnspringClient client, int appId, int recordId) + { + _client = client; + AppId = appId; + RecordId = recordId; + } + + public async Task SendAsync() + { + return await _client.DeleteRecordAsync(AppId, RecordId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs new file mode 100644 index 0000000..71f527f --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class DeleteRecordsByAppRequestBuilder : IDeleteRecordsByAppRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + + internal DeleteRecordsByAppRequestBuilder(IOnspringClient client, int appId) + { + _client = client; + AppId = appId; + } + + public IDeleteRecordByIdRequestBuilder WithId(int recordId) + { + return new DeleteRecordByIdRequestBuilder(_client, AppId, recordId); + } + + public IDeleteRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds) + { + return new DeleteRecordsByIdsRequestBuilder(_client, AppId, recordIds); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs new file mode 100644 index 0000000..d99df5a --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using System.Dynamic; +using System.Linq; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class DeleteRecordsByIdsRequestBuilder : IDeleteRecordsByIdsRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + public IEnumerable RecordIds { get; private set; } + + internal DeleteRecordsByIdsRequestBuilder(IOnspringClient client, int appId, IEnumerable recordIds) + { + _client = client; + AppId = appId; + RecordIds = recordIds; + } + + public async Task SendAsync() + { + return await _client.DeleteRecordsAsync( + new DeleteRecordsRequest + { + AppId = AppId, + RecordIds = RecordIds.ToList(), + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs new file mode 100644 index 0000000..9d2d0ad --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs @@ -0,0 +1,19 @@ +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class DeleteRecordsRequestBuilder : IDeleteRecordsRequestBuilder + { + private readonly IOnspringClient _client; + + public DeleteRecordsRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IDeleteRecordsByAppRequestBuilder FromApp(int appId) + { + return new DeleteRecordsByAppRequestBuilder(_client, appId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index caae960..cac431a 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -75,11 +75,8 @@ public OnspringClient(OnspringClientConfiguration clientConfig) // ------------------------------------ Fluent Interface ------------------------------------ - /// - /// Creates a new Onspring request which exposes a fluent interface for making a request to the Onspring API. - /// - /// An instance of . - public OnspringRequest CreateRequest() + /// + public IOnspringRequest CreateRequest() { return new OnspringRequest(this); } From cc73a72f570fa99fa09299df668c045e2393f13f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 21:47:45 -0500 Subject: [PATCH 061/168] tests: organize test classes --- .../Fluent/{ => Records/Get}/GetRecordByIdRequestBuilderTests.cs | 0 .../{ => Records/Get}/GetRecordsByAppPagedRequestBuilderTests.cs | 0 .../{ => Records/Get}/GetRecordsByAppRequestBuilderTests.cs | 0 .../{ => Records/Get}/GetRecordsByIdsRequestBuilderTests.cs | 0 .../Fluent/{ => Records/Get}/GetRecordsRequestBuilderTests.cs | 0 .../Tests/Unit/Fluent/{ => Records/Get}/OnspringRequestTests.cs | 0 .../Get}/QueryRecordsByAppPagedRequestBuilderTests.cs | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/{ => Records/Get}/GetRecordByIdRequestBuilderTests.cs (100%) rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/{ => Records/Get}/GetRecordsByAppPagedRequestBuilderTests.cs (100%) rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/{ => Records/Get}/GetRecordsByAppRequestBuilderTests.cs (100%) rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/{ => Records/Get}/GetRecordsByIdsRequestBuilderTests.cs (100%) rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/{ => Records/Get}/GetRecordsRequestBuilderTests.cs (100%) rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/{ => Records/Get}/OnspringRequestTests.cs (100%) rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/{ => Records/Get}/QueryRecordsByAppPagedRequestBuilderTests.cs (100%) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs similarity index 100% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordByIdRequestBuilderTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs similarity index 100% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppPagedRequestBuilderTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs similarity index 100% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByAppRequestBuilderTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs similarity index 100% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsByIdsRequestBuilderTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs similarity index 100% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/GetRecordsRequestBuilderTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs similarity index 100% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/QueryRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs similarity index 100% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/QueryRecordsByAppPagedRequestBuilderTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs From 0c8eb0bab5fa841a3e8a36a8a34eebc39cd25f4a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 21:57:59 -0500 Subject: [PATCH 062/168] tests: stub out delete tests --- .../DeleteRecordByIdRequestBuilderTests.cs | 23 ++++++++++++++ .../DeleteRecordsByAppRequestBuilderTests.cs | 23 ++++++++++++++ .../DeleteRecordsByIdsRequestBuilderTests.cs | 23 ++++++++++++++ .../DeleteRecordsRequestBuilderTests.cs | 30 +++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs new file mode 100644 index 0000000..ec97c25 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs @@ -0,0 +1,23 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class DeleteRecordByIdRequestBuilderTests + { + private static IOnspringClient _client; + private static DeleteRecordByIdRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new DeleteRecordByIdRequestBuilder(_client, 1, 1); + } + + // TODO: Write tests + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs new file mode 100644 index 0000000..cbaa62b --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs @@ -0,0 +1,23 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class DeleteRecordsByAppRequestBuilderTests + { + private static IOnspringClient _client; + private static DeleteRecordsByAppRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new DeleteRecordsByAppRequestBuilder(_client, 1); + } + + // TODO: Write tests + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs new file mode 100644 index 0000000..f6012fd --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs @@ -0,0 +1,23 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class DeleteRecordsByIdsRequestBuilderTests + { + private static IOnspringClient _client; + private static DeleteRecordsByIdsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new DeleteRecordsByIdsRequestBuilder(_client, 1, new[] { 1, 2, 3 }); + } + + // TODO: Write tests + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs new file mode 100644 index 0000000..5a22701 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs @@ -0,0 +1,30 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class DeleteRecordsRequestBuilderTests + { + private static DeleteRecordsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var apiClientMock = Substitute.For(); + _builder = new DeleteRecordsRequestBuilder(apiClientMock); + } + + [TestMethod] + public void FromApp_WhenCalled_ShouldReturnADeleteRecordsByAppRequestBuilderInstanceWithAppIdSetToCorrectValue() + { + var appId = 1; + var builder = _builder.FromApp(appId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(appId, builder.AppId); + } + } +} \ No newline at end of file From 3f595ac9914fcb6cfdbf602ddaf1b225cf79a1fe Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 19 Sep 2023 22:06:24 -0500 Subject: [PATCH 063/168] chore: update vscode extenions --- .vscode/extensions.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 6b35d50..d7886b3 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,7 +4,6 @@ "formulahendry.dotnet-test-explorer", "EditorConfig.EditorConfig", "oderwat.indent-rainbow", - "aliasadidev.nugetpackagemanagergui", - "github.vscode-github-actions" + "aliasadidev.nugetpackagemanagergui" ] } From 81395ce58c76c72858662841c98bcda1f85ef650 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Wed, 20 Sep 2023 17:37:37 -0500 Subject: [PATCH 064/168] chore: fix generatehtmlcoveragereport target --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index 26372b6..efad52a 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -33,7 +33,7 @@ opencover - + From edeb69caa6a3e2f7b9041f75fa6f74c832013b25 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Wed, 20 Sep 2023 20:54:30 -0500 Subject: [PATCH 065/168] tests: add tests for delete records builders --- .../DeleteRecordByIdRequestBuilderTests.cs | 29 +++++++++++++++- .../DeleteRecordsByAppRequestBuilderTests.cs | 34 ++++++++++++++++++- .../DeleteRecordsByIdsRequestBuilderTests.cs | 28 ++++++++++++++- 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs index ec97c25..9852924 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs @@ -1,6 +1,8 @@ using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -18,6 +20,31 @@ public static void ClassInit(TestContext testContext) _builder = new DeleteRecordByIdRequestBuilder(_client, 1, 1); } - // TODO: Write tests + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var appId = 1; + var recordId = 1; + var builder = new DeleteRecordByIdRequestBuilder(_client, appId, recordId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(appId, builder.AppId); + Assert.AreEqual(recordId, builder.RecordId); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse(); + + _client + .DeleteRecordAsync(Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs index cbaa62b..ba28487 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs @@ -18,6 +18,38 @@ public static void ClassInit(TestContext testContext) _builder = new DeleteRecordsByAppRequestBuilder(_client, 1); } - // TODO: Write tests + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var appId = 1; + var builder = new DeleteRecordsByAppRequestBuilder(_client, appId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(appId, builder.AppId); + } + + [TestMethod] + public void WithId_WhenCalled_ItShouldReturnCorrectBuilderInstanceWithPropertiesSet() + { + var recordId = 1; + + var builder = _builder.WithId(recordId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_builder.AppId, builder.AppId); + Assert.AreEqual(recordId, builder.RecordId); + } + + [TestMethod] + public void WithIds_WhenCalled_ItShouldReturnCorrectBuilderInstanceWithPropertiesSet() + { + var recordIds = new[] { 1, 2, 3 }; + + var builder = _builder.WithIds(recordIds); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_builder.AppId, builder.AppId); + Assert.AreEqual(recordIds, builder.RecordIds); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs index f6012fd..7ce84fb 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs @@ -1,6 +1,8 @@ using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -18,6 +20,30 @@ public static void ClassInit(TestContext testContext) _builder = new DeleteRecordsByIdsRequestBuilder(_client, 1, new[] { 1, 2, 3 }); } - // TODO: Write tests + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var appId = 1; + var recordIds = new[] { 1, 2, 3 }; + var builder = new DeleteRecordsByIdsRequestBuilder(_client, appId, recordIds); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(appId, builder.AppId); + Assert.AreEqual(recordIds, builder.RecordIds); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse(); + + _client + .DeleteRecordsAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } } } \ No newline at end of file From 26573ec79cb4636e9306855ca888837aa044c6bb Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Wed, 20 Sep 2023 21:00:06 -0500 Subject: [PATCH 066/168] tests: add integration tests for deleting records fluently --- .../Fluent/OnspringClientRecordsTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs index b418083..a0de017 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs @@ -174,5 +174,31 @@ public async Task QueryRecords_UsingOptions() AssertHelper.AssertSuccess(apiResponse); AssertHelper.AssertCasting(apiResponse.Value.Items); } + + [TestMethod] + public async Task DeleteRecord() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToDeleteRecords() + .FromApp(1) + .WithId(1) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task DeleteRecords() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToDeleteRecords() + .FromApp(1) + .WithIds(new[] { 1, 2, 3 }) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } } } \ No newline at end of file From d0907f57b23e3c41703e0d9bc7d9fbd623fc545c Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 21 Sep 2023 19:07:05 -0500 Subject: [PATCH 067/168] feat: add fluent interface for saving record --- .../Fluent/OnspringClientRecordsTests.cs | 32 +++++++ .../Save/SaveRecordRequestBuilderTests.cs | 83 +++++++++++++++++++ .../Interfaces/Fluent/IOnspringRequest.cs | 1 + .../Save/ISaveRecordByIdRequestBuilder.cs | 13 +++ ...ISaveRecordByIdWithValuesRequestBuilder.cs | 14 ++++ .../Save/ISaveRecordInAppRequestBuilder.cs | 8 ++ .../Records/Save/ISaveRecordRequestBuilder.cs | 7 ++ .../Models/Fluent/OnspringRequest.cs | 5 ++ .../Delete/DeleteRecordsRequestBuilder.cs | 2 +- .../Records/Save/SaveRecordRequestBuilder.cs | 58 +++++++++++++ 10 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Save/SaveRecordRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordInAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs index a0de017..e0d573f 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs @@ -200,5 +200,37 @@ public async Task DeleteRecords() AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task AddRecord() + { + var record = TestDataFactory.GetFullyFilledOutRecord(_appIdWithRecords, 1); + + var apiResponse = await _apiClient + .CreateRequest() + .ToSaveRecord() + .InApp(record.AppId) + .WithId(null) + .WithValues(record.FieldData) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task UpdateRecord() + { + var record = TestDataFactory.GetFullyFilledOutRecord(_appIdWithRecords, 1); + + var apiResponse = await _apiClient + .CreateRequest() + .ToSaveRecord() + .InApp(record.AppId) + .WithId(record.RecordId) + .WithValues(record.FieldData) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Save/SaveRecordRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Save/SaveRecordRequestBuilderTests.cs new file mode 100644 index 0000000..690320f --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Save/SaveRecordRequestBuilderTests.cs @@ -0,0 +1,83 @@ +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class SaveRecordRequestBuilderTests + { + private static IOnspringClient _client; + private static SaveRecordRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new SaveRecordRequestBuilder(_client); + } + + [TestMethod] + public void InApp_WhenCalled_ItShouldSetAppId() + { + var appId = 1; + + _builder.InApp(appId); + + Assert.AreEqual(appId, _builder.AppId); + } + + [TestMethod] + public void WithId_WhenCalledWithNull_ItShouldSetRecordId() + { + int? recordId = null; + + _builder.WithId(recordId); + + Assert.AreEqual(recordId, _builder.RecordId); + } + + [TestMethod] + public void WithId_WhenCalledWithIdValue_ItShouldSetRecordId() + { + int? recordId = 1; + + _builder.WithId(recordId); + + Assert.AreEqual(recordId, _builder.RecordId); + } + + [TestMethod] + public void WithValues_WhenCalled_ItShouldSetValues() + { + var values = new[] { new RecordFieldValue() }; + + _builder.WithValues(values); + + Assert.AreEqual(values, _builder.Values); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.Created, + Value = new SaveRecordResponse(), + }; + + _client + .SaveRecordAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index d88ce14..87e0f28 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -4,5 +4,6 @@ public interface IOnspringRequest { IGetRecordsRequestBuilder ToGetRecords(); IDeleteRecordsRequestBuilder ToDeleteRecords(); + ISaveRecordRequestBuilder ToSaveRecord(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs new file mode 100644 index 0000000..1fb7e43 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface ISaveRecordByIdRequestBuilder + { + int AppId { get; } + int? RecordId { get; } + ISaveRecordByIdWithValuesRequestBuilder WithValues(IEnumerable values); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs new file mode 100644 index 0000000..7279ec8 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface ISaveRecordByIdWithValuesRequestBuilder + { + int AppId { get; } + int? RecordId { get; } + IEnumerable Values { get; } + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordInAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordInAppRequestBuilder.cs new file mode 100644 index 0000000..48e95c6 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordInAppRequestBuilder.cs @@ -0,0 +1,8 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface ISaveRecordInAppRequestBuilder + { + int AppId { get; } + ISaveRecordByIdRequestBuilder WithId(int? recordId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordRequestBuilder.cs new file mode 100644 index 0000000..18486e6 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface ISaveRecordRequestBuilder + { + ISaveRecordInAppRequestBuilder InApp(int appId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 0381bb1..b662299 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -20,5 +20,10 @@ public IGetRecordsRequestBuilder ToGetRecords() { return new GetRecordsRequestBuilder(_client); } + + public ISaveRecordRequestBuilder ToSaveRecord() + { + return new SaveRecordRequestBuilder(_client); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs index 9d2d0ad..693d10f 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs @@ -6,7 +6,7 @@ public class DeleteRecordsRequestBuilder : IDeleteRecordsRequestBuilder { private readonly IOnspringClient _client; - public DeleteRecordsRequestBuilder(IOnspringClient client) + internal DeleteRecordsRequestBuilder(IOnspringClient client) { _client = client; } diff --git a/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs new file mode 100644 index 0000000..bffef42 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class SaveRecordRequestBuilder : + ISaveRecordRequestBuilder, + ISaveRecordInAppRequestBuilder, + ISaveRecordByIdRequestBuilder, + ISaveRecordByIdWithValuesRequestBuilder + { + private readonly IOnspringClient _client; + + internal SaveRecordRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public int AppId { get; private set; } + + public int? RecordId { get; private set; } + + public IEnumerable Values { get; private set; } + + public ISaveRecordInAppRequestBuilder InApp(int appId) + { + AppId = appId; + return this; + } + + public ISaveRecordByIdRequestBuilder WithId(int? recordId) + { + RecordId = recordId; + return this; + } + + public ISaveRecordByIdWithValuesRequestBuilder WithValues(IEnumerable values) + { + Values = values; + return this; + } + + public async Task> SendAsync() + { + return await _client.SaveRecordAsync( + new ResultRecord + { + AppId = AppId, + RecordId = RecordId ?? 0, + FieldData = Values.ToList(), + } + ); + } + } +} \ No newline at end of file From bb8b85a85d79293b7c69b1961f4ac9da293c494f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 21 Sep 2023 19:22:25 -0500 Subject: [PATCH 068/168] feat: add fluent interface for checking connection --- .../Fluent/OnspringClientDiagnosticTests.cs | 34 +++++++++++++++++++ .../Ping/ConnectionRequestBuilderTests.cs | 32 +++++++++++++++++ .../Interfaces/Fluent/IOnspringRequest.cs | 1 + .../Fluent/Ping/IConnectionRequestBuilder.cs | 9 +++++ .../Models/Fluent/OnspringRequest.cs | 9 +++-- .../Fluent/Ping/ConnectionRequestBuilder.cs | 21 ++++++++++++ 6 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientDiagnosticTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientDiagnosticTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientDiagnosticTests.cs new file mode 100644 index 0000000..2b452d2 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientDiagnosticTests.cs @@ -0,0 +1,34 @@ +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Tests.Infrastructure; +using Onspring.API.SDK.Tests.Infrastructure.Http; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringClientDiagnosticTests + { + private static OnspringClient _apiClient; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var testConfiguration = TestConfiguration.LoadFromContext(testContext); + var httpClient = HttpClientFactory.GetHttpClient(testConfiguration); + + _apiClient = new OnspringClient(testConfiguration.ApiKey, httpClient); + } + + [TestMethod] + public async Task CanConnectAsync() + { + var canConnect = await _apiClient + .CreateRequest() + .ToCheckConnection() + .SendAsync(); + + Assert.IsTrue(canConnect, "Unable to connect"); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs new file mode 100644 index 0000000..9023200 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs @@ -0,0 +1,32 @@ +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + public class ConnectionRequestBuilderTests + { + private static IOnspringClient _client; + private static ConnectionRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new ConnectionRequestBuilder(_client); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnBooleanConnectionIndicator() + { + var canConnect = false; + + _client.CanConnectAsync().Returns(canConnect); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(canConnect, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index 87e0f28..a9c23f6 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -2,6 +2,7 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IOnspringRequest { + IConnectionRequestBuilder ToCheckConnection(); IGetRecordsRequestBuilder ToGetRecords(); IDeleteRecordsRequestBuilder ToDeleteRecords(); ISaveRecordRequestBuilder ToSaveRecord(); diff --git a/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs new file mode 100644 index 0000000..5ce466d --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IConnectionRequestBuilder + { + Task SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index b662299..98c4110 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -11,9 +11,9 @@ internal OnspringRequest(IOnspringClient client) _client = client; } - public IDeleteRecordsRequestBuilder ToDeleteRecords() + public IConnectionRequestBuilder ToCheckConnection() { - return new DeleteRecordsRequestBuilder(_client); + return new ConnectionRequestBuilder(_client); } public IGetRecordsRequestBuilder ToGetRecords() @@ -25,5 +25,10 @@ public ISaveRecordRequestBuilder ToSaveRecord() { return new SaveRecordRequestBuilder(_client); } + + public IDeleteRecordsRequestBuilder ToDeleteRecords() + { + return new DeleteRecordsRequestBuilder(_client); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs new file mode 100644 index 0000000..4eb5a77 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs @@ -0,0 +1,21 @@ +using System.Net.Http; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class ConnectionRequestBuilder : IConnectionRequestBuilder + { + private readonly IOnspringClient _client; + + internal ConnectionRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public async Task SendAsync() + { + return await _client.CanConnectAsync(); + } + } +} \ No newline at end of file From 60077ea62034a559ce04742d0d103f53eb56f811 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:49:19 -0500 Subject: [PATCH 069/168] chore: update settings --- .vscode/settings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 70fd490..bdf1da0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,3 @@ { - "dotnet-test-explorer.testArguments": "--settings runsettings/internal.runsettings", - "omnisharp.testRunSettings": "C:\\Users\\sfree\\software_projects\\onspring-api-sdk\\Onspring.API.SDK.Tests\\bin\\Debug\\net7\\runsettings\\internal.runsettings" + "dotnet-test-explorer.testArguments": "--settings runsettings/internal.runsettings" } From f445d6189708c780cff8b70837ef5604239638d2 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:53:02 -0500 Subject: [PATCH 070/168] feat: begin adding get report fluent interface --- .../Interfaces/Fluent/IOnspringRequest.cs | 2 ++ .../Reports/IGetReportByIdRequestBuilder.cs | 11 ++++++++++ .../Reports/IGetReportDataRequestBuilder.cs | 7 +++++++ .../Reports/IGetReportsByAppRequestBuilder.cs | 21 +++++++++++++++++++ .../QueryRecordsByAppPagedRequestBuilder.cs | 0 ...yRecordsByAppPagedRequestBuilderOptions.cs | 0 .../GetReportsByAppRequestBuilderOptions.cs | 11 ++++++++++ 7 files changed, 52 insertions(+) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/QueryRecordsByAppPagedRequestBuilder.cs (100%) rename Onspring.API.SDK/Models/Fluent/{ => Records/Get}/QueryRecordsByAppPagedRequestBuilderOptions.cs (100%) create mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index a9c23f6..89dae0a 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -6,5 +6,7 @@ public interface IOnspringRequest IGetRecordsRequestBuilder ToGetRecords(); IDeleteRecordsRequestBuilder ToDeleteRecords(); ISaveRecordRequestBuilder ToSaveRecord(); + IGetReportsRequestBuilder ToGetReports(); + IGetReportDataRequestBuilder ToGetReportData(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportByIdRequestBuilder.cs new file mode 100644 index 0000000..7d02629 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportByIdRequestBuilder.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetReportByIdRequestBuilder + { + int ReportId { get; } + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs new file mode 100644 index 0000000..166d656 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetReportDataRequestBuilder + { + + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs new file mode 100644 index 0000000..a0c3e4f --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetReportsByAppRequestBuilder + { + int AppId { get; } + int PageNumber { get; } + int PageSize { get; } + DataFormat Format { get; } + IGetReportsByAppRequestBuilder ForPageNumber(int pageNumber); + IGetReportsByAppRequestBuilder WithPageSize(int pageNumber); + IGetReportsByAppRequestBuilder WithFormat(DataFormat format); + Task> SendAsync(); + Task> SendAsync(Action options); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs diff --git a/Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/QueryRecordsByAppPagedRequestBuilderOptions.cs rename to Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs new file mode 100644 index 0000000..3c21340 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs @@ -0,0 +1,11 @@ +using Onspring.API.SDK.Enums; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetReportsByAppRequestBuilderOptions + { + public int PageNumber { get; set; } + public int PageSize { get; set; } + public DataFormat Format { get; set; } + } +} \ No newline at end of file From b2bd365ebe110c539990fd4f6e422f560aa58760 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 09:37:05 -0500 Subject: [PATCH 071/168] tests: assert on return interface types --- .../DeleteRecordByIdRequestBuilderTests.cs | 3 +- .../DeleteRecordsByAppRequestBuilderTests.cs | 7 +-- .../DeleteRecordsByIdsRequestBuilderTests.cs | 3 +- .../DeleteRecordsRequestBuilderTests.cs | 3 +- .../Get/GetRecordByIdRequestBuilderTests.cs | 3 +- ...GetRecordsByAppPagedRequestBuilderTests.cs | 3 +- .../Get/GetRecordsByAppRequestBuilderTests.cs | 11 ++--- .../Get/GetRecordsByIdsRequestBuilderTests.cs | 3 +- .../Get/GetRecordsRequestBuilderTests.cs | 3 +- .../Records/Get/OnspringRequestTests.cs | 3 +- .../Reports/GetReportRequestBuilderTests.cs | 28 ++++++++++++ .../Interfaces/Fluent/IOnspringRequest.cs | 4 +- .../Reports/IGetReportByIdRequestBuilder.cs | 11 ----- .../Reports/IGetReportDataRequestBuilder.cs | 14 +++++- .../Reports/IGetReportRequestBuilder.cs | 7 +++ .../Reports/IGetReportsByAppRequestBuilder.cs | 2 - .../Models/Fluent/OnspringRequest.cs | 10 +++++ .../Records/Save/SaveRecordRequestBuilder.cs | 6 +-- .../Reports/GetReportDataRequestBuilder.cs | 45 +++++++++++++++++++ .../GetReportDataRequestBuilderOptions.cs | 10 +++++ .../Fluent/Reports/GetReportRequestBuilder.cs | 19 ++++++++ .../Reports/GetReportsByAppRequestBuilder.cs | 45 +++++++++++++++++++ .../GetReportsByAppRequestBuilderOptions.cs | 5 +-- 23 files changed, 209 insertions(+), 39 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs delete mode 100644 Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilderOptions.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs index 9852924..03528a6 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; @@ -27,7 +28,7 @@ public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() var recordId = 1; var builder = new DeleteRecordByIdRequestBuilder(_client, appId, recordId); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(appId, builder.AppId); Assert.AreEqual(recordId, builder.RecordId); } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs index ba28487..88e5766 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -24,7 +25,7 @@ public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() var appId = 1; var builder = new DeleteRecordsByAppRequestBuilder(_client, appId); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(appId, builder.AppId); } @@ -35,7 +36,7 @@ public void WithId_WhenCalled_ItShouldReturnCorrectBuilderInstanceWithProperties var builder = _builder.WithId(recordId); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(_builder.AppId, builder.AppId); Assert.AreEqual(recordId, builder.RecordId); } @@ -47,7 +48,7 @@ public void WithIds_WhenCalled_ItShouldReturnCorrectBuilderInstanceWithPropertie var builder = _builder.WithIds(recordIds); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(_builder.AppId, builder.AppId); Assert.AreEqual(recordIds, builder.RecordIds); } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs index 7ce84fb..84ca8e4 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; @@ -27,7 +28,7 @@ public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() var recordIds = new[] { 1, 2, 3 }; var builder = new DeleteRecordsByIdsRequestBuilder(_client, appId, recordIds); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(appId, builder.AppId); Assert.AreEqual(recordIds, builder.RecordIds); } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs index 5a22701..f9ed8a2 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -23,7 +24,7 @@ public void FromApp_WhenCalled_ShouldReturnADeleteRecordsByAppRequestBuilderInst var appId = 1; var builder = _builder.FromApp(appId); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(appId, builder.AppId); } } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs index d8b9ddd..369f5db 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs @@ -5,6 +5,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; @@ -30,7 +31,7 @@ public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() var recordId = 1; var builder = new GetRecordByIdRequestBuilder(_client, appId, recordId); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(appId, builder.AppId); Assert.AreEqual(recordId, builder.RecordId); Assert.AreEqual(Enumerable.Empty(), builder.FieldIds); diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs index ea77d9b..18ae438 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs @@ -5,6 +5,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; @@ -30,7 +31,7 @@ public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() var pageNumber = 1; var builder = new GetRecordsByAppPagedRequestBuilder(_client, appId, pageNumber); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(appId, builder.AppId); Assert.AreEqual(pageNumber, builder.PageNumber); Assert.AreEqual(Enumerable.Empty(), builder.FieldIds); diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs index 55a3b3c..b70ecf7 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs @@ -2,6 +2,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; @@ -36,7 +37,7 @@ public void ForPage_WhenCalled_ReturnsInstanceOfPagedAppBuilderWithPropetiesSet( var pagedBuilder = builder.ForPage(pageNumber); - Assert.IsInstanceOfType(pagedBuilder); + Assert.IsInstanceOfType(pagedBuilder); Assert.AreEqual(appId, pagedBuilder.AppId); Assert.AreEqual(pageNumber, pagedBuilder.PageNumber); } @@ -50,7 +51,7 @@ public void WithId_WhenCalled_ReturnsRecordByIdBuilderWithPropertiesSet() var recordByIdBuilder = builder.WithId(recordId); - Assert.IsInstanceOfType(recordByIdBuilder); + Assert.IsInstanceOfType(recordByIdBuilder); Assert.AreEqual(appId, recordByIdBuilder.AppId); Assert.AreEqual(recordId, recordByIdBuilder.RecordId); } @@ -64,7 +65,7 @@ public void WithIds_WhenCalled_ReturnsRecordsByIdsBuilderWithPropertiesSet() var recordsByIdsBuilder = builder.WithIds(recordIds); - Assert.IsInstanceOfType(recordsByIdsBuilder); + Assert.IsInstanceOfType(recordsByIdsBuilder); Assert.AreEqual(appId, recordsByIdsBuilder.AppId); Assert.AreEqual(recordIds, recordsByIdsBuilder.RecordIds); } @@ -78,7 +79,7 @@ public void WithFilter_WhenCalledWithFilterString_ReturnsQueryRecordsBuilderWith var queryRecordsBuilder = builder.WithFilter(filter.ToString()); - Assert.IsInstanceOfType(queryRecordsBuilder); + Assert.IsInstanceOfType(queryRecordsBuilder); Assert.AreEqual(appId, queryRecordsBuilder.AppId); Assert.AreEqual(filter.ToString(), queryRecordsBuilder.Filter); } @@ -97,7 +98,7 @@ public void WithFilter_WhenCalledWithFilterAction_ReturnsQueryRecordsBuilderWith f.Value = filter.Value; }); - Assert.IsInstanceOfType(queryRecordsBuilder); + Assert.IsInstanceOfType(queryRecordsBuilder); Assert.AreEqual(appId, queryRecordsBuilder.AppId); Assert.AreEqual(filter.ToString(), queryRecordsBuilder.Filter); } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs index 6b263ec..5f42297 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs @@ -5,6 +5,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; @@ -30,7 +31,7 @@ public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() var recordIds = new[] { 1, 2, 3 }; var builder = new GetRecordsByIdsRequestBuilder(_client, appId, recordIds); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(appId, builder.AppId); Assert.AreEqual(recordIds, builder.RecordIds); Assert.AreEqual(Enumerable.Empty(), builder.FieldIds); diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs index ddbaa94..4aeaf84 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -23,7 +24,7 @@ public void FromApp_WhenCalled_ShouldReturnAGetRecordsByAppRequestBuilderInstanc var appId = 1; var builder = _builder.FromApp(appId); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); Assert.AreEqual(appId, builder.AppId); } } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs index 4f348bb..24cead3 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -22,7 +23,7 @@ public void ToGetRecords_WhenCalled_ShouldReturnAGetRecordsRequestBuilderInstanc { var builder = _onspringRequest.ToGetRecords(); - Assert.IsInstanceOfType(builder); + Assert.IsInstanceOfType(builder); } } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs new file mode 100644 index 0000000..0b25437 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs @@ -0,0 +1,28 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + public class GetReportRequestBuilderTests + { + private static IOnspringClient _client; + private static GetReportRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetReportRequestBuilder(_client); + } + + [TestMethod] + public void FromReport_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() + { + var result = _builder.FromReport(1); + + Assert.IsInstanceOfType(result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index 89dae0a..3b30a30 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -6,7 +6,7 @@ public interface IOnspringRequest IGetRecordsRequestBuilder ToGetRecords(); IDeleteRecordsRequestBuilder ToDeleteRecords(); ISaveRecordRequestBuilder ToSaveRecord(); - IGetReportsRequestBuilder ToGetReports(); - IGetReportDataRequestBuilder ToGetReportData(); + IGetReportsByAppRequestBuilder ToGetReports(); + IGetReportRequestBuilder ToGetReportData(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportByIdRequestBuilder.cs deleted file mode 100644 index 7d02629..0000000 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportByIdRequestBuilder.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Threading.Tasks; -using Onspring.API.SDK.Models; - -namespace Onspring.API.SDK.Interfaces.Fluent -{ - public interface IGetReportByIdRequestBuilder - { - int ReportId { get; } - Task> SendAsync(); - } -} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs index 166d656..41351e9 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs @@ -1,7 +1,19 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetReportDataRequestBuilder { - + int ReportId { get; } + DataFormat Format { get; } + ReportDataType DataType { get; } + IGetReportDataRequestBuilder WithFormat(DataFormat format); + IGetReportDataRequestBuilder WithDataType(ReportDataType dataType); + Task> SendAsync(); + Task> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportRequestBuilder.cs new file mode 100644 index 0000000..3477a23 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetReportRequestBuilder + { + IGetReportDataRequestBuilder FromReport(int reportId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs index a0c3e4f..492b1b3 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs @@ -11,10 +11,8 @@ public interface IGetReportsByAppRequestBuilder int AppId { get; } int PageNumber { get; } int PageSize { get; } - DataFormat Format { get; } IGetReportsByAppRequestBuilder ForPageNumber(int pageNumber); IGetReportsByAppRequestBuilder WithPageSize(int pageNumber); - IGetReportsByAppRequestBuilder WithFormat(DataFormat format); Task> SendAsync(); Task> SendAsync(Action options); } diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 98c4110..cc08113 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -30,5 +30,15 @@ public IDeleteRecordsRequestBuilder ToDeleteRecords() { return new DeleteRecordsRequestBuilder(_client); } + + public IGetReportsByAppRequestBuilder ToGetReports() + { + return new GetReportsByAppRequestBuilder(_client); + } + + public IGetReportRequestBuilder ToGetReportData() + { + return new GetReportRequestBuilder(_client); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs index bffef42..c0db865 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs @@ -13,16 +13,14 @@ public class SaveRecordRequestBuilder : ISaveRecordByIdWithValuesRequestBuilder { private readonly IOnspringClient _client; + public int AppId { get; private set; } + public int? RecordId { get; private set; } internal SaveRecordRequestBuilder(IOnspringClient client) { _client = client; } - public int AppId { get; private set; } - - public int? RecordId { get; private set; } - public IEnumerable Values { get; private set; } public ISaveRecordInAppRequestBuilder InApp(int appId) diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilder.cs new file mode 100644 index 0000000..f407bc0 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilder.cs @@ -0,0 +1,45 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetReportDataRequestBuilder : IGetReportDataRequestBuilder + { + private readonly IOnspringClient _client; + public int ReportId { get; private set; } + public DataFormat Format { get; private set; } = DataFormat.Raw; + public ReportDataType DataType { get; private set; } = ReportDataType.ReportData; + + internal GetReportDataRequestBuilder(IOnspringClient client, int reportId) + { + _client = client; + ReportId = reportId; + } + + public IGetReportDataRequestBuilder WithFormat(DataFormat format) + { + Format = format; + return this; + } + + public IGetReportDataRequestBuilder WithDataType(ReportDataType dataType) + { + DataType = dataType; + return this; + } + + public async Task> SendAsync() + { + return await _client.GetReportAsync(ReportId, DataType, Format); + } + + public async Task> SendAsync(Action options) + { + var opts = new GetReportDataRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetReportAsync(ReportId, opts.DataType, opts.Format); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilderOptions.cs new file mode 100644 index 0000000..d393e89 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilderOptions.cs @@ -0,0 +1,10 @@ +using Onspring.API.SDK.Enums; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetReportDataRequestBuilderOptions + { + public DataFormat Format { get; set; } = DataFormat.Raw; + public ReportDataType DataType { get; set; } = ReportDataType.ReportData; + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs new file mode 100644 index 0000000..338db92 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs @@ -0,0 +1,19 @@ +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetReportRequestBuilder : IGetReportRequestBuilder + { + private readonly IOnspringClient _client; + + internal GetReportRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetReportDataRequestBuilder FromReport(int reportId) + { + return new GetReportDataRequestBuilder(_client, reportId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilder.cs new file mode 100644 index 0000000..7174b35 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilder.cs @@ -0,0 +1,45 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetReportsByAppRequestBuilder : IGetReportsByAppRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + public int PageNumber { get; private set; } = 1; + public int PageSize { get; private set; } = 50; + + internal GetReportsByAppRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetReportsByAppRequestBuilder ForPageNumber(int pageNumber) + { + PageNumber = pageNumber; + return this; + } + + public IGetReportsByAppRequestBuilder WithPageSize(int pageNumber) + { + PageNumber = pageNumber; + return this; + } + + public async Task> SendAsync() + { + return await _client.GetReportsForAppAsync(AppId, new PagingRequest(PageNumber, PageSize)); + } + + public async Task> SendAsync(Action options) + { + var opts = new GetReportsByAppRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetReportsForAppAsync(AppId, new PagingRequest(opts.PageNumber, opts.PageSize)); + } + + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs index 3c21340..2cd92b8 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs @@ -4,8 +4,7 @@ namespace Onspring.API.SDK.Models.Fluent { public class GetReportsByAppRequestBuilderOptions { - public int PageNumber { get; set; } - public int PageSize { get; set; } - public DataFormat Format { get; set; } + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 50; } } \ No newline at end of file From fd3a9cb69849506c623a8f28220c586cf8ca2dd6 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:09:03 -0500 Subject: [PATCH 072/168] tests: write tests for query records builder --- ...eryRecordsByAppPagedRequestBuilderTests.cs | 104 +++++++++++++++++- .../QueryRecordsByAppPagedRequestBuilder.cs | 2 +- 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs index dd7b01a..692800d 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs @@ -1,6 +1,11 @@ using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -9,13 +14,110 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent public class QueryRecordsByAppPagedRequestBuilderTests { private static IOnspringClient _client; + private static QueryRecordsByAppPagedRequestBuilder _builder; [ClassInitialize] public static void ClassInit(TestContext testContext) { _client = Substitute.For(); + _builder = new QueryRecordsByAppPagedRequestBuilder(_client, 1, "filter"); } - // TODO: Write tests + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() + { + var appId = 1; + var filter = "filter"; + var builder = new QueryRecordsByAppPagedRequestBuilder(_client, appId, filter); + + Assert.AreEqual(appId, builder.AppId); + Assert.AreEqual(filter, builder.Filter); + Assert.AreEqual(1, builder.PageNumber); + Assert.AreEqual(50, builder.PageSize); + Assert.AreEqual(Enumerable.Empty(), builder.FieldIds); + Assert.AreEqual(DataFormat.Raw, builder.Format); + } + + [TestMethod] + public void ForPageNumber_WhenCalled_ItShouldSetPageNumberProperty() + { + var pageNumber = 2; + + _builder.ForPageNumber(pageNumber); + + Assert.AreEqual(pageNumber, _builder.PageNumber); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldSetPageSizeProperty() + { + var pageSize = 1; + + _builder.WithPageSize(pageSize); + + Assert.AreEqual(pageSize, _builder.PageSize); + } + + [TestMethod] + public void WithFieldIds_WhenCalled_ItShouldSetFieldIdsProperty() + { + var fieldIds = new int[] { 1, 2, 3 }; + + _builder.WithFieldIds(fieldIds); + + Assert.AreEqual(fieldIds, _builder.FieldIds); + } + + [TestMethod] + public void WithFormat_WhenCalled_ItShouldSetFormatProperty() + { + var format = DataFormat.Raw; + + _builder.WithFormat(format); + + Assert.AreEqual(format, _builder.Format); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetPagedRecordsResponse(), + }; + + _client + .QueryRecordsAsync(Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + + [TestMethod] + public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetPagedRecordsResponse(), + }; + + _client + .QueryRecordsAsync(Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(options => + { + options.PageNumber = 2; + options.PageSize = 100; + options.Format = DataFormat.Formatted; + options.FieldIds = new[] { 1 }; + }); + + Assert.AreEqual(apiResponse, result); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs index bb4e715..ab90181 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs @@ -32,7 +32,7 @@ public IQueryRecordsByAppPagedRequestBuilder ForPageNumber(int pageNumber) public IQueryRecordsByAppPagedRequestBuilder WithPageSize(int pageSize) { - PageNumber = pageSize; + PageSize = pageSize; return this; } From 22fa71bce02fa730478f2bc1419ce2fe7adcfbf4 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:11:36 -0500 Subject: [PATCH 073/168] tests: add GetReportRequestBuilder tests --- .../Fluent/Reports/GetReportRequestBuilderTests.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs index 0b25437..4fad648 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; @@ -20,9 +21,14 @@ public static void ClassInit(TestContext testContext) [TestMethod] public void FromReport_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() { - var result = _builder.FromReport(1); + var reportId = 1; - Assert.IsInstanceOfType(result); + var builder = _builder.FromReport(reportId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(reportId, builder.ReportId); + Assert.AreEqual(DataFormat.Raw, builder.Format); + Assert.AreEqual(ReportDataType.ReportData, builder.DataType); } } } \ No newline at end of file From ab3579332439290f935aa9ebbbbaa7f649b524e1 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:31:14 -0500 Subject: [PATCH 074/168] tests: add GetReportDataRequestBuilder tests --- .../GetReportDataRequestBuilderTests.cs | 120 ++++++++++++++++++ .../Reports/GetReportRequestBuilderTests.cs | 2 + 2 files changed, 122 insertions(+) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportDataRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportDataRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportDataRequestBuilderTests.cs new file mode 100644 index 0000000..8a8c0c1 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportDataRequestBuilderTests.cs @@ -0,0 +1,120 @@ +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using NSubstitute.ReceivedExtensions; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetReportDataRequestBuilderTests + { + private static readonly int _reportId = 1; + private static IOnspringClient _client; + private static GetReportDataRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetReportDataRequestBuilder(_client, _reportId); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() + { + var reportId = 1; + + var builder = new GetReportDataRequestBuilder(_client, reportId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(reportId, builder.ReportId); + Assert.AreEqual(DataFormat.Raw, builder.Format); + Assert.AreEqual(ReportDataType.ReportData, builder.DataType); + } + + [TestMethod] + public void WithFormat_WhenCalled_ItShouldSetFormatProperty() + { + var format = DataFormat.Formatted; + + _builder.WithFormat(format); + + Assert.AreEqual(format, _builder.Format); + } + + [TestMethod] + public void WithDataType_WhenCalled_ItShouldSetDataTypeProperty() + { + var dataType = ReportDataType.ChartData; + + _builder.WithDataType(dataType); + + Assert.AreEqual(dataType, _builder.DataType); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new ReportData(), + }; + + _client + .GetReportAsync( + Arg.Any(), + Arg.Any(), + Arg.Any() + ) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + + [TestMethod] + public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new ReportData(), + }; + + _client + .GetReportAsync( + Arg.Any(), + Arg.Any(), + Arg.Any() + ) + .Returns(apiResponse); + + var format = DataFormat.Formatted; + var dataType = ReportDataType.ChartData; + + var result = await _builder.SendAsync(options => + { + options.Format = format; + options.DataType = dataType; + }); + + Assert.AreEqual(apiResponse, result); + + await _client + .Received() + .GetReportAsync( + _reportId, + dataType, + format + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs index 4fad648..2a06c23 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; @@ -6,6 +7,7 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { + [TestClass, ExcludeFromCodeCoverage] public class GetReportRequestBuilderTests { private static IOnspringClient _client; From 7f553b86d32568613b9272b266a2e9f0d8e5779c Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:35:35 -0500 Subject: [PATCH 075/168] tests: add integration tests for getting report data with fluent interface --- .../Fluent/OnspringClientReportsTests.cs | 58 +++++++++++++++++++ .../Integration/OnspringClientReportsTests.cs | 1 - 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs new file mode 100644 index 0000000..acb74a2 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs @@ -0,0 +1,58 @@ +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Tests.Infrastructure; +using Onspring.API.SDK.Tests.Infrastructure.Helpers; +using Onspring.API.SDK.Tests.Infrastructure.Http; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringClientReportsTests + { + private const int _appIdWithReports = 1; + private const int _reportId = 1; + private static OnspringClient _apiClient; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var testConfiguration = TestConfiguration.LoadFromContext(testContext); + var httpClient = HttpClientFactory.GetHttpClient(testConfiguration); + + _apiClient = new OnspringClient(testConfiguration.ApiKey, httpClient); + } + + [TestMethod] + public async Task GetReportData() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetReportData() + .FromReport(_reportId) + .WithFormat(DataFormat.Formatted) + .WithDataType(ReportDataType.ChartData) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task GetReportData_WithOptions() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetReportData() + .FromReport(_reportId) + .SendAsync(options => + { + options.Format = DataFormat.Formatted; + options.DataType = ReportDataType.ChartData; + }); + + AssertHelper.AssertSuccess(apiResponse); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs index c488f4a..a63eb12 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs @@ -13,7 +13,6 @@ public class OnspringClientReportsTests { private const int _appIdWithReports = 1; private const int _reportId = 1; - private static OnspringClient _apiClient; [ClassInitialize] From 8a0c80a5226b32f2ba68f93a729a173dbefb0673 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:44:52 -0500 Subject: [PATCH 076/168] tests: update OnspringRequest tests --- .../Tests/Unit/Fluent/OnspringRequestTests.cs | 69 +++++++++++++++++++ .../Records/Get/OnspringRequestTests.cs | 29 -------- 2 files changed, 69 insertions(+), 29 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs delete mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs new file mode 100644 index 0000000..283e540 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs @@ -0,0 +1,69 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringRequestTests + { + private static OnspringRequest _onspringRequest; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var apiClientMock = Substitute.For(); + _onspringRequest = new OnspringRequest(apiClientMock); + } + + [TestMethod] + public void ToGetRecords_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _onspringRequest.ToGetRecords(); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void ToCheckConnection_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _onspringRequest.ToCheckConnection(); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void ToSaveRecord_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _onspringRequest.ToSaveRecord(); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void ToDeleteRecords_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _onspringRequest.ToDeleteRecords(); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void ToGetReports_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _onspringRequest.ToGetReports(); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void ToGetReportData_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _onspringRequest.ToGetReportData(); + + Assert.IsInstanceOfType(builder); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs deleted file mode 100644 index 24cead3..0000000 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/OnspringRequestTests.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NSubstitute; -using Onspring.API.SDK.Interfaces.Fluent; -using Onspring.API.SDK.Models.Fluent; - -namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent -{ - [TestClass, ExcludeFromCodeCoverage] - public class OnspringRequestTests - { - private static OnspringRequest _onspringRequest; - - [ClassInitialize] - public static void ClassInit(TestContext testContext) - { - var apiClientMock = Substitute.For(); - _onspringRequest = new OnspringRequest(apiClientMock); - } - - [TestMethod] - public void ToGetRecords_WhenCalled_ShouldReturnAGetRecordsRequestBuilderInstance() - { - var builder = _onspringRequest.ToGetRecords(); - - Assert.IsInstanceOfType(builder); - } - } -} \ No newline at end of file From 71a86a0e410d49db02b6d248c5d8564db6feca88 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:09:01 -0500 Subject: [PATCH 077/168] refactor: use single builder model for getting report --- .../GetReportDataRequestBuilderTests.cs | 120 ------------------ .../Reports/GetReportRequestBuilderTests.cs | 83 ++++++++++++ .../Reports/GetReportsRequestBuilderTests.cs | 22 ++++ .../Reports/IGetReportDataRequestBuilder.cs | 2 +- .../Reports/IGetReportsByAppRequestBuilder.cs | 3 +- .../Reports/IGetReportsRequestBuilder.cs | 7 + .../Models/Fluent/OnspringRequest.cs | 2 +- ...rOptions.cs => GetReportBuilderOptions.cs} | 2 +- .../Reports/GetReportDataRequestBuilder.cs | 45 ------- .../Fluent/Reports/GetReportRequestBuilder.cs | 35 ++++- ...Builder.cs => GetReportsRequestBuilder.cs} | 24 ++-- ....cs => GetReportsRequestBuilderOptions.cs} | 2 +- 12 files changed, 164 insertions(+), 183 deletions(-) delete mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportDataRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsRequestBuilder.cs rename Onspring.API.SDK/Models/Fluent/Reports/{GetReportDataRequestBuilderOptions.cs => GetReportBuilderOptions.cs} (79%) delete mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilder.cs rename Onspring.API.SDK/Models/Fluent/Reports/{GetReportsByAppRequestBuilder.cs => GetReportsRequestBuilder.cs} (61%) rename Onspring.API.SDK/Models/Fluent/Reports/{GetReportsByAppRequestBuilderOptions.cs => GetReportsRequestBuilderOptions.cs} (74%) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportDataRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportDataRequestBuilderTests.cs deleted file mode 100644 index 8a8c0c1..0000000 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportDataRequestBuilderTests.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NSubstitute; -using NSubstitute.ReceivedExtensions; -using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Interfaces.Fluent; -using Onspring.API.SDK.Models; -using Onspring.API.SDK.Models.Fluent; - -namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent -{ - [TestClass, ExcludeFromCodeCoverage] - public class GetReportDataRequestBuilderTests - { - private static readonly int _reportId = 1; - private static IOnspringClient _client; - private static GetReportDataRequestBuilder _builder; - - [ClassInitialize] - public static void ClassInit(TestContext testContext) - { - _client = Substitute.For(); - _builder = new GetReportDataRequestBuilder(_client, _reportId); - } - - [TestMethod] - public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() - { - var reportId = 1; - - var builder = new GetReportDataRequestBuilder(_client, reportId); - - Assert.IsInstanceOfType(builder); - Assert.AreEqual(reportId, builder.ReportId); - Assert.AreEqual(DataFormat.Raw, builder.Format); - Assert.AreEqual(ReportDataType.ReportData, builder.DataType); - } - - [TestMethod] - public void WithFormat_WhenCalled_ItShouldSetFormatProperty() - { - var format = DataFormat.Formatted; - - _builder.WithFormat(format); - - Assert.AreEqual(format, _builder.Format); - } - - [TestMethod] - public void WithDataType_WhenCalled_ItShouldSetDataTypeProperty() - { - var dataType = ReportDataType.ChartData; - - _builder.WithDataType(dataType); - - Assert.AreEqual(dataType, _builder.DataType); - } - - [TestMethod] - public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() - { - var apiResponse = new ApiResponse - { - StatusCode = HttpStatusCode.OK, - Value = new ReportData(), - }; - - _client - .GetReportAsync( - Arg.Any(), - Arg.Any(), - Arg.Any() - ) - .Returns(apiResponse); - - var result = await _builder.SendAsync(); - - Assert.AreEqual(apiResponse, result); - } - - [TestMethod] - public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnAnApiResponse() - { - var apiResponse = new ApiResponse - { - StatusCode = HttpStatusCode.OK, - Value = new ReportData(), - }; - - _client - .GetReportAsync( - Arg.Any(), - Arg.Any(), - Arg.Any() - ) - .Returns(apiResponse); - - var format = DataFormat.Formatted; - var dataType = ReportDataType.ChartData; - - var result = await _builder.SendAsync(options => - { - options.Format = format; - options.DataType = dataType; - }); - - Assert.AreEqual(apiResponse, result); - - await _client - .Received() - .GetReportAsync( - _reportId, - dataType, - format - ); - } - } -} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs index 2a06c23..37f229d 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs @@ -1,8 +1,11 @@ using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -10,6 +13,7 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent [TestClass, ExcludeFromCodeCoverage] public class GetReportRequestBuilderTests { + private static readonly int _reportId = 1; private static IOnspringClient _client; private static GetReportRequestBuilder _builder; @@ -32,5 +36,84 @@ public void FromReport_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet Assert.AreEqual(DataFormat.Raw, builder.Format); Assert.AreEqual(ReportDataType.ReportData, builder.DataType); } + + [TestMethod] + public void WithFormat_WhenCalled_ItShouldSetFormatProperty() + { + var format = DataFormat.Formatted; + + _builder.WithFormat(format); + + Assert.AreEqual(format, _builder.Format); + } + + [TestMethod] + public void WithDataType_WhenCalled_ItShouldSetDataTypeProperty() + { + var dataType = ReportDataType.ChartData; + + _builder.WithDataType(dataType); + + Assert.AreEqual(dataType, _builder.DataType); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new ReportData(), + }; + + _client + .GetReportAsync( + Arg.Any(), + Arg.Any(), + Arg.Any() + ) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + + [TestMethod] + public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new ReportData(), + }; + + _client + .GetReportAsync( + Arg.Any(), + Arg.Any(), + Arg.Any() + ) + .Returns(apiResponse); + + var format = DataFormat.Formatted; + var dataType = ReportDataType.ChartData; + + var result = await _builder.SendAsync(options => + { + options.Format = format; + options.DataType = dataType; + }); + + Assert.AreEqual(apiResponse, result); + + await _client + .Received() + .GetReportAsync( + _reportId, + dataType, + format + ); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs new file mode 100644 index 0000000..6373d28 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs @@ -0,0 +1,22 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetReportsRequestBuilderTests + { + private static readonly int _appId = 1; + private static IOnspringClient _client; + private static GetReportsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetReportsRequestBuilder(_client); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs index 41351e9..7d24388 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs @@ -14,6 +14,6 @@ public interface IGetReportDataRequestBuilder IGetReportDataRequestBuilder WithFormat(DataFormat format); IGetReportDataRequestBuilder WithDataType(ReportDataType dataType); Task> SendAsync(); - Task> SendAsync(Action options); + Task> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs index 492b1b3..fb3b3e9 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; @@ -14,6 +13,6 @@ public interface IGetReportsByAppRequestBuilder IGetReportsByAppRequestBuilder ForPageNumber(int pageNumber); IGetReportsByAppRequestBuilder WithPageSize(int pageNumber); Task> SendAsync(); - Task> SendAsync(Action options); + Task> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsRequestBuilder.cs new file mode 100644 index 0000000..8f3b239 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetReportsRequestBuilder + { + IGetReportsByAppRequestBuilder FromApp(int appId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index cc08113..9f2c844 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -33,7 +33,7 @@ public IDeleteRecordsRequestBuilder ToDeleteRecords() public IGetReportsByAppRequestBuilder ToGetReports() { - return new GetReportsByAppRequestBuilder(_client); + return new GetReportsRequestBuilder(_client); } public IGetReportRequestBuilder ToGetReportData() diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportBuilderOptions.cs similarity index 79% rename from Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilderOptions.cs rename to Onspring.API.SDK/Models/Fluent/Reports/GetReportBuilderOptions.cs index d393e89..c053c42 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportBuilderOptions.cs @@ -2,7 +2,7 @@ namespace Onspring.API.SDK.Models.Fluent { - public class GetReportDataRequestBuilderOptions + public class GetReportBuilderOptions { public DataFormat Format { get; set; } = DataFormat.Raw; public ReportDataType DataType { get; set; } = ReportDataType.ReportData; diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilder.cs deleted file mode 100644 index f407bc0..0000000 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportDataRequestBuilder.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Threading.Tasks; -using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Interfaces.Fluent; - -namespace Onspring.API.SDK.Models.Fluent -{ - public class GetReportDataRequestBuilder : IGetReportDataRequestBuilder - { - private readonly IOnspringClient _client; - public int ReportId { get; private set; } - public DataFormat Format { get; private set; } = DataFormat.Raw; - public ReportDataType DataType { get; private set; } = ReportDataType.ReportData; - - internal GetReportDataRequestBuilder(IOnspringClient client, int reportId) - { - _client = client; - ReportId = reportId; - } - - public IGetReportDataRequestBuilder WithFormat(DataFormat format) - { - Format = format; - return this; - } - - public IGetReportDataRequestBuilder WithDataType(ReportDataType dataType) - { - DataType = dataType; - return this; - } - - public async Task> SendAsync() - { - return await _client.GetReportAsync(ReportId, DataType, Format); - } - - public async Task> SendAsync(Action options) - { - var opts = new GetReportDataRequestBuilderOptions(); - options.Invoke(opts); - return await _client.GetReportAsync(ReportId, opts.DataType, opts.Format); - } - } -} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs index 338db92..b6491f2 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs @@ -1,10 +1,16 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { - public class GetReportRequestBuilder : IGetReportRequestBuilder + public class GetReportRequestBuilder : IGetReportRequestBuilder, IGetReportDataRequestBuilder { private readonly IOnspringClient _client; + public int ReportId { get; private set; } + public DataFormat Format { get; private set; } + public ReportDataType DataType { get; private set; } internal GetReportRequestBuilder(IOnspringClient client) { @@ -13,7 +19,32 @@ internal GetReportRequestBuilder(IOnspringClient client) public IGetReportDataRequestBuilder FromReport(int reportId) { - return new GetReportDataRequestBuilder(_client, reportId); + ReportId = reportId; + return this; + } + + public IGetReportDataRequestBuilder WithDataType(ReportDataType dataType) + { + DataType = dataType; + return this; + } + + public IGetReportDataRequestBuilder WithFormat(DataFormat format) + { + Format = format; + return this; + } + + public async Task> SendAsync() + { + return await _client.GetReportAsync(ReportId, DataType, Format); + } + + public async Task> SendAsync(Action options) + { + var opts = new GetReportBuilderOptions(); + options.Invoke(opts); + return await _client.GetReportAsync(ReportId, opts.DataType, opts.Format); } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs similarity index 61% rename from Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs index 7174b35..37db3ed 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs @@ -1,31 +1,36 @@ using System; using System.Threading.Tasks; -using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { - public class GetReportsByAppRequestBuilder : IGetReportsByAppRequestBuilder + public class GetReportsRequestBuilder : IGetReportsRequestBuilder, IGetReportsByAppRequestBuilder { private readonly IOnspringClient _client; public int AppId { get; private set; } - public int PageNumber { get; private set; } = 1; - public int PageSize { get; private set; } = 50; + public int PageNumber { get; private set; } + public int PageSize { get; private set; } - internal GetReportsByAppRequestBuilder(IOnspringClient client) + internal GetReportsRequestBuilder(IOnspringClient client) { _client = client; } + public IGetReportsByAppRequestBuilder FromApp(int appId) + { + AppId = appId; + return this; + } + public IGetReportsByAppRequestBuilder ForPageNumber(int pageNumber) { PageNumber = pageNumber; return this; } - public IGetReportsByAppRequestBuilder WithPageSize(int pageNumber) + public IGetReportsByAppRequestBuilder WithPageSize(int pageSize) { - PageNumber = pageNumber; + PageSize = pageSize; return this; } @@ -34,12 +39,11 @@ public async Task> SendAsync() return await _client.GetReportsForAppAsync(AppId, new PagingRequest(PageNumber, PageSize)); } - public async Task> SendAsync(Action options) + public async Task> SendAsync(Action options) { - var opts = new GetReportsByAppRequestBuilderOptions(); + var opts = new GetReportsRequestBuilderOptions(); options.Invoke(opts); return await _client.GetReportsForAppAsync(AppId, new PagingRequest(opts.PageNumber, opts.PageSize)); } - } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilderOptions.cs similarity index 74% rename from Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs rename to Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilderOptions.cs index 2cd92b8..9e4637b 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsByAppRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilderOptions.cs @@ -2,7 +2,7 @@ namespace Onspring.API.SDK.Models.Fluent { - public class GetReportsByAppRequestBuilderOptions + public class GetReportsRequestBuilderOptions { public int PageNumber { get; set; } = 1; public int PageSize { get; set; } = 50; From 35cee6c4229db08c500622a56fda78bd8308bbc7 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:21:00 -0500 Subject: [PATCH 078/168] tests: add tests for GetReportsRequestBuilder --- .../Reports/GetReportsRequestBuilderTests.cs | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs index 6373d28..9506239 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs @@ -1,6 +1,9 @@ using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent @@ -9,6 +12,8 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent public class GetReportsRequestBuilderTests { private static readonly int _appId = 1; + private static readonly int _pageNumber = 2; + private static readonly int _pageSize = 100; private static IOnspringClient _client; private static GetReportsRequestBuilder _builder; @@ -18,5 +23,78 @@ public static void ClassInit(TestContext testContext) _client = Substitute.For(); _builder = new GetReportsRequestBuilder(_client); } + + [TestMethod] + public void FromApp_WhenCalled_ItShouldSetAppIdProperty() + { + _builder.FromApp(_appId); + + Assert.AreEqual(_appId, _builder.AppId); + } + + [TestMethod] + public void ForPageNumber_WhenCalled_ItShouldSetPageNumberProperty() + { + _builder.ForPageNumber(_pageNumber); + + Assert.AreEqual(_pageNumber, _builder.PageNumber); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldSetPageSizeProperty() + { + _builder.WithPageSize(_pageSize); + + Assert.AreEqual(_pageSize, _builder.PageSize); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetReportsForAppResponse(), + }; + + _client + .GetReportsForAppAsync(Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + + [TestMethod] + public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetReportsForAppResponse(), + }; + + _client + .GetReportsForAppAsync(Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(options => + { + options.PageNumber = _pageNumber; + options.PageSize = _pageSize; + }); + + Assert.AreEqual(apiResponse, result); + + await _client + .Received() + .GetReportsForAppAsync( + _appId, + Arg.Is( + pr => pr.PageNumber == _pageNumber && pr.PageSize == _pageSize + ) + ); + } } } \ No newline at end of file From dfa88a5898a2f37db18f98800d0ad7677bcf4fa3 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:25:37 -0500 Subject: [PATCH 079/168] chore: add todos --- Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index 3b30a30..99897ec 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -8,5 +8,13 @@ public interface IOnspringRequest ISaveRecordRequestBuilder ToSaveRecord(); IGetReportsByAppRequestBuilder ToGetReports(); IGetReportRequestBuilder ToGetReportData(); + // TODO: ToSaveListValue() + // TODO: ToDeleteListValue() + // TODO: ToGetFile() + // TODO: ToGetFileInfo() + // TODO: ToAddFile() + // TODO: ToDeleteFile() + // TODO: ToGetFields() + // TODO: ToGetApps() } } \ No newline at end of file From c418f043e3cebe621be6a0ce4dc95d8ff786632c Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:29:59 -0500 Subject: [PATCH 080/168] feat: add fluent interface for saving list item --- .../Fluent/OnspringClientListsTests.cs | 61 +++++++++++++ .../Lists/SaveListValueRequestBuilderTests.cs | 88 +++++++++++++++++++ .../Interfaces/Fluent/IOnspringRequest.cs | 2 +- .../ISaveListValueInListRequestBuilder.cs | 9 ++ .../Lists/ISaveListValueRequestBuilder.cs | 7 ++ .../ISaveListValueWithIdRequestBuilder.cs | 11 +++ .../ISaveListValueWithNameRequestBuilder.cs | 16 ++++ .../Lists/SaveListValueRequestBuilder.cs | 69 +++++++++++++++ .../Models/Fluent/OnspringRequest.cs | 5 ++ 9 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/SaveListValueRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueInListRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithNameRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Lists/SaveListValueRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs new file mode 100644 index 0000000..c6817e6 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs @@ -0,0 +1,61 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Tests.Infrastructure; +using Onspring.API.SDK.Tests.Infrastructure.Helpers; +using Onspring.API.SDK.Tests.Infrastructure.Http; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringClientListsTests + { + private static OnspringClient _apiClient; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var testConfiguration = TestConfiguration.LoadFromContext(testContext); + var httpClient = HttpClientFactory.GetHttpClient(testConfiguration); + + _apiClient = new OnspringClient(testConfiguration.ApiKey, httpClient); + } + + [TestMethod] + public async Task AddListValue() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToSaveListValue() + .InList(1) + .WithId(null) + .WithName("Test") + .WithNumericValue(0) + .WithColor("#db3e3e") + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + Assert.IsInstanceOfType(apiResponse.Value.Id); + } + + [TestMethod] + public async Task UpdateListValue() + { + var testId = Guid.NewGuid(); + + var apiResponse = await _apiClient + .CreateRequest() + .ToSaveListValue() + .InList(1) + .WithId(testId) + .WithName("Test") + .WithNumericValue(0) + .WithColor("#db3e3e") + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + Assert.AreEqual(testId, apiResponse.Value.Id); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/SaveListValueRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/SaveListValueRequestBuilderTests.cs new file mode 100644 index 0000000..56e4ff1 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/SaveListValueRequestBuilderTests.cs @@ -0,0 +1,88 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class SaveListValueRequestBuilderTests + { + private static readonly int _listId = 1; + private static readonly Guid? _id = Guid.NewGuid(); + private static readonly string _name = "Name"; + private static readonly decimal _numValue = 1; + private static readonly string _color = "#db3e3e"; + private static IOnspringClient _client; + private static SaveListValueRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new SaveListValueRequestBuilder(_client); + } + + [TestMethod] + public void InList_WhenCalled_ItShouldSetListIdProperty() + { + _builder.InList(_listId); + + Assert.AreEqual(_listId, _builder.ListId); + } + + [TestMethod] + public void WithId_WhenCalled_ItShouldSetIdProperty() + { + _builder.WithId(_id); + + Assert.AreEqual(_id, _builder.Id); + } + + [TestMethod] + public void WithName_WhenCalled_ItShouldSetNameProperty() + { + _builder.WithName(_name); + + Assert.AreEqual(_name, _builder.Name); + } + + [TestMethod] + public void WithColor_WhenCalled_ItShouldSetColorProperty() + { + _builder.WithColor(_color); + + Assert.AreEqual(_color, _builder.Color); + } + + [TestMethod] + public void WithNumericValue_WhenCalled_ItShouldSetNumericValueProperty() + { + _builder.WithNumericValue(_numValue); + + Assert.AreEqual(_numValue, _builder.NumericValue); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new SaveListItemResponse(Guid.NewGuid()), + }; + + _client + .SaveListItemAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index 99897ec..cfc7318 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -8,7 +8,7 @@ public interface IOnspringRequest ISaveRecordRequestBuilder ToSaveRecord(); IGetReportsByAppRequestBuilder ToGetReports(); IGetReportRequestBuilder ToGetReportData(); - // TODO: ToSaveListValue() + ISaveListValueRequestBuilder ToSaveListValue(); // TODO: ToDeleteListValue() // TODO: ToGetFile() // TODO: ToGetFileInfo() diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueInListRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueInListRequestBuilder.cs new file mode 100644 index 0000000..bb62814 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueInListRequestBuilder.cs @@ -0,0 +1,9 @@ +using System; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface ISaveListValueInListRequestBuilder + { + ISaveListValueWithIdRequestBuilder WithId(Guid? id); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueRequestBuilder.cs new file mode 100644 index 0000000..b6c2797 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface ISaveListValueRequestBuilder + { + ISaveListValueInListRequestBuilder InList(int listId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithIdRequestBuilder.cs new file mode 100644 index 0000000..7733399 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithIdRequestBuilder.cs @@ -0,0 +1,11 @@ +using System; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface ISaveListValueWithIdRequestBuilder + { + int ListId { get; } + Guid? Id { get; } + ISaveListValueWithNameRequestBuilder WithName(string name); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithNameRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithNameRequestBuilder.cs new file mode 100644 index 0000000..7f608b2 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithNameRequestBuilder.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface ISaveListValueWithNameRequestBuilder + { + int ListId { get; } + Guid? Id { get; } + string Name { get; } + ISaveListValueWithNameRequestBuilder WithColor(string color); + ISaveListValueWithNameRequestBuilder WithNumericValue(decimal value); + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Lists/SaveListValueRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Lists/SaveListValueRequestBuilder.cs new file mode 100644 index 0000000..64df266 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Lists/SaveListValueRequestBuilder.cs @@ -0,0 +1,69 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class SaveListValueRequestBuilder : + ISaveListValueRequestBuilder, + ISaveListValueInListRequestBuilder, + ISaveListValueWithIdRequestBuilder, + ISaveListValueWithNameRequestBuilder + { + private readonly IOnspringClient _client; + public int ListId { get; private set; } + public Guid? Id { get; private set; } + public string Name { get; private set; } + public decimal? NumericValue { get; private set; } + public string Color { get; private set; } + + internal SaveListValueRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public ISaveListValueInListRequestBuilder InList(int listId) + { + ListId = listId; + return this; + } + + public ISaveListValueWithIdRequestBuilder WithId(Guid? id) + { + Id = id; + return this; + } + + public ISaveListValueWithNameRequestBuilder WithName(string name) + { + Name = name; + return this; + } + + public ISaveListValueWithNameRequestBuilder WithColor(string color) + { + Color = color; + return this; + } + + public ISaveListValueWithNameRequestBuilder WithNumericValue(decimal value) + { + NumericValue = value; + return this; + } + + public async Task> SendAsync() + { + return await _client.SaveListItemAsync( + new SaveListItemRequest + { + ListId = ListId, + Id = Id, + Name = Name, + NumericValue = NumericValue, + Color = Color, + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index 9f2c844..e972c4b 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -40,5 +40,10 @@ public IGetReportRequestBuilder ToGetReportData() { return new GetReportRequestBuilder(_client); } + + public ISaveListValueRequestBuilder ToSaveListValue() + { + return new SaveListValueRequestBuilder(_client); + } } } \ No newline at end of file From 5737c5e3dbc892ddbf5317fed8037a5eaa07a867 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:55:41 -0500 Subject: [PATCH 081/168] feat: add fluent interface for deleting list item --- .../Fluent/OnspringClientListsTests.cs | 13 +++++ .../DeleteListValueRequestBuilderTests.cs | 57 +++++++++++++++++++ .../SaveListValueRequestBuilderTests.cs | 0 .../Interfaces/Fluent/IOnspringRequest.cs | 2 +- .../IDeleteListValueInListRequestBuilder.cs | 10 ++++ .../Delete/IDeleteListValueRequestBuilder.cs | 7 +++ .../IDeleteListValueWithIdRequestBuilder.cs | 13 +++++ .../ISaveListValueInListRequestBuilder.cs | 0 .../ISaveListValueRequestBuilder.cs | 0 .../ISaveListValueWithIdRequestBuilder.cs | 0 .../ISaveListValueWithNameRequestBuilder.cs | 0 .../Delete/DeleteListValueRequestBuilder.cs | 39 +++++++++++++ .../{ => Save}/SaveListValueRequestBuilder.cs | 0 .../Models/Fluent/OnspringRequest.cs | 5 ++ 14 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Delete/DeleteListValueRequestBuilderTests.cs rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/{ => Save}/SaveListValueRequestBuilderTests.cs (100%) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueInListRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs rename Onspring.API.SDK/Interfaces/Fluent/Lists/{ => Save}/ISaveListValueInListRequestBuilder.cs (100%) rename Onspring.API.SDK/Interfaces/Fluent/Lists/{ => Save}/ISaveListValueRequestBuilder.cs (100%) rename Onspring.API.SDK/Interfaces/Fluent/Lists/{ => Save}/ISaveListValueWithIdRequestBuilder.cs (100%) rename Onspring.API.SDK/Interfaces/Fluent/Lists/{ => Save}/ISaveListValueWithNameRequestBuilder.cs (100%) create mode 100644 Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs rename Onspring.API.SDK/Models/Fluent/Lists/{ => Save}/SaveListValueRequestBuilder.cs (100%) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs index c6817e6..44a0354 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs @@ -57,5 +57,18 @@ public async Task UpdateListValue() AssertHelper.AssertSuccess(apiResponse); Assert.AreEqual(testId, apiResponse.Value.Id); } + + [TestMethod] + public async Task DeleteListValue() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToDeleteListValue() + .InList(1) + .WithId(Guid.NewGuid()) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Delete/DeleteListValueRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Delete/DeleteListValueRequestBuilderTests.cs new file mode 100644 index 0000000..e02c742 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Delete/DeleteListValueRequestBuilderTests.cs @@ -0,0 +1,57 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class DeleteListValueRequestBuilderTests + { + private static readonly int _listId = 1; + private static readonly Guid _id = Guid.NewGuid(); + + private static IOnspringClient _client; + private static DeleteListValueRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new DeleteListValueRequestBuilder(_client); + } + + [TestMethod] + public void InList_WhenCalled_ItShouldSetListIdProperty() + { + _builder.InList(_listId); + + Assert.AreEqual(_listId, _builder.ListId); + } + + [TestMethod] + public void WithId_WhenCalled_ItShouldSetIdProperty() + { + _builder.WithId(_id); + + Assert.AreEqual(_id, _builder.Id); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnApiResponse() + { + var apiResponse = new ApiResponse(); + + _client + .DeleteListItemAsync(Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/SaveListValueRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Save/SaveListValueRequestBuilderTests.cs similarity index 100% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/SaveListValueRequestBuilderTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Save/SaveListValueRequestBuilderTests.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs index cfc7318..a8d9fc5 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs @@ -9,7 +9,7 @@ public interface IOnspringRequest IGetReportsByAppRequestBuilder ToGetReports(); IGetReportRequestBuilder ToGetReportData(); ISaveListValueRequestBuilder ToSaveListValue(); - // TODO: ToDeleteListValue() + IDeleteListValueRequestBuilder ToDeleteListValue(); // TODO: ToGetFile() // TODO: ToGetFileInfo() // TODO: ToAddFile() diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueInListRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueInListRequestBuilder.cs new file mode 100644 index 0000000..b12df72 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueInListRequestBuilder.cs @@ -0,0 +1,10 @@ +using System; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteListValueInListRequestBuilder + { + int ListId { get; } + IDeleteListValueWithIdRequestBuilder WithId(Guid id); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueRequestBuilder.cs new file mode 100644 index 0000000..d3056b4 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteListValueRequestBuilder + { + IDeleteListValueInListRequestBuilder InList(int listId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs new file mode 100644 index 0000000..dae2107 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs @@ -0,0 +1,13 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteListValueWithIdRequestBuilder + { + int ListId { get; } + Guid Id { get; } + Task SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueInListRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueInListRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueInListRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueInListRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithIdRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithIdRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithIdRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithNameRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Interfaces/Fluent/Lists/ISaveListValueWithNameRequestBuilder.cs rename to Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs diff --git a/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs new file mode 100644 index 0000000..ce9a2f5 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs @@ -0,0 +1,39 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class DeleteListValueRequestBuilder : + IDeleteListValueRequestBuilder, + IDeleteListValueInListRequestBuilder, + IDeleteListValueWithIdRequestBuilder + { + private readonly IOnspringClient _client; + public int ListId { get; private set; } + public Guid Id { get; private set; } + + + internal DeleteListValueRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IDeleteListValueInListRequestBuilder InList(int listId) + { + ListId = listId; + return this; + } + + public IDeleteListValueWithIdRequestBuilder WithId(Guid id) + { + Id = id; + return this; + } + + public async Task SendAsync() + { + return await _client.DeleteListItemAsync(ListId, Id); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Lists/SaveListValueRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/Lists/SaveListValueRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs index e972c4b..331d711 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs @@ -45,5 +45,10 @@ public ISaveListValueRequestBuilder ToSaveListValue() { return new SaveListValueRequestBuilder(_client); } + + public IDeleteListValueRequestBuilder ToDeleteListValue() + { + return new DeleteListValueRequestBuilder(_client); + } } } \ No newline at end of file From bf35f81e7ceba683cc32129067613bdc07b1e84a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 20:25:20 -0500 Subject: [PATCH 082/168] refactor: rename OnspringRequest to OnspringRequestBuilder --- .../Tests/Integration/OnspringClientTests.cs | 2 +- ...stTests.cs => OnspringRequestBuilderTests.cs} | 16 ++++++++-------- .../Tests/Unit/OnspringClientTests.cs | 2 +- Onspring.API.SDK/IOnspringClient.cs | 4 ++-- ...ringRequest.cs => IOnspringRequestBuilder.cs} | 2 +- ...pringRequest.cs => OnspringRequestBuilder.cs} | 4 ++-- Onspring.API.SDK/OnspringClient.cs | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) rename Onspring.API.SDK.Tests/Tests/Unit/Fluent/{OnspringRequestTests.cs => OnspringRequestBuilderTests.cs} (74%) rename Onspring.API.SDK/Interfaces/Fluent/{IOnspringRequest.cs => IOnspringRequestBuilder.cs} (91%) rename Onspring.API.SDK/Models/Fluent/{OnspringRequest.cs => OnspringRequestBuilder.cs} (87%) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs index 6524b8a..298282b 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs @@ -107,7 +107,7 @@ public void CreateRequest_WhenCalled_ItShouldReturnAnInstanceOfAnOnspringRequest { var client = new OnspringClient(_testConfiguration.ApiKey, new HttpClient { BaseAddress = new Uri(_testConfiguration.BaseAddress) }); var request = client.CreateRequest(); - Assert.IsInstanceOfType(request, typeof(OnspringRequest)); + Assert.IsInstanceOfType(request, typeof(OnspringRequestBuilder)); } } } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs similarity index 74% rename from Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs rename to Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs index 283e540..a635f74 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs @@ -9,19 +9,19 @@ namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent [TestClass, ExcludeFromCodeCoverage] public class OnspringRequestTests { - private static OnspringRequest _onspringRequest; + private static OnspringRequestBuilder _builder; [ClassInitialize] public static void ClassInit(TestContext testContext) { var apiClientMock = Substitute.For(); - _onspringRequest = new OnspringRequest(apiClientMock); + _builder = new OnspringRequestBuilder(apiClientMock); } [TestMethod] public void ToGetRecords_WhenCalled_ShouldReturnBuilderInstance() { - var builder = _onspringRequest.ToGetRecords(); + var builder = _builder.ToGetRecords(); Assert.IsInstanceOfType(builder); } @@ -29,7 +29,7 @@ public void ToGetRecords_WhenCalled_ShouldReturnBuilderInstance() [TestMethod] public void ToCheckConnection_WhenCalled_ShouldReturnBuilderInstance() { - var builder = _onspringRequest.ToCheckConnection(); + var builder = _builder.ToCheckConnection(); Assert.IsInstanceOfType(builder); } @@ -37,7 +37,7 @@ public void ToCheckConnection_WhenCalled_ShouldReturnBuilderInstance() [TestMethod] public void ToSaveRecord_WhenCalled_ShouldReturnBuilderInstance() { - var builder = _onspringRequest.ToSaveRecord(); + var builder = _builder.ToSaveRecord(); Assert.IsInstanceOfType(builder); } @@ -45,7 +45,7 @@ public void ToSaveRecord_WhenCalled_ShouldReturnBuilderInstance() [TestMethod] public void ToDeleteRecords_WhenCalled_ShouldReturnBuilderInstance() { - var builder = _onspringRequest.ToDeleteRecords(); + var builder = _builder.ToDeleteRecords(); Assert.IsInstanceOfType(builder); } @@ -53,7 +53,7 @@ public void ToDeleteRecords_WhenCalled_ShouldReturnBuilderInstance() [TestMethod] public void ToGetReports_WhenCalled_ShouldReturnBuilderInstance() { - var builder = _onspringRequest.ToGetReports(); + var builder = _builder.ToGetReports(); Assert.IsInstanceOfType(builder); } @@ -61,7 +61,7 @@ public void ToGetReports_WhenCalled_ShouldReturnBuilderInstance() [TestMethod] public void ToGetReportData_WhenCalled_ShouldReturnBuilderInstance() { - var builder = _onspringRequest.ToGetReportData(); + var builder = _builder.ToGetReportData(); Assert.IsInstanceOfType(builder); } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs index b6c3705..c87ae69 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs @@ -13,7 +13,7 @@ public void CreateRequest_WhenCalled_ItShouldReturnAnOnspringRequestInstance() var client = new OnspringClient("https://api.onspring.com", "key"); var request = client.CreateRequest(); - Assert.IsInstanceOfType(request); + Assert.IsInstanceOfType(request); } } } \ No newline at end of file diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index b308219..ed800e9 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -16,8 +16,8 @@ public interface IOnspringClient /// /// Creates a new Onspring Request which exposes a fluent interface for making a request to the Onspring API. /// - /// An instance that implements the interface. - IOnspringRequest CreateRequest(); + /// An instance that implements the interface. + IOnspringRequestBuilder CreateRequest(); /// /// Determines if the API is reachable. diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs similarity index 91% rename from Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs rename to Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index a8d9fc5..fd6876e 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequest.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -1,6 +1,6 @@ namespace Onspring.API.SDK.Interfaces.Fluent { - public interface IOnspringRequest + public interface IOnspringRequestBuilder { IConnectionRequestBuilder ToCheckConnection(); IGetRecordsRequestBuilder ToGetRecords(); diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs similarity index 87% rename from Onspring.API.SDK/Models/Fluent/OnspringRequest.cs rename to Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index 331d711..e4e09dd 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequest.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -2,11 +2,11 @@ namespace Onspring.API.SDK.Models.Fluent { - public class OnspringRequest : IOnspringRequest + public class OnspringRequestBuilder : IOnspringRequestBuilder { private readonly IOnspringClient _client; - internal OnspringRequest(IOnspringClient client) + internal OnspringRequestBuilder(IOnspringClient client) { _client = client; } diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index cac431a..ea190a0 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -76,9 +76,9 @@ public OnspringClient(OnspringClientConfiguration clientConfig) // ------------------------------------ Fluent Interface ------------------------------------ /// - public IOnspringRequest CreateRequest() + public IOnspringRequestBuilder CreateRequest() { - return new OnspringRequest(this); + return new OnspringRequestBuilder(this); } // ------------------------------------ Diagnostic ------------------------------------ From a5a6dda0a396abdd8cfda72bbf4f36f6d4ed24ab Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 20:47:44 -0500 Subject: [PATCH 083/168] feat: add get file fluent interface --- .../Fluent/OnspringClientFilesTests.cs | 38 +++++++++++ .../Files/Get/GetFileRequestBuilderTests.cs | 67 +++++++++++++++++++ .../Files/Get/IGetFileByIdRequestBuilder.cs | 13 ++++ .../Get/IGetFileFromRecordRequestBuilder.cs | 8 +++ .../Get/IGetFileInFieldRequestBuilder.cs | 9 +++ .../Files/Get/IGetFileRequestBuilder.cs | 7 ++ .../Fluent/IOnspringRequestBuilder.cs | 2 +- .../Fluent/Files/GetFileRequestBuilder.cs | 45 +++++++++++++ .../Models/Fluent/OnspringRequestBuilder.cs | 5 ++ .../Fluent/Ping/ConnectionRequestBuilder.cs | 1 - 10 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileFromRecordRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInFieldRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Files/GetFileRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs new file mode 100644 index 0000000..6202221 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs @@ -0,0 +1,38 @@ +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Tests.Infrastructure; +using Onspring.API.SDK.Tests.Infrastructure.Helpers; +using Onspring.API.SDK.Tests.Infrastructure.Http; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringClientFilesTests + { + private static OnspringClient _apiClient; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var testConfiguration = TestConfiguration.LoadFromContext(testContext); + var httpClient = HttpClientFactory.GetHttpClient(testConfiguration); + + _apiClient = new OnspringClient(testConfiguration.ApiKey, httpClient); + } + + [TestMethod] + public async Task GetFile() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetFile() + .FromRecord(1) + .InField(1) + .WithId(1) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs new file mode 100644 index 0000000..1d8a016 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs @@ -0,0 +1,67 @@ +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + public class GetFileRequestBuilderTests + { + private static readonly int _recordId = 1; + private static readonly int _fieldId = 1; + private static readonly int _fileId = 1; + private static IOnspringClient _client; + private static GetFileRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetFileRequestBuilder(_client); + } + + [TestMethod] + public void FromRecord_WhenCalled_ItShouldSetRecordIdProperties() + { + _builder.FromRecord(_recordId); + + Assert.AreEqual(_recordId, _builder.RecordId); + } + + [TestMethod] + public void InField_WhenCalled_ItShouldSetFieldIdProperties() + { + _builder.InField(_fieldId); + + Assert.AreEqual(_fieldId, _builder.FieldId); + } + + [TestMethod] + public void WithId_WhenCalled_ItShouldSetFileIdProperties() + { + _builder.WithId(_fileId); + + Assert.AreEqual(_fileId, _builder.FileId); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetFileResponse(), + }; + + _client + .GetFileAsync(Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs new file mode 100644 index 0000000..9d89e74 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFileByIdRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + int FileId { get; } + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileFromRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileFromRecordRequestBuilder.cs new file mode 100644 index 0000000..f6b8907 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileFromRecordRequestBuilder.cs @@ -0,0 +1,8 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFileFromRecordRequestBuilder + { + int RecordId { get; } + IGetFileInFieldRequestBuilder InField(int fieldId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInFieldRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInFieldRequestBuilder.cs new file mode 100644 index 0000000..8fb1876 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInFieldRequestBuilder.cs @@ -0,0 +1,9 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFileInFieldRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + IGetFileByIdRequestBuilder WithId(int fileId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileRequestBuilder.cs new file mode 100644 index 0000000..8c47c6e --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFileRequestBuilder + { + IGetFileFromRecordRequestBuilder FromRecord(int recordId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index fd6876e..154ca48 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -10,7 +10,7 @@ public interface IOnspringRequestBuilder IGetReportRequestBuilder ToGetReportData(); ISaveListValueRequestBuilder ToSaveListValue(); IDeleteListValueRequestBuilder ToDeleteListValue(); - // TODO: ToGetFile() + IGetFileRequestBuilder ToGetFile(); // TODO: ToGetFileInfo() // TODO: ToAddFile() // TODO: ToDeleteFile() diff --git a/Onspring.API.SDK/Models/Fluent/Files/GetFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/GetFileRequestBuilder.cs new file mode 100644 index 0000000..5730462 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Files/GetFileRequestBuilder.cs @@ -0,0 +1,45 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetFileRequestBuilder : + IGetFileRequestBuilder, + IGetFileFromRecordRequestBuilder, + IGetFileInFieldRequestBuilder, + IGetFileByIdRequestBuilder + { + private readonly IOnspringClient _client; + public int RecordId { get; private set; } + public int FieldId { get; private set; } + public int FileId { get; private set; } + + internal GetFileRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetFileFromRecordRequestBuilder FromRecord(int recordId) + { + RecordId = recordId; + return this; + } + + public IGetFileInFieldRequestBuilder InField(int fieldId) + { + FieldId = fieldId; + return this; + } + + public IGetFileByIdRequestBuilder WithId(int fileId) + { + FileId = fileId; + return this; + } + + public async Task> SendAsync() + { + return await _client.GetFileAsync(RecordId, FieldId, FileId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index e4e09dd..e98c24f 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -50,5 +50,10 @@ public IDeleteListValueRequestBuilder ToDeleteListValue() { return new DeleteListValueRequestBuilder(_client); } + + public IGetFileRequestBuilder ToGetFile() + { + return new GetFileRequestBuilder(_client); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs index 4eb5a77..2244c26 100644 --- a/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs @@ -1,4 +1,3 @@ -using System.Net.Http; using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; From 661f74d49693d7073d93f5b9ae6b61786017e935 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 20:48:49 -0500 Subject: [PATCH 084/168] chore: organize --- .../Models/Fluent/Files/{ => Get}/GetFileRequestBuilder.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Onspring.API.SDK/Models/Fluent/Files/{ => Get}/GetFileRequestBuilder.cs (100%) diff --git a/Onspring.API.SDK/Models/Fluent/Files/GetFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs similarity index 100% rename from Onspring.API.SDK/Models/Fluent/Files/GetFileRequestBuilder.cs rename to Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs From e644985ea42c7ff54d430370644151fe0b2a446a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 20:59:57 -0500 Subject: [PATCH 085/168] feat: add get file info fluent interfaces --- .../Get/GetFileInfoRequestBuilderTests.cs | 67 +++++++++++++++++++ .../Fluent/OnspringRequestBuilderTests.cs | 16 +++++ .../Get/IGetFileInfoByIdRequestBuilder.cs | 13 ++++ .../IGetFileInfoFromRecordRequestBuilder.cs | 8 +++ .../Get/IGetFileInfoInFieldRequestBuilder.cs | 9 +++ .../Files/Get/IGetFileInfoRequestBuilder.cs | 7 ++ .../Fluent/IOnspringRequestBuilder.cs | 2 +- .../Files/Get/GetFileInfoRequestBuilder.cs | 45 +++++++++++++ .../Models/Fluent/OnspringRequestBuilder.cs | 5 ++ 9 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoFromRecordRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoInFieldRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs new file mode 100644 index 0000000..362ab2a --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs @@ -0,0 +1,67 @@ +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + public class GetFileInfoRequestBuilderTests + { + private static readonly int _recordId = 1; + private static readonly int _fieldId = 1; + private static readonly int _fileId = 1; + private static IOnspringClient _client; + private static GetFileInfoRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetFileInfoRequestBuilder(_client); + } + + [TestMethod] + public void FromRecord_WhenCalled_ItShouldSetRecordIdProperties() + { + _builder.FromRecord(_recordId); + + Assert.AreEqual(_recordId, _builder.RecordId); + } + + [TestMethod] + public void InField_WhenCalled_ItShouldSetFieldIdProperties() + { + _builder.InField(_fieldId); + + Assert.AreEqual(_fieldId, _builder.FieldId); + } + + [TestMethod] + public void WithId_WhenCalled_ItShouldSetFileIdProperties() + { + _builder.WithId(_fileId); + + Assert.AreEqual(_fileId, _builder.FileId); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetFileInfoResponse(), + }; + + _client + .GetFileInfoAsync(Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs index a635f74..ab4d798 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs @@ -65,5 +65,21 @@ public void ToGetReportData_WhenCalled_ShouldReturnBuilderInstance() Assert.IsInstanceOfType(builder); } + + [TestMethod] + public void ToGetFile_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _builder.ToGetFile(); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void ToGetFileInfo_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _builder.ToGetFileInfo(); + + Assert.IsInstanceOfType(builder); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs new file mode 100644 index 0000000..056c5f6 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFileInfoByIdRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + int FileId { get; } + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoFromRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoFromRecordRequestBuilder.cs new file mode 100644 index 0000000..c5ff2cc --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoFromRecordRequestBuilder.cs @@ -0,0 +1,8 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFileInfoFromRecordRequestBuilder + { + int RecordId { get; } + IGetFileInfoInFieldRequestBuilder InField(int fieldId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoInFieldRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoInFieldRequestBuilder.cs new file mode 100644 index 0000000..fbaa8cf --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoInFieldRequestBuilder.cs @@ -0,0 +1,9 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFileInfoInFieldRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + IGetFileInfoByIdRequestBuilder WithId(int fileId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoRequestBuilder.cs new file mode 100644 index 0000000..86a7975 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFileInfoRequestBuilder + { + IGetFileInfoFromRecordRequestBuilder FromRecord(int recordId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index 154ca48..e269892 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -11,7 +11,7 @@ public interface IOnspringRequestBuilder ISaveListValueRequestBuilder ToSaveListValue(); IDeleteListValueRequestBuilder ToDeleteListValue(); IGetFileRequestBuilder ToGetFile(); - // TODO: ToGetFileInfo() + IGetFileInfoRequestBuilder ToGetFileInfo(); // TODO: ToAddFile() // TODO: ToDeleteFile() // TODO: ToGetFields() diff --git a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs new file mode 100644 index 0000000..53697ff --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs @@ -0,0 +1,45 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetFileInfoRequestBuilder : + IGetFileInfoRequestBuilder, + IGetFileInfoFromRecordRequestBuilder, + IGetFileInfoInFieldRequestBuilder, + IGetFileInfoByIdRequestBuilder + { + private readonly IOnspringClient _client; + public int RecordId { get; private set; } + public int FieldId { get; private set; } + public int FileId { get; private set; } + + internal GetFileInfoRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetFileInfoFromRecordRequestBuilder FromRecord(int recordId) + { + RecordId = recordId; + return this; + } + + public IGetFileInfoInFieldRequestBuilder InField(int fieldId) + { + FieldId = fieldId; + return this; + } + + public IGetFileInfoByIdRequestBuilder WithId(int fileId) + { + FileId = fileId; + return this; + } + + public async Task> SendAsync() + { + return await _client.GetFileInfoAsync(RecordId, FieldId, FileId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index e98c24f..914ea89 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -55,5 +55,10 @@ public IGetFileRequestBuilder ToGetFile() { return new GetFileRequestBuilder(_client); } + + public IGetFileInfoRequestBuilder ToGetFileInfo() + { + return new GetFileInfoRequestBuilder(_client); + } } } \ No newline at end of file From 7438c121514a73c28beda9bd2978571ecd25f626 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 21:17:29 -0500 Subject: [PATCH 086/168] feat: add delete file fluent interface --- .../Fluent/OnspringClientFilesTests.cs | 30 ++++++++- .../Delete/DeleteFileRequestBuilderTests.cs | 65 +++++++++++++++++++ .../Get/GetFileInfoRequestBuilderTests.cs | 2 + .../Files/Get/GetFileRequestBuilderTests.cs | 2 + .../Fluent/OnspringRequestBuilderTests.cs | 8 +++ .../Delete/IDeleteFileByIdRequestBuilder.cs | 13 ++++ .../IDeleteFileFromRecordRequestBuilder.cs | 8 +++ .../IDeleteFileInFieldRequestBuilder.cs | 9 +++ .../Files/Delete/IDeleteFileRequestBuilder.cs | 7 ++ .../Fluent/IOnspringRequestBuilder.cs | 2 +- .../Files/Delete/DeleteFileRequestBuilder.cs | 45 +++++++++++++ .../Models/Fluent/OnspringRequestBuilder.cs | 5 ++ 12 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Delete/DeleteFileRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileFromRecordRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileInFieldRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs index 6202221..fc22a7a 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs @@ -34,5 +34,33 @@ public async Task GetFile() AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task GetFileInfo() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetFileInfo() + .FromRecord(1) + .InField(1) + .WithId(1) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task DeleteFile() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToDeleteFile() + .FromRecord(1) + .InField(1) + .WithId(1) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } } -} \ No newline at end of file +} diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Delete/DeleteFileRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Delete/DeleteFileRequestBuilderTests.cs new file mode 100644 index 0000000..ef2164f --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Delete/DeleteFileRequestBuilderTests.cs @@ -0,0 +1,65 @@ +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class DeleteFileRequestBuilderTests + { + private static readonly int _recordId = 1; + private static readonly int _fieldId = 1; + private static readonly int _fileId = 1; + private static IOnspringClient _client; + private static DeleteFileRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new DeleteFileRequestBuilder(_client); + } + + [TestMethod] + public void FromRecord_WhenCalled_ItShouldSetRecordIdProperties() + { + _builder.FromRecord(_recordId); + + Assert.AreEqual(_recordId, _builder.RecordId); + } + + [TestMethod] + public void InField_WhenCalled_ItShouldSetFieldIdProperties() + { + _builder.InField(_fieldId); + + Assert.AreEqual(_fieldId, _builder.FieldId); + } + + [TestMethod] + public void WithId_WhenCalled_ItShouldSetFileIdProperties() + { + _builder.WithId(_fileId); + + Assert.AreEqual(_fileId, _builder.FileId); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse(); + + _client + .DeleteFileAsync(Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs index 362ab2a..92814cb 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.Net; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -7,6 +8,7 @@ namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { + [TestClass, ExcludeFromCodeCoverage] public class GetFileInfoRequestBuilderTests { private static readonly int _recordId = 1; diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs index 1d8a016..678e3fd 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.Net; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -7,6 +8,7 @@ namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { + [TestClass, ExcludeFromCodeCoverage] public class GetFileRequestBuilderTests { private static readonly int _recordId = 1; diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs index ab4d798..47814b5 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs @@ -81,5 +81,13 @@ public void ToGetFileInfo_WhenCalled_ShouldReturnBuilderInstance() Assert.IsInstanceOfType(builder); } + + [TestMethod] + public void ToDeleteFile_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _builder.ToDeleteFile(); + + Assert.IsInstanceOfType(builder); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs new file mode 100644 index 0000000..7e31a07 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteFileByIdRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + int FileId { get; } + Task SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileFromRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileFromRecordRequestBuilder.cs new file mode 100644 index 0000000..5b02c8d --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileFromRecordRequestBuilder.cs @@ -0,0 +1,8 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteFileFromRecordRequestBuilder + { + int RecordId { get; } + IDeleteFileInFieldRequestBuilder InField(int fieldId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileInFieldRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileInFieldRequestBuilder.cs new file mode 100644 index 0000000..0ec4600 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileInFieldRequestBuilder.cs @@ -0,0 +1,9 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteFileInFieldRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + IDeleteFileByIdRequestBuilder WithId(int fileId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileRequestBuilder.cs new file mode 100644 index 0000000..fbe9acd --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IDeleteFileRequestBuilder + { + IDeleteFileFromRecordRequestBuilder FromRecord(int recordId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index e269892..3319b2c 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -12,8 +12,8 @@ public interface IOnspringRequestBuilder IDeleteListValueRequestBuilder ToDeleteListValue(); IGetFileRequestBuilder ToGetFile(); IGetFileInfoRequestBuilder ToGetFileInfo(); + IDeleteFileRequestBuilder ToDeleteFile(); // TODO: ToAddFile() - // TODO: ToDeleteFile() // TODO: ToGetFields() // TODO: ToGetApps() } diff --git a/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs new file mode 100644 index 0000000..f9a8565 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs @@ -0,0 +1,45 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class DeleteFileRequestBuilder : + IDeleteFileRequestBuilder, + IDeleteFileFromRecordRequestBuilder, + IDeleteFileInFieldRequestBuilder, + IDeleteFileByIdRequestBuilder + { + private readonly IOnspringClient _client; + public int RecordId { get; private set; } + public int FieldId { get; private set; } + public int FileId { get; private set; } + + internal DeleteFileRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IDeleteFileFromRecordRequestBuilder FromRecord(int recordId) + { + RecordId = recordId; + return this; + } + + public IDeleteFileInFieldRequestBuilder InField(int fieldId) + { + FieldId = fieldId; + return this; + } + + public IDeleteFileByIdRequestBuilder WithId(int fileId) + { + FileId = fileId; + return this; + } + + public async Task SendAsync() + { + return await _client.DeleteFileAsync(RecordId, FieldId, FileId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index 914ea89..0bc1bc4 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -60,5 +60,10 @@ public IGetFileInfoRequestBuilder ToGetFileInfo() { return new GetFileInfoRequestBuilder(_client); } + + public IDeleteFileRequestBuilder ToDeleteFile() + { + return new DeleteFileRequestBuilder(_client); + } } } \ No newline at end of file From 3fbd9241255450bcad8796463baeda77f34752b8 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 22:09:12 -0500 Subject: [PATCH 087/168] feat: add fluent interface for adding file --- .../Fluent/OnspringClientFilesTests.cs | 23 ++++ .../Files/Add/AddFileRequestBuilderTests.cs | 114 ++++++++++++++++++ .../Add/IAddFileInFieldRequestBuilder.cs | 9 ++ .../Files/Add/IAddFileRequestBuilder.cs | 7 ++ .../Add/IAddFileToRecordRequestBuilder.cs | 8 ++ .../IAddFileWithModifiedDateRequestBuilder.cs | 19 +++ .../Add/IAddFileWithNameRequestBuilder.cs | 12 ++ .../Add/IAddFileWithNotesRequestBuilder.cs | 16 +++ .../Add/IAddFileWithStreamRequestBuilder.cs | 13 ++ .../Add/IAddFileWithTypeRequestBuilder.cs | 14 +++ .../Fluent/IOnspringRequestBuilder.cs | 2 +- .../Fluent/Files/Add/AddFileRequestBuilder.cs | 92 ++++++++++++++ .../Models/Fluent/OnspringRequestBuilder.cs | 5 + 13 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Add/AddFileRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileInFieldRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileToRecordRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNameRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNotesRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithStreamRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithTypeRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs index fc22a7a..c531465 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs @@ -1,4 +1,6 @@ +using System; using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Tests.Infrastructure; @@ -62,5 +64,26 @@ public async Task DeleteFile() AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task AddFile() + { + var filePath = TestHelper.GetDefaultImagePath(); + var fileStream = File.OpenRead(filePath); + + var apiResponse = await _apiClient + .CreateRequest() + .ToAddFile() + .ToRecord(1) + .InField(1) + .WithName("image") + .WithStream(fileStream) + .WithType("image/png") + .WithNotes("This is a test file") + .WithModifiedDate(DateTime.UtcNow) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } } } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Add/AddFileRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Add/AddFileRequestBuilderTests.cs new file mode 100644 index 0000000..4e46f92 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Add/AddFileRequestBuilderTests.cs @@ -0,0 +1,114 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class AddFileRequestBuilderTests + { + private static readonly int _recordId = 1; + private static readonly int _fieldId = 1; + private static readonly string _name = "name"; + private static readonly Stream _stream = new MemoryStream(); + private static readonly string _type = "text/plain"; + private static readonly string _notes = "notes"; + private static readonly DateTime _modifiedDate = DateTime.UtcNow; + private static IOnspringClient _client; + private static AddFileRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new AddFileRequestBuilder(_client); + } + + [TestMethod] + public void ToRecord_WhenCalled_ItShouldSetRecordIdProperty() + { + _builder.ToRecord(_recordId); + + Assert.AreEqual(_recordId, _builder.RecordId); + } + + [TestMethod] + public void InField_WhenCalled_ItShouldSetFieldIdProperty() + { + _builder.InField(_fieldId); + + Assert.AreEqual(_fieldId, _builder.FieldId); + } + + [TestMethod] + public void WithName_WhenCalled_ItShouldSetNameProperty() + { + _builder.WithName(_name); + + Assert.AreEqual(_name, _builder.Name); + } + + [TestMethod] + public void WithStream_WhenCalled_ItShouldSetStreamProperty() + { + _builder.WithStream(_stream); + + Assert.AreEqual(_stream, _builder.FileStream); + } + + [TestMethod] + public void WithType_WhenCalled_ItShouldSetTypeProperty() + { + _builder.WithType(_type); + + Assert.AreEqual(_type, _builder.Type); + } + + [TestMethod] + public void WithNotes_WhenCalled_ItShouldSetNotesProperty() + { + _builder.WithNotes(_notes); + + Assert.AreEqual(_notes, _builder.Notes); + } + + [TestMethod] + public void WithModifiedDate_WhenCalled_ItShouldSetModifiedDateProperty() + { + _builder.WithModifiedDate(null); + + Assert.AreEqual(null, _builder.ModifiedDate); + + _builder.WithModifiedDate(_modifiedDate); + + Assert.AreEqual(_modifiedDate, _builder.ModifiedDate); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse> + { + StatusCode = HttpStatusCode.Created, + Value = new CreatedWithIdResponse + { + Id = 1, + } + }; + + _client + .SaveFileAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileInFieldRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileInFieldRequestBuilder.cs new file mode 100644 index 0000000..8460bf4 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileInFieldRequestBuilder.cs @@ -0,0 +1,9 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IAddFileInFieldRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + IAddFileWithNameRequestBuilder WithName(string name); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileRequestBuilder.cs new file mode 100644 index 0000000..d825ddf --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileRequestBuilder.cs @@ -0,0 +1,7 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IAddFileRequestBuilder + { + IAddFileToRecordRequestBuilder ToRecord(int recordId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileToRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileToRecordRequestBuilder.cs new file mode 100644 index 0000000..fdc2358 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileToRecordRequestBuilder.cs @@ -0,0 +1,8 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IAddFileToRecordRequestBuilder + { + int RecordId { get; } + IAddFileInFieldRequestBuilder InField(int fieldId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs new file mode 100644 index 0000000..a4617e3 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs @@ -0,0 +1,19 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IAddFileWithModifiedDateRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + string Name { get; } + Stream FileStream { get; } + string Type { get; } + string Notes { get; } + DateTime? ModifiedDate { get; } + Task>> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNameRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNameRequestBuilder.cs new file mode 100644 index 0000000..25eed51 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNameRequestBuilder.cs @@ -0,0 +1,12 @@ +using System.IO; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IAddFileWithNameRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + string Name { get; } + IAddFileWithStreamRequestBuilder WithStream(Stream stream); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNotesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNotesRequestBuilder.cs new file mode 100644 index 0000000..0461baa --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNotesRequestBuilder.cs @@ -0,0 +1,16 @@ +using System; +using System.IO; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IAddFileWithNotesRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + string Name { get; } + Stream FileStream { get; } + string Type { get; } + string Notes { get; } + IAddFileWithModifiedDateRequestBuilder WithModifiedDate(DateTime? modifiedDate); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithStreamRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithStreamRequestBuilder.cs new file mode 100644 index 0000000..aa70998 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithStreamRequestBuilder.cs @@ -0,0 +1,13 @@ +using System.IO; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IAddFileWithStreamRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + string Name { get; } + Stream FileStream { get; } + IAddFileWithTypeRequestBuilder WithType(string type); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithTypeRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithTypeRequestBuilder.cs new file mode 100644 index 0000000..b0906bd --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithTypeRequestBuilder.cs @@ -0,0 +1,14 @@ +using System.IO; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IAddFileWithTypeRequestBuilder + { + int RecordId { get; } + int FieldId { get; } + string Name { get; } + Stream FileStream { get; } + string Type { get; } + IAddFileWithNotesRequestBuilder WithNotes(string notes); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index 3319b2c..1263a31 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -13,7 +13,7 @@ public interface IOnspringRequestBuilder IGetFileRequestBuilder ToGetFile(); IGetFileInfoRequestBuilder ToGetFileInfo(); IDeleteFileRequestBuilder ToDeleteFile(); - // TODO: ToAddFile() + IAddFileRequestBuilder ToAddFile(); // TODO: ToGetFields() // TODO: ToGetApps() } diff --git a/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs new file mode 100644 index 0000000..8904705 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs @@ -0,0 +1,92 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class AddFileRequestBuilder : + IAddFileRequestBuilder, + IAddFileToRecordRequestBuilder, + IAddFileInFieldRequestBuilder, + IAddFileWithNameRequestBuilder, + IAddFileWithStreamRequestBuilder, + IAddFileWithTypeRequestBuilder, + IAddFileWithNotesRequestBuilder, + IAddFileWithModifiedDateRequestBuilder + { + private readonly IOnspringClient _client; + public int RecordId { get; private set; } + public int FieldId { get; private set; } + public string Name { get; private set; } + public Stream FileStream { get; private set; } + public string Type { get; private set; } + public string Notes { get; private set; } + public DateTime? ModifiedDate { get; private set; } + + internal AddFileRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IAddFileToRecordRequestBuilder ToRecord(int recordId) + { + RecordId = recordId; + return this; + } + + public IAddFileInFieldRequestBuilder InField(int fieldId) + { + FieldId = fieldId; + return this; + } + + public IAddFileWithNameRequestBuilder WithName(string name) + { + Name = name; + return this; + } + + public IAddFileWithStreamRequestBuilder WithStream(Stream stream) + { + FileStream = stream; + return this; + } + + public IAddFileWithTypeRequestBuilder WithType(string type) + { + Type = type; + return this; + } + + public IAddFileWithNotesRequestBuilder WithNotes(string notes) + { + Notes = notes; + return this; + } + + public IAddFileWithModifiedDateRequestBuilder WithModifiedDate(DateTime? modifiedDate) + { + ModifiedDate = modifiedDate; + return this; + } + + + + public async Task>> SendAsync() + { + return await _client.SaveFileAsync( + new SaveFileRequest + { + RecordId = RecordId, + FieldId = FieldId, + Notes = Notes, + ModifiedDate = ModifiedDate, + ContentType = Type, + FileName = Name, + FileStream = FileStream, + } + ); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index 0bc1bc4..4ee2ad4 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -65,5 +65,10 @@ public IDeleteFileRequestBuilder ToDeleteFile() { return new DeleteFileRequestBuilder(_client); } + + public IAddFileRequestBuilder ToAddFile() + { + return new AddFileRequestBuilder(_client); + } } } \ No newline at end of file From a75887a86383c9450478c07ea8956965c58f7368 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 22 Sep 2023 22:15:13 -0500 Subject: [PATCH 088/168] style: format README.md --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 17885d7..5ce08d9 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,16 @@ Install the SDK using Nuget ## API Key -In order to successfully interact with the Onspring API, you must use an API key. API keys may be obtained by an Onspring user with permissions to read API Keys for your instance, using the following instructions: +In order to successfully interact with the Onspring API, you must use an API key. API keys may be obtained by an Onspring user with permissions to read API Keys for your instance, using the following instructions: -1. Within Onspring, navigate to Administration | Security | API Keys. -2. On the list page, add a new API Key (requires Create permissions) or click an existing API Key to view its details. -3. On the details page for an API Key, expand the **Developer Information** section. Copy the **X-ApiKey Header** value from this section. +1. Within Onspring, navigate to Administration | Security | API Keys. +2. On the list page, add a new API Key (requires Create permissions) or click an existing API Key to view its details. +3. On the details page for an API Key, expand the **Developer Information** section. Copy the **X-ApiKey Header** value from this section. #### Important -- An API Key must have a **Status** of *Enabled* (available on the details page) in order to be used. -- Each API Key has an associated **Role** that controls the permissions for requests made using that API Key. An Onspring administrator may configure those permissions as they would any other Role in Onspring. If the API Key does not have sufficient permissions to perform the requested action, an error will be returned. +- An API Key must have a **Status** of _Enabled_ (available on the details page) in order to be used. +- Each API Key has an associated **Role** that controls the permissions for requests made using that API Key. An Onspring administrator may configure those permissions as they would any other Role in Onspring. If the API Key does not have sufficient permissions to perform the requested action, an error will be returned. ## Sample Projects @@ -28,7 +28,7 @@ In order to successfully interact with the Onspring API, you must use an API key ## Start Coding -The most common way to use the SDK is to create an `OnspringClient` instance and call its methods. Its constructor requires two parameters: +The most common way to use the SDK is to create an `OnspringClient` instance and call its methods. Its constructor requires two parameters: - `baseUrl` - currently this should always be: **`https://api.onspring.com/`** - `apiKey` - the value obtained by following the steps in the **API Key** section @@ -59,7 +59,6 @@ var onspringClient = new OnspringClient(apiKey, myHttpClient); Although we strongly recommend using async for accessing the API, in the case that the calling code is synchronous, we offer a simple helper class `Onspring.API.SDK.Helpers.AsyncHelper`. This class allows C# to execute an asynchronous function in a synchronous context without deadlocking. - Example assumes that you've have an `OnspringClient` (or `IOnspringClient`) instance prior to execution. ```C# @@ -68,10 +67,9 @@ using Onspring.API.SDK.Helpers; bool canConnect = AsyncHelper.RunTask(() => onspringClient.CanConnectAsync()); ``` - ## Full API Documentation -When using the SDK, you do not need to be as concerned with the details covered in the full [Onspring API documentation](https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v2%20API.pdf). However, you may wish to refer to it when determining which values to pass as parameters to some of the `OnspringClient` methods. +When using the SDK, you do not need to be as concerned with the details covered in the full [Onspring API documentation](https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v2%20API.pdf). However, you may wish to refer to it when determining which values to pass as parameters to some of the `OnspringClient` methods. Each method on the `OnspringClient` aside from `CanConnectAsync` returns a wrapped response, allowing clients to decide how a response should be handled. This wrapper is the `ApiResponse` class and includes generic types to encompass the response body, if any. In the examples below, we're omitting the validation/error handling around that, however we recommend that each client adds resilience and error handling for potential unsuccessful responses. Please refer to the API documentation/swagger page to determine the possible responses. @@ -82,6 +80,7 @@ The `OnspringClient` is thread-safe and can be used as a singleton or transient. ## Upgrading SDK Already using a previous version of the SDK? Check out our migration guides below. + - [2.x to 3.0](./docs/migrations/2-to-30.md) ## Example Code @@ -99,6 +98,7 @@ bool canConnect = await onspringClient.CanConnectAsync(); Returns a paged collection of apps/surveys, which can be paged through using the `Onspring.API.SDK.Models.PagingRequest`. ##### Basic + ```C# var apps = await onspringClient.GetAppsAsync(); foreach (App app in apps) @@ -108,6 +108,7 @@ foreach (App app in apps) ``` ##### Paged + Async and synchronous methods allow use of `Onspring.API.SDK.Models.PagingRequest`. ```C# @@ -360,4 +361,4 @@ using (var result = getFileResponse.Value) result.Stream.CopyTo(fileStream); } } -``` \ No newline at end of file +``` From bb365859a71eb7a3ecd46634a91086b5e2589bb2 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:00:01 -0500 Subject: [PATCH 089/168] feat: add fluent interface for getting fields --- .../Fluent/OnspringClientFieldTests.cs | 82 ++++++++++++++++ .../Fields/GetFieldByIdRequestBuilderTests.cs | 53 +++++++++++ .../GetFieldsByAppRequestBuilderTests.cs | 93 +++++++++++++++++++ .../GetFieldsByIdsRequestBuilderTests.cs | 54 +++++++++++ .../Fields/GetFieldsRequestBuilderTests.cs | 53 +++++++++++ .../Fluent/OnspringRequestBuilderTests.cs | 16 ++++ .../Fields/IGetFieldByIdRequestBuilder.cs | 11 +++ .../Fields/IGetFieldsByAppRequestBuilder.cs | 18 ++++ .../Fields/IGetFieldsByIdsRequestBuilder.cs | 12 +++ .../Fluent/Fields/IGetFieldsRequestBuilder.cs | 11 +++ .../Fluent/IOnspringRequestBuilder.cs | 2 +- .../Fields/GetFieldByIdRequestBuilder.cs | 22 +++++ .../Fields/GetFieldsByAppRequestBuilder.cs | 44 +++++++++ .../GetFieldsByAppRequestBuilderOptions.cs | 8 ++ .../Fields/GetFieldsByIdsRequestBuilder.cs | 23 +++++ .../Fluent/Fields/GetFieldsRequestBuilder.cs | 30 ++++++ .../Models/Fluent/OnspringRequestBuilder.cs | 5 + 17 files changed, 536 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldByIdRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilderOptions.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs new file mode 100644 index 0000000..bc71007 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs @@ -0,0 +1,82 @@ +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Tests.Infrastructure; +using Onspring.API.SDK.Tests.Infrastructure.Helpers; +using Onspring.API.SDK.Tests.Infrastructure.Http; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class OnspringClientFieldTests + { + private const int _appIdWithFields = 1; + private static readonly int[] _fields = new[] { 1, 2, 3, 4, 5 }; + + private static OnspringClient _apiClient; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var testConfiguration = TestConfiguration.LoadFromContext(testContext); + var httpClient = HttpClientFactory.GetHttpClient(testConfiguration); + + _apiClient = new OnspringClient(testConfiguration.ApiKey, httpClient); + } + + [TestMethod] + public async Task GetField() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetFields() + .WithId(_fields.First()) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task GetFields() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetFields() + .WithIds(_fields) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task GetFieldsFromApp() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetFields() + .FromApp(_appIdWithFields) + .ForPageNumber(1) + .WithPageSize(50) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task GetFieldsFromApp_WithOptions() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetFields() + .FromApp(_appIdWithFields) + .SendAsync(options => + { + options.PageNumber = 1; + options.PageSize = 25; + }); + + AssertHelper.AssertSuccess(apiResponse); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldByIdRequestBuilderTests.cs new file mode 100644 index 0000000..247f91b --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldByIdRequestBuilderTests.cs @@ -0,0 +1,53 @@ +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetFieldByIdRequestBuilderTests + { + private static readonly int _fieldId = 1; + private static IOnspringClient _client; + private static GetFieldByIdRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetFieldByIdRequestBuilder(_client, _fieldId); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() + { + var builder = new GetFieldByIdRequestBuilder(_client, _fieldId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_fieldId, builder.FieldId); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new Field(), + }; + + _client + .GetFieldAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs new file mode 100644 index 0000000..59cbf6d --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs @@ -0,0 +1,93 @@ +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetFieldsByAppRequestBuilderTests + { + private static readonly int _appId = 1; + private static readonly int _pageNumber = 2; + private static readonly int _pageSize = 25; + private static IOnspringClient _client; + private static GetFieldsByAppRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetFieldsByAppRequestBuilder(_client, _appId); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() + { + var builder = new GetFieldsByAppRequestBuilder(_client, _appId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appId, builder.AppId); + } + + [TestMethod] + public void ForPageNumber_WhenCalled_ItShouldSetPageNumberProperty() + { + _builder.ForPageNumber(_pageNumber); + + Assert.AreEqual(_pageNumber, _builder.PageNumber); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldSetPageSizeProperty() + { + _builder.WithPageSize(_pageSize); + + Assert.AreEqual(_pageSize, _builder.PageSize); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetPagedFieldsResponse(), + }; + + _client + .GetFieldsForAppAsync(Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + + [TestMethod] + public async Task SendAsync_WhenCalledWithOptions_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetPagedFieldsResponse(), + }; + + _client + .GetFieldsForAppAsync(Arg.Any(), Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(options => + { + options.PageNumber = 2; + options.PageSize = 25; + }); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs new file mode 100644 index 0000000..68b9d03 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetFieldsByIdsRequestBuilderTests + { + private static readonly IEnumerable _fieldIds = new[] { 1, 2, 3 }; + private static IOnspringClient _client; + private static GetFieldsByIdsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetFieldsByIdsRequestBuilder(_client, _fieldIds); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() + { + var builder = new GetFieldsByIdsRequestBuilder(_client, _fieldIds); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_fieldIds, builder.FieldIds); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetFieldsResponse(), + }; + + _client + .GetFieldsAsync(Arg.Any>()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs new file mode 100644 index 0000000..48674e6 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetFieldsRequestBuilderTests + { + private static readonly int _appId = 1; + private static readonly int _fieldId = 1; + private static readonly IEnumerable _fieldIds = new[] { 1, 2, 3 }; + private static IOnspringClient _client; + private static GetFieldsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetFieldsRequestBuilder(_client); + } + + [TestMethod] + public void FromApp_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() + { + var builder = _builder.FromApp(_appId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appId, builder.AppId); + } + + [TestMethod] + public void WithId_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() + { + var builder = _builder.WithId(_fieldId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appId, builder.FieldId); + } + + [TestMethod] + public void WithIds_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() + { + var builder = _builder.WithIds(_fieldIds); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_fieldIds, builder.FieldIds); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs index 47814b5..645eab3 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs @@ -89,5 +89,21 @@ public void ToDeleteFile_WhenCalled_ShouldReturnBuilderInstance() Assert.IsInstanceOfType(builder); } + + [TestMethod] + public void ToAddFile_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _builder.ToAddFile(); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void ToGetFields_WhenCalled_ShouldReturnBuilderInstance() + { + var builder = _builder.ToGetFields(); + + Assert.IsInstanceOfType(builder); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs new file mode 100644 index 0000000..15c696d --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFieldByIdRequestBuilder + { + int FieldId { get; } + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs new file mode 100644 index 0000000..f20129a --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs @@ -0,0 +1,18 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFieldsByAppRequestBuilder + { + int AppId { get; } + int PageNumber { get; } + int PageSize { get; } + IGetFieldsByAppRequestBuilder ForPageNumber(int pageNumber); + IGetFieldsByAppRequestBuilder WithPageSize(int pageSize); + Task> SendAsync(); + Task> SendAsync(Action options); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs new file mode 100644 index 0000000..9540318 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFieldsByIdsRequestBuilder + { + IEnumerable FieldIds { get; } + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsRequestBuilder.cs new file mode 100644 index 0000000..a1a22fb --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsRequestBuilder.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetFieldsRequestBuilder + { + IGetFieldByIdRequestBuilder WithId(int fieldId); + IGetFieldsByAppRequestBuilder FromApp(int appId); + IGetFieldsByIdsRequestBuilder WithIds(IEnumerable fieldIds); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index 1263a31..234a2fb 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -14,7 +14,7 @@ public interface IOnspringRequestBuilder IGetFileInfoRequestBuilder ToGetFileInfo(); IDeleteFileRequestBuilder ToDeleteFile(); IAddFileRequestBuilder ToAddFile(); - // TODO: ToGetFields() + IGetFieldsRequestBuilder ToGetFields(); // TODO: ToGetApps() } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs new file mode 100644 index 0000000..9fbdbba --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs @@ -0,0 +1,22 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetFieldByIdRequestBuilder : IGetFieldByIdRequestBuilder + { + private readonly IOnspringClient _client; + public int FieldId { get; private set; } + + internal GetFieldByIdRequestBuilder(IOnspringClient client, int fieldId) + { + _client = client; + FieldId = fieldId; + } + + public async Task> SendAsync() + { + return await _client.GetFieldAsync(FieldId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs new file mode 100644 index 0000000..8dc05b3 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs @@ -0,0 +1,44 @@ +using System; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetFieldsByAppRequestBuilder : IGetFieldsByAppRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + public int PageNumber { get; private set; } = 1; + public int PageSize { get; private set; } = 50; + + internal GetFieldsByAppRequestBuilder(IOnspringClient client, int appId) + { + _client = client; + AppId = appId; + } + + public IGetFieldsByAppRequestBuilder ForPageNumber(int pageNumber) + { + PageNumber = pageNumber; + return this; + } + + public IGetFieldsByAppRequestBuilder WithPageSize(int pageSize) + { + PageSize = pageSize; + return this; + } + + public async Task> SendAsync() + { + return await _client.GetFieldsForAppAsync(AppId, new PagingRequest(PageNumber, PageSize)); + } + + public async Task> SendAsync(Action options) + { + var opts = new GetFieldsByAppRequestBuilderOptions(); + options.Invoke(opts); + return await _client.GetFieldsForAppAsync(AppId, new PagingRequest(opts.PageNumber, opts.PageSize)); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilderOptions.cs new file mode 100644 index 0000000..bf47bc4 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilderOptions.cs @@ -0,0 +1,8 @@ +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetFieldsByAppRequestBuilderOptions + { + public int PageNumber { get; set; } = 1; + public int PageSize { get; set; } = 50; + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs new file mode 100644 index 0000000..bcb4315 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetFieldsByIdsRequestBuilder : IGetFieldsByIdsRequestBuilder + { + private readonly IOnspringClient _client; + public IEnumerable FieldIds { get; private set; } + + internal GetFieldsByIdsRequestBuilder(IOnspringClient client, IEnumerable fieldIds) + { + _client = client; + FieldIds = fieldIds; + } + + public async Task> SendAsync() + { + return await _client.GetFieldsAsync(FieldIds); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs new file mode 100644 index 0000000..e3ebfa9 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetFieldsRequestBuilder : IGetFieldsRequestBuilder + { + private readonly IOnspringClient _client; + + internal GetFieldsRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetFieldsByAppRequestBuilder FromApp(int appId) + { + return new GetFieldsByAppRequestBuilder(_client, appId); + } + + public IGetFieldByIdRequestBuilder WithId(int fieldId) + { + return new GetFieldByIdRequestBuilder(_client, fieldId); + } + + public IGetFieldsByIdsRequestBuilder WithIds(IEnumerable fieldIds) + { + return new GetFieldsByIdsRequestBuilder(_client, fieldIds); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index 4ee2ad4..d59d794 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -70,5 +70,10 @@ public IAddFileRequestBuilder ToAddFile() { return new AddFileRequestBuilder(_client); } + + public IGetFieldsRequestBuilder ToGetFields() + { + return new GetFieldsRequestBuilder(_client); + } } } \ No newline at end of file From 25e87058997700adf53f21141016ca1d402b0035 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sat, 23 Sep 2023 23:54:54 -0500 Subject: [PATCH 090/168] feat: add fluent interface for getting apps --- .../Fluent/OnspringClientAppsTests.cs | 59 +++++++++++++++++ .../Fluent/OnspringClientFieldTests.cs | 2 +- .../Fluent/OnspringClientRecordsTests.cs | 2 +- .../Apps/GetAppByIdRequestBuilderTests.cs | 53 +++++++++++++++ .../Apps/GetAppsByIdsRequestBuilderTests.cs | 54 ++++++++++++++++ .../Fluent/Apps/GetAppsRequestBuilderTests.cs | 53 +++++++++++++++ .../Apps/GetPagedAppsRequestBuilderTests.cs | 64 +++++++++++++++++++ .../GetFieldsByAppRequestBuilderTests.cs | 4 +- ...eryRecordsByAppPagedRequestBuilderTests.cs | 4 +- .../Reports/GetReportsRequestBuilderTests.cs | 4 +- .../Fluent/Apps/IGetAppByIdRequestBuilder.cs | 11 ++++ .../Apps/IGetAppsByIdsRequestBuilder.cs | 12 ++++ .../Fluent/Apps/IGetAppsRequestBuilder.cs | 11 ++++ .../Apps/IGetPagedAppsRequestBuilder.cs | 13 ++++ .../Fields/IGetFieldsByAppRequestBuilder.cs | 2 +- .../Fluent/IOnspringRequestBuilder.cs | 2 +- .../IQueryRecordsByAppPagedRequestBuilder.cs | 2 +- .../Reports/IGetReportsByAppRequestBuilder.cs | 2 +- .../Fluent/Apps/GetAppByIdRequestBuilder.cs | 22 +++++++ .../Fluent/Apps/GetAppsByIdsRequestBuilder.cs | 23 +++++++ .../Fluent/Apps/GetAppsRequestBuilder.cs | 30 +++++++++ .../Fluent/Apps/GetPagedAppsRequestBuilder.cs | 29 +++++++++ .../Fields/GetFieldsByAppRequestBuilder.cs | 2 +- .../Models/Fluent/OnspringRequestBuilder.cs | 5 ++ .../QueryRecordsByAppPagedRequestBuilder.cs | 2 +- .../Reports/GetReportsRequestBuilder.cs | 2 +- 26 files changed, 454 insertions(+), 15 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetPagedAppsRequestBuilderTests.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs new file mode 100644 index 0000000..444c403 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs @@ -0,0 +1,59 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Tests.Infrastructure.Http; +using Onspring.API.SDK.Tests.Infrastructure; +using System.Threading.Tasks; +using Onspring.API.SDK.Tests.Infrastructure.Helpers; + +namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent +{ + public class OnspringClientAppsTests + { + private static OnspringClient _apiClient; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + var testConfiguration = TestConfiguration.LoadFromContext(testContext); + var httpClient = HttpClientFactory.GetHttpClient(testConfiguration); + + _apiClient = new OnspringClient(testConfiguration.ApiKey, httpClient); + } + + [TestMethod] + public async Task GetApp() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetApps() + .WithId(1) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task GetAppsByIds() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetApps() + .WithIds(new[] { 1, 2, 3 }) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + + [TestMethod] + public async Task GetApps() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetApps() + .ForPage(1) + .WithPageSize(25) + .SendAsync(); + + AssertHelper.AssertSuccess(apiResponse); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs index bc71007..85f7790 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs @@ -56,7 +56,7 @@ public async Task GetFieldsFromApp() .CreateRequest() .ToGetFields() .FromApp(_appIdWithFields) - .ForPageNumber(1) + .ForPage(1) .WithPageSize(50) .SendAsync(); diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs index e0d573f..f0b0247 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs @@ -140,7 +140,7 @@ public async Task QueryRecords() .ToGetRecords() .FromApp(_appIdWithRecords) .WithFilter($"{1} eq {1}") - .ForPageNumber(1) + .ForPage(1) .WithPageSize(50) .WithFieldIds(new[] { 1, 2, 3 }) .WithFormat(DataFormat.Formatted) diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs new file mode 100644 index 0000000..5dfc382 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs @@ -0,0 +1,53 @@ +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAppByIdRequestBuilderTests + { + private static readonly int _appId = 1; + private static IOnspringClient _client; + private static GetAppByIdRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAppByIdRequestBuilder(_client, _appId); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var builder = new GetAppByIdRequestBuilder(_client, _appId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appId, builder.AppId); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new App(), + }; + + _client + .GetAppAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs new file mode 100644 index 0000000..26da0d3 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAppsByIdsRequestBuilderTests + { + private static readonly IEnumerable _appIds = new[] { 1, 2, 3 }; + private static IOnspringClient _client; + private static GetAppsByIdsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAppsByIdsRequestBuilder(_client, _appIds); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var builder = new GetAppsByIdsRequestBuilder(_client, _appIds); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appIds, builder.AppIds); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetAppsResponse(), + }; + + _client + .GetAppsAsync(Arg.Any>()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs new file mode 100644 index 0000000..bfcde36 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAppsRequestBuilderTests + { + private static readonly int _pageNumber = 1; + private static readonly int _appId = 1; + private static readonly IEnumerable _appIds = new[] { 1, 2, 3 }; + private static IOnspringClient _client; + private static GetAppsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAppsRequestBuilder(_client); + } + + [TestMethod] + public void ForPage_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() + { + var builder = _builder.ForPage(_pageNumber); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_pageNumber, builder.PageNumber); + } + + [TestMethod] + public void WithIds_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() + { + var builder = _builder.WithIds(_appIds); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appIds, builder.AppIds); + } + + [TestMethod] + public void WithId_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() + { + var builder = _builder.WithId(_appId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appId, builder.AppId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetPagedAppsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetPagedAppsRequestBuilderTests.cs new file mode 100644 index 0000000..10458df --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetPagedAppsRequestBuilderTests.cs @@ -0,0 +1,64 @@ +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + + public class GetPagedAppsRequestBuilderTests + { + private static readonly int _pageNumber = 1; + private static IOnspringClient _client; + private static GetPagedAppsRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetPagedAppsRequestBuilder(_client, _pageNumber); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet() + { + var builder = new GetPagedAppsRequestBuilder(_client, _pageNumber); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_pageNumber, builder.PageNumber); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldSetPageSizeProperty() + { + var pageSize = 5; + + _builder.WithPageSize(pageSize); + + Assert.AreEqual(pageSize, _builder.PageSize); + } + + [TestMethod] + public async Task SendAsync_WhenCalled_ItShouldReturnAnApiResponse() + { + var apiResponse = new ApiResponse + { + StatusCode = HttpStatusCode.OK, + Value = new GetPagedAppsResponse(), + }; + + _client + .GetAppsAsync(Arg.Any()) + .Returns(apiResponse); + + var result = await _builder.SendAsync(); + + Assert.AreEqual(apiResponse, result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs index 59cbf6d..856e0af 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs @@ -35,9 +35,9 @@ public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() } [TestMethod] - public void ForPageNumber_WhenCalled_ItShouldSetPageNumberProperty() + public void ForPage_WhenCalled_ItShouldSetPageNumberProperty() { - _builder.ForPageNumber(_pageNumber); + _builder.ForPage(_pageNumber); Assert.AreEqual(_pageNumber, _builder.PageNumber); } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs index 692800d..8f9cafb 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs @@ -39,11 +39,11 @@ public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() } [TestMethod] - public void ForPageNumber_WhenCalled_ItShouldSetPageNumberProperty() + public void ForPage_WhenCalled_ItShouldSetPageNumberProperty() { var pageNumber = 2; - _builder.ForPageNumber(pageNumber); + _builder.ForPage(pageNumber); Assert.AreEqual(pageNumber, _builder.PageNumber); } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs index 9506239..f217aad 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs @@ -33,9 +33,9 @@ public void FromApp_WhenCalled_ItShouldSetAppIdProperty() } [TestMethod] - public void ForPageNumber_WhenCalled_ItShouldSetPageNumberProperty() + public void ForPage_WhenCalled_ItShouldSetPageNumberProperty() { - _builder.ForPageNumber(_pageNumber); + _builder.ForPage(_pageNumber); Assert.AreEqual(_pageNumber, _builder.PageNumber); } diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs new file mode 100644 index 0000000..317cc99 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetAppByIdRequestBuilder + { + int AppId { get; } + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs new file mode 100644 index 0000000..e9dc3fb --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetAppsByIdsRequestBuilder + { + IEnumerable AppIds { get; } + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsRequestBuilder.cs new file mode 100644 index 0000000..32a6aef --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsRequestBuilder.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetAppsRequestBuilder + { + IGetPagedAppsRequestBuilder ForPage(int pageNumber); + IGetAppsByIdsRequestBuilder WithIds(IEnumerable appIds); + IGetAppByIdRequestBuilder WithId(int appId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs new file mode 100644 index 0000000..30f39eb --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Models; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetPagedAppsRequestBuilder + { + int PageNumber { get; } + int PageSize { get; } + IGetPagedAppsRequestBuilder WithPageSize(int pageSize); + Task> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs index f20129a..fd28f03 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs @@ -10,7 +10,7 @@ public interface IGetFieldsByAppRequestBuilder int AppId { get; } int PageNumber { get; } int PageSize { get; } - IGetFieldsByAppRequestBuilder ForPageNumber(int pageNumber); + IGetFieldsByAppRequestBuilder ForPage(int pageNumber); IGetFieldsByAppRequestBuilder WithPageSize(int pageSize); Task> SendAsync(); Task> SendAsync(Action options); diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index 234a2fb..5aeea6a 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -15,6 +15,6 @@ public interface IOnspringRequestBuilder IDeleteFileRequestBuilder ToDeleteFile(); IAddFileRequestBuilder ToAddFile(); IGetFieldsRequestBuilder ToGetFields(); - // TODO: ToGetApps() + IGetAppsRequestBuilder ToGetApps(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs index f725f87..eca7900 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs @@ -17,7 +17,7 @@ public interface IQueryRecordsByAppPagedRequestBuilder DataFormat Format { get; } Task> SendAsync(); Task> SendAsync(Action options); - IQueryRecordsByAppPagedRequestBuilder ForPageNumber(int pageNumber); + IQueryRecordsByAppPagedRequestBuilder ForPage(int pageNumber); IQueryRecordsByAppPagedRequestBuilder WithPageSize(int pageSize); IQueryRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds); IQueryRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat); diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs index fb3b3e9..dcddfba 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs @@ -10,7 +10,7 @@ public interface IGetReportsByAppRequestBuilder int AppId { get; } int PageNumber { get; } int PageSize { get; } - IGetReportsByAppRequestBuilder ForPageNumber(int pageNumber); + IGetReportsByAppRequestBuilder ForPage(int pageNumber); IGetReportsByAppRequestBuilder WithPageSize(int pageNumber); Task> SendAsync(); Task> SendAsync(Action options); diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs new file mode 100644 index 0000000..f78afb8 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs @@ -0,0 +1,22 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetAppByIdRequestBuilder : IGetAppByIdRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + + internal GetAppByIdRequestBuilder(IOnspringClient client, int appId) + { + _client = client; + AppId = appId; + } + + public async Task> SendAsync() + { + return await _client.GetAppAsync(AppId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs new file mode 100644 index 0000000..c394e7d --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetAppsByIdsRequestBuilder : IGetAppsByIdsRequestBuilder + { + private readonly IOnspringClient _client; + public IEnumerable AppIds { get; private set; } + + internal GetAppsByIdsRequestBuilder(IOnspringClient client, IEnumerable appIds) + { + _client = client; + AppIds = appIds; + } + + public async Task> SendAsync() + { + return await _client.GetAppsAsync(AppIds); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs new file mode 100644 index 0000000..c6e4623 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetAppsRequestBuilder : IGetAppsRequestBuilder + { + private readonly IOnspringClient _client; + + internal GetAppsRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetPagedAppsRequestBuilder ForPage(int pageNumber) + { + return new GetPagedAppsRequestBuilder(_client, pageNumber); + } + + public IGetAppsByIdsRequestBuilder WithIds(IEnumerable appIds) + { + return new GetAppsByIdsRequestBuilder(_client, appIds); + } + + public IGetAppByIdRequestBuilder WithId(int appId) + { + return new GetAppByIdRequestBuilder(_client, appId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs new file mode 100644 index 0000000..bb06941 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs @@ -0,0 +1,29 @@ +using System.Threading.Tasks; +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetPagedAppsRequestBuilder : IGetPagedAppsRequestBuilder + { + private readonly IOnspringClient _client; + public int PageNumber { get; private set; } + public int PageSize { get; private set; } = 50; + + internal GetPagedAppsRequestBuilder(IOnspringClient client, int pageNumber) + { + _client = client; + PageNumber = pageNumber; + } + + public IGetPagedAppsRequestBuilder WithPageSize(int pageSize) + { + PageSize = pageSize; + return this; + } + + public async Task> SendAsync() + { + return await _client.GetAppsAsync(new PagingRequest(PageNumber, PageSize)); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs index 8dc05b3..20c95d7 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs @@ -17,7 +17,7 @@ internal GetFieldsByAppRequestBuilder(IOnspringClient client, int appId) AppId = appId; } - public IGetFieldsByAppRequestBuilder ForPageNumber(int pageNumber) + public IGetFieldsByAppRequestBuilder ForPage(int pageNumber) { PageNumber = pageNumber; return this; diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index d59d794..9a232f6 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -75,5 +75,10 @@ public IGetFieldsRequestBuilder ToGetFields() { return new GetFieldsRequestBuilder(_client); } + + public IGetAppsRequestBuilder ToGetApps() + { + return new GetAppsRequestBuilder(_client); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs index ab90181..3e5d70e 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs @@ -24,7 +24,7 @@ internal QueryRecordsByAppPagedRequestBuilder(IOnspringClient client, int appId, Filter = filter; } - public IQueryRecordsByAppPagedRequestBuilder ForPageNumber(int pageNumber) + public IQueryRecordsByAppPagedRequestBuilder ForPage(int pageNumber) { PageNumber = pageNumber; return this; diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs index 37db3ed..6ff99f1 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs @@ -22,7 +22,7 @@ public IGetReportsByAppRequestBuilder FromApp(int appId) return this; } - public IGetReportsByAppRequestBuilder ForPageNumber(int pageNumber) + public IGetReportsByAppRequestBuilder ForPage(int pageNumber) { PageNumber = pageNumber; return this; From 414e6b370d57cb93e60528840149080a7318b188 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sat, 23 Sep 2023 23:56:34 -0500 Subject: [PATCH 091/168] tests: update OnspringClientTests --- .../Tests/Integration/OnspringClientTests.cs | 3 ++- Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs index 298282b..7b4cf1b 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs @@ -1,4 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; using Onspring.API.SDK.Tests.Infrastructure; using System; @@ -107,7 +108,7 @@ public void CreateRequest_WhenCalled_ItShouldReturnAnInstanceOfAnOnspringRequest { var client = new OnspringClient(_testConfiguration.ApiKey, new HttpClient { BaseAddress = new Uri(_testConfiguration.BaseAddress) }); var request = client.CreateRequest(); - Assert.IsInstanceOfType(request, typeof(OnspringRequestBuilder)); + Assert.IsInstanceOfType(request); } } } diff --git a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs index c87ae69..9b16388 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit @@ -13,7 +14,7 @@ public void CreateRequest_WhenCalled_ItShouldReturnAnOnspringRequestInstance() var client = new OnspringClient("https://api.onspring.com", "key"); var request = client.CreateRequest(); - Assert.IsInstanceOfType(request); + Assert.IsInstanceOfType(request); } } } \ No newline at end of file From 78eeba7ccae159e76f73302f673ca09b94fd3711 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:15:45 -0500 Subject: [PATCH 092/168] docs: add xml comments to IOnspringRequestBuilder interface --- .../Fluent/IOnspringRequestBuilder.cs | 72 +++++++++++++++++++ .../Models/Fluent/OnspringRequestBuilder.cs | 1 + 2 files changed, 73 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index 5aeea6a..a8b262b 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -1,20 +1,92 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder interface for creating various types of Onspring API requests. + /// public interface IOnspringRequestBuilder { + /// + /// Creates a builder for checking the connection to the Onspring API. + /// + /// A builder instance for checking the connection that implements the interface. IConnectionRequestBuilder ToCheckConnection(); + + /// + /// Creates a builder for retrieving records from Onspring. + /// + /// A builder instance for retrieving records that implements the interface. IGetRecordsRequestBuilder ToGetRecords(); + + /// + /// Creates a builder for deleting records in Onspring. + /// + /// A builder instance for deleting records that implements the interface. IDeleteRecordsRequestBuilder ToDeleteRecords(); + + /// + /// Creates a builder for saving a record in Onspring. + /// + /// A builder instance for saving records that implements the interface. ISaveRecordRequestBuilder ToSaveRecord(); + + /// + /// Creates a builder for retrieving reports from Onspring. + /// + /// A builder instance for retrieving reports that implements the interface. IGetReportsByAppRequestBuilder ToGetReports(); + + /// + /// Creates a builder for retrieving report data from Onspring. + /// + /// A builder instance for retrieving report data that implements the interface. IGetReportRequestBuilder ToGetReportData(); + + /// + /// Creates a builder for saving a list value in Onspring. + /// + /// A builder instance for saving list values that implements the interface. ISaveListValueRequestBuilder ToSaveListValue(); + + /// + /// Creates a builder for deleting a list value in Onspring. + /// + /// A builder instance for deleting list values that implements the interface. IDeleteListValueRequestBuilder ToDeleteListValue(); + + /// + /// Creates a builder for retrieving files from Onspring. + /// + /// A builder instance for retrieving files that implements the interface. IGetFileRequestBuilder ToGetFile(); + + /// + /// Creates a builder for retrieving file information from Onspring. + /// + /// A builder instance for retrieving file information that implements the interface. IGetFileInfoRequestBuilder ToGetFileInfo(); + + /// + /// Creates a builder for deleting a file in Onspring. + /// + /// A builder instance for deleting files that implements the interface. IDeleteFileRequestBuilder ToDeleteFile(); + + /// + /// Creates a builder for adding a file in Onspring. + /// + /// A builder instance for adding files that implements the interface. IAddFileRequestBuilder ToAddFile(); + + /// + /// Creates a builder for retrieving fields from Onspring. + /// + /// A builder instance for retrieving fields that implements the interface. IGetFieldsRequestBuilder ToGetFields(); + + /// + /// Creates a builder for retrieving apps from Onspring. + /// + /// A builder instance for retrieving apps that implements the interface. IGetAppsRequestBuilder ToGetApps(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index 9a232f6..ecc066f 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -2,6 +2,7 @@ namespace Onspring.API.SDK.Models.Fluent { + /// public class OnspringRequestBuilder : IOnspringRequestBuilder { private readonly IOnspringClient _client; From aa3723ef0d07744de4f02e8ce3c6bcb7171574fd Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:21:30 -0500 Subject: [PATCH 093/168] docs: add xml comments to IConnectionRequestBuilder interface --- Onspring.API.SDK/IOnspringClient.cs | 1 - .../Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs | 7 +++++++ .../Models/Fluent/Ping/ConnectionRequestBuilder.cs | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index ed800e9..bd935da 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -1,7 +1,6 @@ using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; -using Onspring.API.SDK.Models.Fluent; using System; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs index 5ce466d..c9624c1 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs @@ -2,8 +2,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder interface for sending a connection request to the Onspring API. + /// public interface IConnectionRequestBuilder { + /// + /// Asynchronously sends the connection request to the Onspring API. + /// + /// A representing the asynchronous operation. The result is a boolean indicating the success of the connection. Task SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs index 2244c26..5b9c8d8 100644 --- a/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs @@ -3,6 +3,7 @@ namespace Onspring.API.SDK.Models.Fluent { + /// public class ConnectionRequestBuilder : IConnectionRequestBuilder { private readonly IOnspringClient _client; From f40e5f6809f7d5063d9846cd6a2ebbba67437438 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:24:42 -0500 Subject: [PATCH 094/168] docs: formatted migration doc --- docs/migrations/2-to-30.md | 88 ++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 38 deletions(-) diff --git a/docs/migrations/2-to-30.md b/docs/migrations/2-to-30.md index 574c71b..1f1effb 100644 --- a/docs/migrations/2-to-30.md +++ b/docs/migrations/2-to-30.md @@ -7,44 +7,44 @@ This SDK upgrade will allow the SDK to communicate with the V2 Onspring Client A ## What's New? - Client changes: - - `HttpHelper` has been replaced with `OnspringClient` and moved to the root namespace: `Onspring.API.SDK`. - - Added ability to supply HttpClient instance. - - Added ability to customize serialization of JSON. - - Added interface `IOnspringClient` to allow for easier dependency injection/mocking. - - Errors are no longer raised on an unsuccessful API response. - - Added ability to created/update/delete list items. + - `HttpHelper` has been replaced with `OnspringClient` and moved to the root namespace: `Onspring.API.SDK`. + - Added ability to supply HttpClient instance. + - Added ability to customize serialization of JSON. + - Added interface `IOnspringClient` to allow for easier dependency injection/mocking. + - Errors are no longer raised on an unsuccessful API response. + - Added ability to created/update/delete list items. - Request changes: - - The majority of request objects have been renamed/modified/restructured. - - Paging request added to allow for paged requests. + - The majority of request objects have been renamed/modified/restructured. + - Paging request added to allow for paged requests. - Response changes: - - All client responses (other than CanConnect/Async) are wrapped in an `ApiResponse` wrapper class. - - This allows clients to determine how they want to handle any API response, as well as including a response message, if possible. - - Paged responses added for endpoints that allow retrieval of data. - - Methods that get data by their identifiers do not include paging, since a specific set of data is requested. - - Record result values have been consolidated into the `Onspring.API.SDK.Models` namespace. + - All client responses (other than CanConnect/Async) are wrapped in an `ApiResponse` wrapper class. + - This allows clients to determine how they want to handle any API response, as well as including a response message, if possible. + - Paged responses added for endpoints that allow retrieval of data. + - Methods that get data by their identifiers do not include paging, since a specific set of data is requested. + - Record result values have been consolidated into the `Onspring.API.SDK.Models` namespace. - New features: - - Apps - - Get individual app info. - - Get a batch of apps. - - Paging around getting all apps. - - Fields - - Get fields by their identifier. - - Get a batch of fields. - - Paging around getting all fields for app. - - Files - - Get a file's info without actually getting the file. - - Delete a file. - - Lists - - Add/Update list item. - - Remove list item. - - Records - - Create and update record consolidated into `SaveRecordAsync`. - - Separate method for querying records, with paging. - - Delete batch of records. - - Get batch of records. - - Paging around getting all records for app. - - Reports - - Paging around getting all reports for app. + - Apps + - Get individual app info. + - Get a batch of apps. + - Paging around getting all apps. + - Fields + - Get fields by their identifier. + - Get a batch of fields. + - Paging around getting all fields for app. + - Files + - Get a file's info without actually getting the file. + - Delete a file. + - Lists + - Add/Update list item. + - Remove list item. + - Records + - Create and update record consolidated into `SaveRecordAsync`. + - Separate method for querying records, with paging. + - Delete batch of records. + - Get batch of records. + - Paging around getting all records for app. + - Reports + - Paging around getting all reports for app. - Support for netstandard2.1 - Removed all synchronous API calls. @@ -55,6 +55,7 @@ Version 3.x of the SDK will not work with the V1 API, due to request/response ob ## API address Change With the V2 Client API, we've approached versioning using header values, which means we're going to need to change the legacy path, as it includes version as part of the path. Specifically, we just need to remove the `v1` portion of the original URL. + - `https://api.onspring.com/v1` should be changed to `https://api.onspring.com/` ## Breaking changes @@ -64,11 +65,13 @@ Due to the amount of breaking changes within the SDK itself, this section will b ### App breaking changes `GetAppsAsync` response object has changed from `IReadOnlyList` to `ApiResponse` + - Additionally, we've added an optional parameter to the request for paging. ### Field breaking changes `GetAppFieldsAsync` has been replaced with `GetFieldsForAppAsync`. + - Response type changed from `IReadOnlyList` to `ApiResponse` - Additionally, the request/response has changed to allow for paging. @@ -84,6 +87,7 @@ var fields = getFieldsResponse.Value.Items; ``` `GetAppFieldAsync` has been replaced with `GetFieldAsync` + - Response type changed from `Field` to `ApiResponse` ```C# @@ -100,6 +104,7 @@ var field = getFieldsResponse.Value; ### File breaking changes `GetFileFromRecordAsync` has been replaced with `GetFileAsync`. + - AppId is no longer needed in order to get a file. - Response type changed from `FileResult` to `ApiResponse`. @@ -118,6 +123,7 @@ var fileResult = getFileResponse.Value; ``` `AddFileToRecordAsync` has been replaced with `SaveFileAsync`. + - Overload to load from file has been removed. - AppId is no longer needed in order to save a file. - Response type changed from `FileResult` to `ApiResponse`. @@ -146,6 +152,7 @@ var newFileId = saveResponse.Value.Id; ### Record breaking changes `CreateAppRecordAsync` and `UpdateAppRecordAsync` have been replaced with `SaveRecordAsync`. + - Response type changed from `AddEditResult` to `ApiResponse` ```C# @@ -162,9 +169,10 @@ var saveRequest = new SaveRecordRequest // ... }; var saveResponse = await onspringClient.SaveRecordAsync(saveRequest); -```` +``` `GetAppRecordsAsync` has been replaced with `GetRecordsForAppAsync`. + - Response type changed from `IReadOnlyList` to `ApiResponse`. - Additionally, the request/response has changed to allow for paging. @@ -190,6 +198,7 @@ var newFileId = saveResponse.Value.Id; ``` `GetAppRecordAsync` has been replaced with `GetRecordAsync`. + - Request parameters changed to use an object instead of multiple parameters. - Response type changed from `ResultRecord` to `ApiResponse`. @@ -207,6 +216,7 @@ var record = getResponse.Value; ``` `DeleteAppRecordAsync` has been replaced with `DeleteRecordAsync`. + - Response type changed from `DeleteResult` to `ApiResponse`. ```C# @@ -227,8 +237,9 @@ Lastly, the `As` methods for record field values no longer work as properties. I ### Report breaking changes `GetAppReportsAsync` has been replaced with `GetReportsForAppAsync`. + - Response changed from `IReadOnlyList` to `ApiResponse` -- Additionally, the request/response has changed to allow for paging. +- Additionally, the request/response has changed to allow for paging. ```C# const int appId = 1; @@ -242,6 +253,7 @@ var reports = getFieldsResponse.Value.Items; ``` `GetReportDataAsync` has been replaced with `GetReportAsync`. + - Response type changed from `ReportData` to `ApiResponse` ```C# @@ -255,4 +267,4 @@ var reportData = await httpHelper.GetReportDataAsync(reportId, dataType, dataFor // New var getReportResponse = await onspringClient.GetReportAsync(reportId, dataType, dataFormat); var reportData = getReportResponse.Value; -``` \ No newline at end of file +``` From df564e4bf035634ecb1d8a90f6a2633e3e38de7b Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 10:33:39 -0500 Subject: [PATCH 095/168] docs: add comments to FilterOperator class --- Onspring.API.SDK/Enums/FilterOperator.cs | 83 ++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/Onspring.API.SDK/Enums/FilterOperator.cs b/Onspring.API.SDK/Enums/FilterOperator.cs index 1d1523d..b1f7b7b 100644 --- a/Onspring.API.SDK/Enums/FilterOperator.cs +++ b/Onspring.API.SDK/Enums/FilterOperator.cs @@ -2,16 +2,39 @@ namespace Onspring.API.SDK.Enums { + /// + /// Represents a base class for enumerations with common properties. + /// public abstract class Enumeration : IComparable { + /// + /// Gets the name of the enumeration. + /// public string Name { get; private set; } + /// + /// Gets the unique identifier of the enumeration. + /// public int Id { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The unique identifier of the enumeration. + /// The name of the enumeration. protected Enumeration(int id, string name) => (Id, Name) = (id, name); + /// + /// Converts the enumeration to its string representation (the name). + /// + /// The name of the enumeration. public override string ToString() => Name; + /// + /// Determines whether the current object is equal to another object. + /// + /// The object to compare with. + /// True if the objects are equal; otherwise, false. public override bool Equals(object obj) { if (obj is Enumeration otherValue) @@ -25,27 +48,87 @@ public override bool Equals(object obj) return false; } + /// + /// Gets a hash code for the enumeration. + /// + /// A hash code for the enumeration. public override int GetHashCode() { return Id.GetHashCode(); } + /// + /// Compares the current instance with another object and returns an integer + /// that indicates whether the current instance precedes, follows, or is equivalent + /// to the other object. + /// + /// An object to compare with this instance. + /// + /// A value that indicates the relative order of the objects being compared. + /// public int CompareTo(object other) => Id.CompareTo(((Enumeration)other).Id); } + /// + /// Represents a filter operator enumeration with predefined values. + /// public class FilterOperator : Enumeration { + /// + /// Represents the "eq" filter operator. + /// public static FilterOperator Equal { get; } = new FilterOperator(1, "eq"); + + /// + /// Represents the "ne" filter operator. + /// public static FilterOperator NotEqual { get; } = new FilterOperator(2, "ne"); + + /// + /// Represents the "contains" filter operator. + /// public static FilterOperator Contains { get; } = new FilterOperator(3, "contains"); + + /// + /// Represents the "isnull" filter operator. + /// public static FilterOperator IsNull { get; } = new FilterOperator(4, "isnull"); + + /// + /// Represents the "notnull" filter operator. + /// public static FilterOperator NotNull { get; } = new FilterOperator(5, "notnull"); + + /// + /// Represents the "gt" filter operator. + /// public static FilterOperator GreaterThan { get; } = new FilterOperator(6, "gt"); + + /// + /// Represents the "lt" filter operator. + /// public static FilterOperator LessThan { get; } = new FilterOperator(7, "lt"); + + /// + /// Represents the "and" filter operator. + /// public static FilterOperator And { get; } = new FilterOperator(8, "and"); + + /// + /// Represents the "or" filter operator. + /// public static FilterOperator Or { get; } = new FilterOperator(9, "or"); + + /// + /// Represents the "not" filter operator. + /// public static FilterOperator Not { get; } = new FilterOperator(10, "not"); + /// + /// Initializes a new instance of the class. + /// + /// The unique identifier of the filter operator. + /// The name of the filter operator. private FilterOperator(int id, string name) : base(id, name) { } From cea8428d3408c88f597de9346dc51585278d773b Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 10:39:54 -0500 Subject: [PATCH 096/168] docs: add comments to Filter class --- Onspring.API.SDK/Models/Filter.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Onspring.API.SDK/Models/Filter.cs b/Onspring.API.SDK/Models/Filter.cs index a8217eb..a4f83cf 100644 --- a/Onspring.API.SDK/Models/Filter.cs +++ b/Onspring.API.SDK/Models/Filter.cs @@ -3,13 +3,26 @@ namespace Onspring.API.SDK.Models { + /// + /// Represents a filter used for querying data. + /// public class Filter { + /// + /// Gets or sets the identifier of the field to filter on. + /// public int FieldId { get; set; } + + /// + /// Gets or sets the filter operator to apply to the field. + /// public FilterOperator Operator { get; set; } private object filterValue; + /// + /// Gets or sets the value to filter against. + /// public object Value { get { return filterValue; } @@ -24,8 +37,17 @@ public object Value } } + /// + /// Initializes a new instance of the class. + /// internal Filter() { } + /// + /// Initializes a new instance of the class with specified values. + /// + /// The identifier of the field to filter on. + /// The filter operator to apply to the field. + /// The value to filter against. public Filter(int fieldId, FilterOperator filterOperator, object value) { FieldId = fieldId; @@ -33,6 +55,10 @@ public Filter(int fieldId, FilterOperator filterOperator, object value) Value = value; } + /// + /// Returns a string representation of the filter. + /// + /// A string representing the filter. public override string ToString() { if (Value == null) From 861628d351b8e4abcbe5e8cac4faa4281e49db4a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 10:46:47 -0500 Subject: [PATCH 097/168] docs: add comments to GetRecordsRequestBuilder --- .../Fluent/Records/Get/IGetRecordsRequestBuilder.cs | 8 ++++++++ Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs | 7 +++++++ .../Models/Fluent/Records/Get/GetRecordsRequestBuilder.cs | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs index 355ad78..b4aaeb2 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve records. + /// public interface IGetRecordsRequestBuilder { + /// + /// Specifies the app from which to retrieve records. + /// + /// The unique identifier of the app. + /// A builder for further configuration of the request. IGetRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index ecc066f..d1de48c 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -2,11 +2,18 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing Onspring API requests. + /// /// public class OnspringRequestBuilder : IOnspringRequestBuilder { private readonly IOnspringClient _client; + /// + /// Initializes a new instance of the class. + /// + /// The Onspring client to use for making API requests. internal OnspringRequestBuilder(IOnspringClient client) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsRequestBuilder.cs index 4e74e84..12aaef4 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsRequestBuilder.cs @@ -2,10 +2,18 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve records. + /// + /// public class GetRecordsRequestBuilder : IGetRecordsRequestBuilder { private readonly IOnspringClient _client; + /// + /// Initializes a new instance of the class. + /// + /// The Onspring client to use for making API requests. internal GetRecordsRequestBuilder(IOnspringClient client) { _client = client; From 32b08fad92aca3d9c12d9485732a15e2fc82e41b Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:01:46 -0500 Subject: [PATCH 098/168] docs: add comments to QueryRecordsByAppPagedRequestBuilder --- .../IQueryRecordsByAppPagedRequestBuilder.cs | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs index eca7900..7515ce0 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs @@ -7,19 +7,84 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Builds a request to query records by application. + /// public interface IQueryRecordsByAppPagedRequestBuilder { + /// + /// Gets the application ID. + /// int AppId { get; } + + /// + /// Gets the filter. + /// string Filter { get; } + + /// + /// Gets the page number. + /// int PageNumber { get; } + + /// + /// Gets the page size. + /// int PageSize { get; } + + /// + /// Gets the field IDs. + /// IEnumerable FieldIds { get; } + + /// + /// Gets the data format. + /// DataFormat Format { get; } + + /// + /// Sends the request asynchronously. + /// + /// An awaitable task that returns an API response when complete. + /// + /// Task> SendAsync(); + + /// + /// Sends the request asynchronously with the specified options. + /// + /// The options to use when sending the request. + /// An awaitable task that returns an API response when complete. + /// + /// Task> SendAsync(Action options); + + /// + /// Sets the page number to retrieve. + /// + /// The page number to retrieve + /// A builder for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder ForPage(int pageNumber); + + /// + /// Sets the page size to retrieve. + /// + /// The size of page to retrieve + /// A builder for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder WithPageSize(int pageSize); + + /// + /// Sets the field IDs to retrieve. + /// + /// The field IDs to retrieve + /// A builder for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds); + + /// + /// Sets the format of the data to retrieve. + /// + /// The format of the data to retrieve + /// A builder for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat); } From 52815559cca3c7f620f40bfba59d47d8208ac420 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:02:02 -0500 Subject: [PATCH 099/168] docs: add comments to QueryRecordsByAppPagedRequestBuilder --- .../Get/QueryRecordsByAppPagedRequestBuilder.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs index 3e5d70e..c45dac7 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs @@ -7,6 +7,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// A builder for constructing requests to query records from an app. + /// + /// public class QueryRecordsByAppPagedRequestBuilder : IQueryRecordsByAppPagedRequestBuilder { private readonly IOnspringClient _client; @@ -17,6 +21,12 @@ public class QueryRecordsByAppPagedRequestBuilder : IQueryRecordsByAppPagedReque public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); public DataFormat Format { get; private set; } = DataFormat.Raw; + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. + /// The unique identifier of the app from which to retrieve records. + /// The filter to apply to the request. internal QueryRecordsByAppPagedRequestBuilder(IOnspringClient client, int appId, string filter) { _client = client; From 39b1dd1ad81f0354ed87b6ce56e45144dec1cee7 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:05:11 -0500 Subject: [PATCH 100/168] docs: Add comments to QueryRecordsByAppPagedRequestBuilderOptions --- ...ryRecordsByAppPagedRequestBuilderOptions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs index 34b1917..c97948c 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs @@ -4,11 +4,29 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents options for building paged requests to query records by application. + /// public class QueryRecordsByAppPagedRequestBuilderOptions { + /// + /// Gets or sets the page number for the paged request. Default is 1. + /// public int PageNumber { get; set; } = 1; + + /// + /// Gets or sets the page size for the paged request. Default is 50. + /// public int PageSize { get; set; } = 50; + + /// + /// Gets or sets the field IDs to include in the query. Default is an empty collection. + /// public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + + /// + /// Gets or sets the data format for the query results. Default is . + /// public DataFormat Format { get; set; } = DataFormat.Raw; } } \ No newline at end of file From 9c70887866dcfe39653dd27792aadb3b845e7cd9 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:10:47 -0500 Subject: [PATCH 101/168] docs: add comments to GetRecordsByIdsRequestBuilder --- .../Get/IGetRecordsByIdsRequestBuilder.cs | 45 +++++++++++++++++++ .../Get/GetRecordsByIdsRequestBuilder.cs | 10 +++++ .../GetRecordsByIdsRequestBuilderOptions.cs | 10 +++++ 3 files changed, 65 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs index 5fa7ae0..166e52d 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs @@ -7,15 +7,60 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// A builder for constructing requests to get records by IDs. + /// public interface IGetRecordsByIdsRequestBuilder { + /// + /// Gets the app from which to retrieve records. + /// int AppId { get; } + + /// + /// Gets the IDs of the records to retrieve. + /// IEnumerable RecordIds { get; } + + /// + /// Gets the IDs of the fields to retrieve. + /// IEnumerable FieldIds { get; } + + /// + /// Gets the data format of the response. + /// DataFormat Format { get; } + + /// + /// Sends the request asynchronously. + /// + /// An awaitable task that returns an API response when complete. + /// + /// Task> SendAsync(); + + /// + /// Sends the request asynchronously with the specified options. + /// + /// The options to use when sending the request. + /// An awaitable task that returns an API response when complete. + /// + /// Task> SendAsync(Action options); + + /// + /// Specifies the IDs of the fields to retrieve. + /// + /// The IDs of the fields to retrieve. + /// A builder for further configuration of the request. IGetRecordsByIdsRequestBuilder WithFieldIds(IEnumerable fieldIds); + + /// + /// Specifies the data format of the response. + /// + /// The data format of the response. + /// A builder for further configuration of the request. IGetRecordsByIdsRequestBuilder WithFormat(DataFormat dataFormat); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs index 486e720..ba8aeaf 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs @@ -7,6 +7,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// A builder for constructing requests to get records by IDs. + /// + /// public class GetRecordsByIdsRequestBuilder : IGetRecordsByIdsRequestBuilder { private readonly IOnspringClient _client; @@ -15,6 +19,12 @@ public class GetRecordsByIdsRequestBuilder : IGetRecordsByIdsRequestBuilder public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); public DataFormat Format { get; private set; } = DataFormat.Raw; + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. + /// The unique identifier of the app from which to retrieve records. + /// The unique identifiers of the records to retrieve. internal GetRecordsByIdsRequestBuilder(IOnspringClient client, int appId, IEnumerable recordIds) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs index 0dc300b..30cf4d2 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs @@ -4,9 +4,19 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents options for building requests to get records by IDs. + /// public class GetRecordsByIdsRequestBuilderOptions { + /// + /// Gets or sets the IDs of the fields to retrieve. Default is an empty collection. + /// public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + + /// + /// Gets or sets the data format for the query results. Default is . + /// public DataFormat Format { get; set; } = DataFormat.Raw; } } \ No newline at end of file From 3f5d8928ade0879504f6cfa5b43ab529975327ad Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:21:17 -0500 Subject: [PATCH 102/168] docs: add comments to GetRecordsByAppRequestBuilder --- .../Fluent/Ping/IConnectionRequestBuilder.cs | 2 +- .../Get/IGetRecordsByAppRequestBuilder.cs | 41 +++++++++++++++++++ .../Get/IGetRecordsByIdsRequestBuilder.cs | 10 ++--- .../Records/Get/IGetRecordsRequestBuilder.cs | 1 + .../IQueryRecordsByAppPagedRequestBuilder.cs | 2 +- .../Get/GetRecordsByAppRequestBuilder.cs | 8 ++++ 6 files changed, 55 insertions(+), 9 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs index c9624c1..d1475b3 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Ping/IConnectionRequestBuilder.cs @@ -10,7 +10,7 @@ public interface IConnectionRequestBuilder /// /// Asynchronously sends the connection request to the Onspring API. /// - /// A representing the asynchronous operation. The result is a boolean indicating the success of the connection. + /// A representing the asynchronous operation. The result is a boolean indicating the success of the connection. Task SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs index 4fa0ec5..37723f4 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs @@ -4,13 +4,54 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to get records by app. + /// public interface IGetRecordsByAppRequestBuilder { + /// + /// Gets the app from which to retrieve records. + /// int AppId { get; } + + /// + /// Specifies the page number to retrieve. + /// + /// The page number to retrieve. Must be greater than zero. + /// A builder for further configuration of the request. + /// IGetRecordsByAppPagedRequestBuilder ForPage(int pageNumber); + + /// + /// Specifies the record ID to retrieve. + /// + /// The ID of the record to retrieve. + /// A builder for further configuration of the request. + /// IGetRecordByIdRequestBuilder WithId(int recordId); + + /// + /// Specifies the IDs of the records to retrieve. + /// + /// The IDs of the records to retrieve. + /// A builder for further configuration of the request. + /// IGetRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds); + + /// + /// Specifies the filter to be used to query records. + /// + /// The filter to be used to query record + /// A builder for further configuration of the request. + /// IQueryRecordsByAppPagedRequestBuilder WithFilter(string filter); + + /// + /// Specifies the filter to be used to query records. + /// + /// An action that constructs the filter to be used to query record + /// A builder for further configuration of the request. + /// IQueryRecordsByAppPagedRequestBuilder WithFilter(Action filter); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs index 166e52d..0801e0e 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs @@ -8,7 +8,7 @@ namespace Onspring.API.SDK.Interfaces.Fluent { /// - /// A builder for constructing requests to get records by IDs. + /// Represents a builder for constructing requests to get records by IDs. /// public interface IGetRecordsByIdsRequestBuilder { @@ -35,18 +35,14 @@ public interface IGetRecordsByIdsRequestBuilder /// /// Sends the request asynchronously. /// - /// An awaitable task that returns an API response when complete. - /// - /// + /// An awaitable task that returns an API response when complete. Task> SendAsync(); /// /// Sends the request asynchronously with the specified options. /// /// The options to use when sending the request. - /// An awaitable task that returns an API response when complete. - /// - /// + /// An awaitable task that returns an API response when complete. Task> SendAsync(Action options); /// diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs index b4aaeb2..ec4ad7f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs @@ -10,6 +10,7 @@ public interface IGetRecordsRequestBuilder /// /// The unique identifier of the app. /// A builder for further configuration of the request. + /// IGetRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs index 7515ce0..82c262f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs @@ -8,7 +8,7 @@ namespace Onspring.API.SDK.Interfaces.Fluent { /// - /// Builds a request to query records by application. + /// Represents a builder for constructing requests to query records from an app. /// public interface IQueryRecordsByAppPagedRequestBuilder { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs index 99057b4..24e40c1 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs @@ -4,11 +4,19 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to get records by app. + /// public class GetRecordsByAppRequestBuilder : IGetRecordsByAppRequestBuilder { private readonly IOnspringClient _client; public int AppId { get; private set; } + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. + /// The unique identifier of the app from which to retrieve records. internal GetRecordsByAppRequestBuilder(IOnspringClient client, int appId) { _client = client; From 5d2ca716eb786b08312816e96f8fcac89efd8759 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:21:40 -0500 Subject: [PATCH 103/168] docs: add comments to GetRecordsByAppRequestBuilder --- .../Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs index 24e40c1..111a8c6 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs @@ -7,6 +7,7 @@ namespace Onspring.API.SDK.Models.Fluent /// /// Represents a builder for constructing requests to get records by app. /// + /// public class GetRecordsByAppRequestBuilder : IGetRecordsByAppRequestBuilder { private readonly IOnspringClient _client; From 85c762f55446422d0085d39ad60ac6a389bf0a7e Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:27:05 -0500 Subject: [PATCH 104/168] docs: add comments to GetRecordByIdRequestBuilder --- .../Get/IGetRecordByIdRequestBuilder.cs | 41 +++++++++++++++++++ .../Get/GetRecordByIdRequestBuilder.cs | 10 +++++ .../Get/GetRecordByIdRequestBuilderOptions.cs | 10 +++++ 3 files changed, 61 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs index eec66ec..7b2346d 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs @@ -7,15 +7,56 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to get a record by ID. + /// public interface IGetRecordByIdRequestBuilder { + /// + /// Gets the app from which to retrieve records. + /// int AppId { get; } + + /// + /// Gets the ID of the record to retrieve. + /// int RecordId { get; } + + /// + /// Gets the IDs of the fields to retrieve. + /// IEnumerable FieldIds { get; } + + /// + /// Gets the data format for the response. + /// DataFormat Format { get; } + + /// + /// Sends the request asynchronously. + /// + /// An awaitable task that returns an API response when complete. Task> SendAsync(); + + /// + /// Sends the request asynchronously with the specified options. + /// + /// The options to use when sending the request. + /// An awaitable task that returns an API response when complete. Task> SendAsync(Action options); + + /// + /// Specifies the IDs of the fields to retrieve. + /// + /// The IDs of the fields to retrieve. + /// A builder for further configuration of the request. IGetRecordByIdRequestBuilder WithFieldIds(IEnumerable fieldIds); + + /// + /// Specifies the data format for the response. + /// + /// The data format for the response. + /// A builder for further configuration of the request. IGetRecordByIdRequestBuilder WithFormat(DataFormat dataFormat); } } diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs index d9e8d81..be948cf 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs @@ -7,6 +7,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to get a record by ID. + /// + /// public class GetRecordByIdRequestBuilder : IGetRecordByIdRequestBuilder { private readonly IOnspringClient _client; @@ -15,6 +19,12 @@ public class GetRecordByIdRequestBuilder : IGetRecordByIdRequestBuilder public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); public DataFormat Format { get; private set; } = DataFormat.Raw; + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. + /// The unique identifier of the app from which to retrieve records. + /// The ID of the record to retrieve. internal GetRecordByIdRequestBuilder(IOnspringClient client, int appId, int recordId) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs index 2b97cd5..55d63d5 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs @@ -4,9 +4,19 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents the options for a request to get a record by ID. + /// public class GetRecordByIdRequestBuilderOptions { + /// + /// Gets or sets the IDs of the fields to retrieve. + /// public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + + /// + /// Gets or sets the data format for the response. + /// public DataFormat Format { get; set; } = DataFormat.Raw; } } \ No newline at end of file From d4057994e2a623bacbf855e9b0d39ec7085c685a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:30:20 -0500 Subject: [PATCH 105/168] docs: more comments --- .../Records/Get/IGetRecordByIdRequestBuilder.cs | 2 +- .../Records/Get/IGetRecordsByAppRequestBuilder.cs | 14 +++++--------- .../Records/Get/IGetRecordsRequestBuilder.cs | 3 +-- .../Get/IQueryRecordsByAppPagedRequestBuilder.cs | 10 +++------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs index 7b2346d..d37f65c 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs @@ -41,7 +41,7 @@ public interface IGetRecordByIdRequestBuilder /// /// Sends the request asynchronously with the specified options. /// - /// The options to use when sending the request. + /// An action that constructs the options to use when sending the request. /// An awaitable task that returns an API response when complete. Task> SendAsync(Action options); diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs index 37723f4..093fe80 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs @@ -26,32 +26,28 @@ public interface IGetRecordsByAppRequestBuilder /// Specifies the record ID to retrieve. /// /// The ID of the record to retrieve. - /// A builder for further configuration of the request. - /// + /// A builder for further configuration of the request. IGetRecordByIdRequestBuilder WithId(int recordId); /// /// Specifies the IDs of the records to retrieve. /// /// The IDs of the records to retrieve. - /// A builder for further configuration of the request. - /// + /// A builder for further configuration of the request. IGetRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds); /// /// Specifies the filter to be used to query records. /// /// The filter to be used to query record - /// A builder for further configuration of the request. - /// + /// A builder for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder WithFilter(string filter); /// /// Specifies the filter to be used to query records. /// - /// An action that constructs the filter to be used to query record - /// A builder for further configuration of the request. - /// + /// An action that constructs the filter to be used to query record + /// A builder for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder WithFilter(Action filter); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs index ec4ad7f..34cc2f3 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs @@ -9,8 +9,7 @@ public interface IGetRecordsRequestBuilder /// Specifies the app from which to retrieve records. /// /// The unique identifier of the app. - /// A builder for further configuration of the request. - /// + /// A builder for further configuration of the request. IGetRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs index 82c262f..b06c019 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs @@ -45,18 +45,14 @@ public interface IQueryRecordsByAppPagedRequestBuilder /// /// Sends the request asynchronously. /// - /// An awaitable task that returns an API response when complete. - /// - /// + /// An awaitable task that returns an API response when complete. Task> SendAsync(); /// /// Sends the request asynchronously with the specified options. /// - /// The options to use when sending the request. - /// An awaitable task that returns an API response when complete. - /// - /// + /// An action that constructs the options to use when sending the request. + /// An awaitable task that returns an API response when complete. Task> SendAsync(Action options); /// From 28b6295fda1908d8e97094d667ee692c8bca1b4d Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:30:59 -0500 Subject: [PATCH 106/168] docs: update comments --- .../Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs index 093fe80..bb51bf8 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs @@ -18,8 +18,7 @@ public interface IGetRecordsByAppRequestBuilder /// Specifies the page number to retrieve. /// /// The page number to retrieve. Must be greater than zero. - /// A builder for further configuration of the request. - /// + /// A builder for further configuration of the request. IGetRecordsByAppPagedRequestBuilder ForPage(int pageNumber); /// From dbb9dc5873adcb1ef3ddb347617a5f72736a1f75 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:36:58 -0500 Subject: [PATCH 107/168] docs: add comments to GetRecordsByAppPagedRequestBuilder --- .../IGetRecordsByAppPagedRequestBuilder.cs | 51 +++++++++++++++++++ .../Get/GetRecordsByAppPagedRequestBuilder.cs | 12 ++++- ...tRecordsByAppPagedRequestBuilderOptions.cs | 14 +++++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs index 7157c65..9890c1e 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs @@ -7,17 +7,68 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to get records by an app. + /// public interface IGetRecordsByAppPagedRequestBuilder { + /// + /// Gets the app from which to retrieve records. + /// int AppId { get; } + + /// + /// Gets the page number to retrieve. + /// int PageNumber { get; } + + /// + /// Gets the IDs of the fields to retrieve. + /// IEnumerable FieldIds { get; } + + /// + /// Gets the data format for the response. + /// DataFormat Format { get; } + + /// + /// Gets the page size. + /// int PageSize { get; } + + /// + /// Sends the request asynchronously. + /// + /// An awaitable task that returns an API response when complete. Task> SendAsync(); + + /// + /// Sends the request asynchronously with the specified options. + /// + /// An action that constructs the options to use when sending the request. + /// An awaitable task that returns an API response when complete. Task> SendAsync(Action options); + + /// + /// Specifies the page size to retrieve. + /// + /// The size of page to retrieve + /// A builder for further configuration of the request. IGetRecordsByAppPagedRequestBuilder WithPageSize(int pageSize); + + /// + /// Specifies the IDs of the fields to retrieve. + /// + /// The IDs of the fields to retrieve. + /// A builder for further configuration of the request. IGetRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds); + + /// + /// Specifies the data format for the response. + /// + /// The data format for the response. + /// A builder for further configuration of the request. IGetRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs index 7e35c94..025431a 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs @@ -7,7 +7,11 @@ namespace Onspring.API.SDK.Models.Fluent { - public partial class GetRecordsByAppPagedRequestBuilder : IGetRecordsByAppPagedRequestBuilder + /// + /// Represents a builder for constructing requests to get records by an app. + /// + /// + public class GetRecordsByAppPagedRequestBuilder : IGetRecordsByAppPagedRequestBuilder { private readonly IOnspringClient _client; public int AppId { get; private set; } @@ -16,6 +20,12 @@ public partial class GetRecordsByAppPagedRequestBuilder : IGetRecordsByAppPagedR public DataFormat Format { get; private set; } = DataFormat.Raw; public int PageSize { get; private set; } = 50; + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. + /// The unique identifier of the app from which to retrieve records. + /// The page number to retrieve. internal GetRecordsByAppPagedRequestBuilder(IOnspringClient client, int appId, int pageNumber) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs index 34412e2..73bab41 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs @@ -4,10 +4,24 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents the options for a request to get records by an app. + /// public class GetRecordsByAppPagedRequestBuilderOptions { + /// + /// Gets or sets the IDs of the fields to retrieve. + /// public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + + /// + /// Gets or sets the data format for the response. + /// public DataFormat Format { get; set; } = DataFormat.Raw; + + /// + /// Gets or sets the page size for the paged request. Default is 50. + /// public int PageSize { get; set; } = 50; } } \ No newline at end of file From 578d05d5ce510304d72b4ada174f39788cf55b34 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:41:30 -0500 Subject: [PATCH 108/168] docs: update comments --- .../Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs | 4 ++-- .../Records/Get/IGetRecordsByAppPagedRequestBuilder.cs | 4 ++-- .../Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs | 6 +++--- .../Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs | 4 ++-- .../Fluent/Records/Get/IGetRecordsRequestBuilder.cs | 2 +- .../Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs | 5 ++--- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs index d37f65c..cbe137f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs @@ -35,14 +35,14 @@ public interface IGetRecordByIdRequestBuilder /// /// Sends the request asynchronously. /// - /// An awaitable task that returns an API response when complete. + /// An awaitable task that returns an when complete. Task> SendAsync(); /// /// Sends the request asynchronously with the specified options. /// /// An action that constructs the options to use when sending the request. - /// An awaitable task that returns an API response when complete. + /// An awaitable task that returns an when complete. Task> SendAsync(Action options); /// diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs index 9890c1e..3bcf1bd 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs @@ -40,14 +40,14 @@ public interface IGetRecordsByAppPagedRequestBuilder /// /// Sends the request asynchronously. /// - /// An awaitable task that returns an API response when complete. + /// An awaitable task that returns an when complete. Task> SendAsync(); /// /// Sends the request asynchronously with the specified options. /// /// An action that constructs the options to use when sending the request. - /// An awaitable task that returns an API response when complete. + /// An awaitable task that returns an when complete. Task> SendAsync(Action options); /// diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs index bb51bf8..4e96eca 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs @@ -18,7 +18,7 @@ public interface IGetRecordsByAppRequestBuilder /// Specifies the page number to retrieve. /// /// The page number to retrieve. Must be greater than zero. - /// A builder for further configuration of the request. + /// A for further configuration of the request. IGetRecordsByAppPagedRequestBuilder ForPage(int pageNumber); /// @@ -39,14 +39,14 @@ public interface IGetRecordsByAppRequestBuilder /// Specifies the filter to be used to query records. /// /// The filter to be used to query record - /// A builder for further configuration of the request. + /// A for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder WithFilter(string filter); /// /// Specifies the filter to be used to query records. /// /// An action that constructs the filter to be used to query record - /// A builder for further configuration of the request. + /// A for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder WithFilter(Action filter); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs index 0801e0e..cd9c0b6 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs @@ -35,14 +35,14 @@ public interface IGetRecordsByIdsRequestBuilder /// /// Sends the request asynchronously. /// - /// An awaitable task that returns an API response when complete. + /// An awaitable task that returns an when complete. Task> SendAsync(); /// /// Sends the request asynchronously with the specified options. /// /// The options to use when sending the request. - /// An awaitable task that returns an API response when complete. + /// An awaitable task that returns an when complete. Task> SendAsync(Action options); /// diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs index 34cc2f3..c0be59b 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsRequestBuilder.cs @@ -9,7 +9,7 @@ public interface IGetRecordsRequestBuilder /// Specifies the app from which to retrieve records. /// /// The unique identifier of the app. - /// A builder for further configuration of the request. + /// A for further configuration of the request. IGetRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs index b06c019..0e89a99 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs @@ -45,14 +45,14 @@ public interface IQueryRecordsByAppPagedRequestBuilder /// /// Sends the request asynchronously. /// - /// An awaitable task that returns an API response when complete. + /// An awaitable task that returns an when complete. Task> SendAsync(); /// /// Sends the request asynchronously with the specified options. /// /// An action that constructs the options to use when sending the request. - /// An awaitable task that returns an API response when complete. + /// An awaitable task that returns an when complete. Task> SendAsync(Action options); /// @@ -82,6 +82,5 @@ public interface IQueryRecordsByAppPagedRequestBuilder /// The format of the data to retrieve /// A builder for further configuration of the request. IQueryRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat); - } } \ No newline at end of file From e41dc5497f26b9b4ef64e9a1c269835dfc98c5d3 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:45:50 -0500 Subject: [PATCH 109/168] docs: add comments to DeleteRecordRequestBuilder --- .../Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs | 8 ++++++++ .../Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs index e87c4f9..547bdc5 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete records. + /// public interface IDeleteRecordsRequestBuilder { + /// + /// Specifies the app from which to delete records. + /// + /// The ID of the app from which to delete records. + /// A for further configuration of the request. IDeleteRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs index 693d10f..724eaa7 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsRequestBuilder.cs @@ -2,10 +2,18 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to delete records. + /// + /// public class DeleteRecordsRequestBuilder : IDeleteRecordsRequestBuilder { private readonly IOnspringClient _client; + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. internal DeleteRecordsRequestBuilder(IOnspringClient client) { _client = client; From 3db3a549b5bc4b0cde157eb2137a83f3c7a14b41 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:48:17 -0500 Subject: [PATCH 110/168] docs: add comments to DeleteRecordsByAppRequestBuilder --- .../IDeleteRecordsByAppRequestBuilder.cs | 18 ++++++++++++++++++ .../Delete/DeleteRecordsByAppRequestBuilder.cs | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs index 9e0b776..d544669 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs @@ -3,10 +3,28 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete records from an app. + /// public interface IDeleteRecordsByAppRequestBuilder { + /// + /// Specifies the ID of the app from which to delete records. + /// int AppId { get; } + + /// + /// Specifies the ID of the record to delete. + /// + /// The ID of the record to delete. + /// A for further configuration of the request. IDeleteRecordByIdRequestBuilder WithId(int recordId); + + /// + /// Specifies the IDs of the records to delete. + /// + /// The IDs of the records to delete. + /// A for further configuration of the request. IDeleteRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs index 71f527f..1b9af22 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs @@ -3,11 +3,20 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to delete records from an app. + /// + /// public class DeleteRecordsByAppRequestBuilder : IDeleteRecordsByAppRequestBuilder { private readonly IOnspringClient _client; public int AppId { get; private set; } + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. + /// The ID of the app from which to delete records. internal DeleteRecordsByAppRequestBuilder(IOnspringClient client, int appId) { _client = client; From c6e37d2a042e61b3dbd2a88d569accae44b83d2e Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:52:08 -0500 Subject: [PATCH 111/168] docs: add comments to DeleteRecordsByIdsRequestBuilder --- .../Delete/IDeleteRecordsByAppRequestBuilder.cs | 2 +- .../Delete/IDeleteRecordsByIdsRequestBuilder.cs | 16 +++++++++++++++- .../Delete/DeleteRecordsByIdsRequestBuilder.cs | 11 +++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs index d544669..6734c66 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs @@ -9,7 +9,7 @@ namespace Onspring.API.SDK.Interfaces.Fluent public interface IDeleteRecordsByAppRequestBuilder { /// - /// Specifies the ID of the app from which to delete records. + /// Gets the ID of the app from which to delete records. /// int AppId { get; } diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs index cbf3811..c6e1820 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs @@ -4,11 +4,25 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete records from an app by IDs. + /// public interface IDeleteRecordsByIdsRequestBuilder { + /// + /// Gets the ID of the app from which to delete records. + /// int AppId { get; } + + /// + /// Gets the IDs of the records to delete. + /// IEnumerable RecordIds { get; } - Task SendAsync(); + /// + /// Asynchronously sends the request to delete the records. + /// + /// An awaitable task that returns an when complete. + Task SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs index d99df5a..f568c94 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs @@ -1,18 +1,25 @@ -using System.Collections; using System.Collections.Generic; -using System.Dynamic; using System.Linq; using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to delete records from an app by IDs. + /// public class DeleteRecordsByIdsRequestBuilder : IDeleteRecordsByIdsRequestBuilder { private readonly IOnspringClient _client; public int AppId { get; private set; } public IEnumerable RecordIds { get; private set; } + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. + /// The ID of the app from which to delete records. + /// The IDs of the records to delete. internal DeleteRecordsByIdsRequestBuilder(IOnspringClient client, int appId, IEnumerable recordIds) { _client = client; From 3087c03e9b75c2aa668f44b5d3336d7064867f26 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:53:55 -0500 Subject: [PATCH 112/168] docs: add comments to DeleteRecordByIdRequestBuilder --- .../Delete/IDeleteRecordByIdRequestBuilder.cs | 15 +++++++++++++++ .../Delete/DeleteRecordByIdRequestBuilder.cs | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs index 1b3b2a1..84f80c1 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs @@ -3,10 +3,25 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete a record from an app by ID. + /// public interface IDeleteRecordByIdRequestBuilder { + /// + /// Gets the ID of the app from which to delete the record. + /// int AppId { get; } + + /// + /// Gets the ID of the record to delete. + /// int RecordId { get; } + + /// + /// Asynchronously sends the request to delete the record. + /// + /// An awaitable task that returns an when complete. Task SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs index 034d7f5..44837c6 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs @@ -3,12 +3,21 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to delete a record from an app by ID. + /// public class DeleteRecordByIdRequestBuilder : IDeleteRecordByIdRequestBuilder { private readonly IOnspringClient _client; public int AppId { get; private set; } public int RecordId { get; private set; } + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. + /// The ID of the app from which to delete the record. + /// The ID of the record to delete. internal DeleteRecordByIdRequestBuilder(IOnspringClient client, int appId, int recordId) { _client = client; From f63881eea7ecbe3bab962bab0a5c141bd3db8fb2 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:10:04 -0500 Subject: [PATCH 113/168] docs: add comments to SaveRecordRequestBuilder --- .../Delete/IDeleteRecordsRequestBuilder.cs | 2 +- .../Save/ISaveRecordByIdRequestBuilder.cs | 17 ++++++++++++++++- ...ISaveRecordByIdWithValuesRequestBuilder.cs | 19 +++++++++++++++++++ .../Save/ISaveRecordInAppRequestBuilder.cs | 12 ++++++++++++ .../Records/Save/ISaveRecordRequestBuilder.cs | 8 ++++++++ .../Records/Save/SaveRecordRequestBuilder.cs | 9 ++++++++- 6 files changed, 64 insertions(+), 3 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs index 547bdc5..204c0b7 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsRequestBuilder.cs @@ -9,7 +9,7 @@ public interface IDeleteRecordsRequestBuilder /// Specifies the app from which to delete records. /// /// The ID of the app from which to delete records. - /// A for further configuration of the request. + /// A for further configuration of the request. IDeleteRecordsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs index 1fb7e43..4223445 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs @@ -1,13 +1,28 @@ -using System; using System.Collections.Generic; using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to save a record by ID. + /// public interface ISaveRecordByIdRequestBuilder { + /// + /// Gets the ID of the app in which to save the record. + /// int AppId { get; } + + /// + /// Gets the ID of the record to save. + /// int? RecordId { get; } + + /// + /// Specifies the field values to save. + /// + /// The field values to save. + /// A for further configuration of the request. ISaveRecordByIdWithValuesRequestBuilder WithValues(IEnumerable values); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs index 7279ec8..8ebd7ae 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs @@ -4,11 +4,30 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to save a record by ID with values. + /// public interface ISaveRecordByIdWithValuesRequestBuilder { + /// + /// Gets the ID of the app in which to save the record. + /// int AppId { get; } + + /// + /// Gets the ID of the record to save. + /// int? RecordId { get; } + + /// + /// Gets the field values to save. + /// IEnumerable Values { get; } + + /// + /// Asynchronously sends the request. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordInAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordInAppRequestBuilder.cs index 48e95c6..80f2340 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordInAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordInAppRequestBuilder.cs @@ -1,8 +1,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to save a record in an app. + /// public interface ISaveRecordInAppRequestBuilder { + /// + /// Gets the ID of the app in which to save the record. + /// int AppId { get; } + + /// + /// Specifies the record to save. If the record ID is null, a new record will be created. + /// + /// The ID of the record to save. + /// A for further configuration of the request. ISaveRecordByIdRequestBuilder WithId(int? recordId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordRequestBuilder.cs index 18486e6..0ab7c22 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to save a record. + /// public interface ISaveRecordRequestBuilder { + /// + /// Specifies the app in which to save the record. + /// + /// The ID of the app in which to save the record. + /// A for further configuration of the request. ISaveRecordInAppRequestBuilder InApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs index c0db865..811b758 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -6,6 +5,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to save a record. + /// + /// public class SaveRecordRequestBuilder : ISaveRecordRequestBuilder, ISaveRecordInAppRequestBuilder, @@ -16,6 +19,10 @@ public class SaveRecordRequestBuilder : public int AppId { get; private set; } public int? RecordId { get; private set; } + /// + /// Creates a new instance of the class. + /// + /// The used to send the request. internal SaveRecordRequestBuilder(IOnspringClient client) { _client = client; From d71cf53306e4412c3cc0d272f9b200dba000d4e8 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:20:31 -0500 Subject: [PATCH 114/168] docs: add comments to GetReportsRequestBuilder --- .../Reports/IGetReportsByAppRequestBuilder.cs | 37 +++++++++++++++++++ .../Reports/IGetReportsRequestBuilder.cs | 8 ++++ .../Fluent/Reports/GetReportBuilderOptions.cs | 10 +++++ .../Reports/GetReportsRequestBuilder.cs | 8 ++++ .../GetReportsRequestBuilderOptions.cs | 12 +++++- 5 files changed, 73 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs index dcddfba..d0f3091 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs @@ -5,14 +5,51 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to get reports from an app. + /// public interface IGetReportsByAppRequestBuilder { + /// + /// Gets the ID of the app from which to get reports. + /// int AppId { get; } + + /// + /// Gets the page number of the reports to get. + /// int PageNumber { get; } + + /// + /// Gets the page size of the page of reports to get. + /// int PageSize { get; } + + /// + /// Specifies the page number of the reports to get. + /// + /// The page number of the reports to get. + /// A for further configuration of the request. IGetReportsByAppRequestBuilder ForPage(int pageNumber); + + /// + /// Specifies the page size of the page of reports to get. + /// + /// The page size of the page of reports to get. + /// A for further configuration of the request. IGetReportsByAppRequestBuilder WithPageSize(int pageNumber); + + /// + /// Asynchronously sends the request. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); + + /// + /// Asynchronously sends the request with the specified options. + /// + /// An action that constructs the options to use for the request. + /// An awaitable task that returns an when complete. Task> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsRequestBuilder.cs index 8f3b239..100050e 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to get reports. + /// public interface IGetReportsRequestBuilder { + /// + /// Specifies the ID of the app from which to get reports. + /// + /// The ID of the app from which to get reports. + /// A for further configuration of the request. IGetReportsByAppRequestBuilder FromApp(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportBuilderOptions.cs index c053c42..dd97de1 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportBuilderOptions.cs @@ -2,9 +2,19 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents options for a request to get a report. + /// public class GetReportBuilderOptions { + /// + /// Gets or sets the format of the report data. + /// public DataFormat Format { get; set; } = DataFormat.Raw; + + /// + /// Gets or sets the type of report data to return. + /// public ReportDataType DataType { get; set; } = ReportDataType.ReportData; } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs index 6ff99f1..d46da0e 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs @@ -4,6 +4,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to get reports. + /// + /// public class GetReportsRequestBuilder : IGetReportsRequestBuilder, IGetReportsByAppRequestBuilder { private readonly IOnspringClient _client; @@ -11,6 +15,10 @@ public class GetReportsRequestBuilder : IGetReportsRequestBuilder, IGetReportsBy public int PageNumber { get; private set; } public int PageSize { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal GetReportsRequestBuilder(IOnspringClient client) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilderOptions.cs index 9e4637b..93496b2 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilderOptions.cs @@ -1,10 +1,18 @@ -using Onspring.API.SDK.Enums; - namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents the options for a request to get reports. + /// public class GetReportsRequestBuilderOptions { + /// + /// Gets or sets the page number to retrieve. + /// public int PageNumber { get; set; } = 1; + + /// + /// Gets or sets the page size to retrieve. + /// public int PageSize { get; set; } = 50; } } \ No newline at end of file From c76efa938a61ee10813729b55c4ac4c89fcccac4 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:24:20 -0500 Subject: [PATCH 115/168] docs: add comments to GetReportRequestBuilder --- .../Reports/IGetReportDataRequestBuilder.cs | 37 +++++++++++++++++++ .../Reports/IGetReportRequestBuilder.cs | 8 ++++ .../Fluent/Reports/GetReportRequestBuilder.cs | 8 ++++ 3 files changed, 53 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs index 7d24388..498dff4 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs @@ -6,14 +6,51 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to get a report's data. + /// public interface IGetReportDataRequestBuilder { + /// + /// Gets the ID of the report to get. + /// int ReportId { get; } + + /// + /// Gets the format of the report data. + /// DataFormat Format { get; } + + /// + /// Gets the type of report data to return. + /// ReportDataType DataType { get; } + + /// + /// Specifies the format of the report data. + /// + /// The format of the report data. + /// A for further configuration of the request. IGetReportDataRequestBuilder WithFormat(DataFormat format); + + /// + /// Specifies the type of report data to return. + /// + /// The type of report data to return. + /// A for further configuration of the request. IGetReportDataRequestBuilder WithDataType(ReportDataType dataType); + + /// + /// Asynchronously sends the request. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); + + /// + /// Asynchronously sends the request with the specified options. + /// + /// An action that constructs the options to use for the request. + /// An awaitable task that returns an when complete. Task> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportRequestBuilder.cs index 3477a23..4db1c15 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to get a report. + /// public interface IGetReportRequestBuilder { + /// + /// Specifies the ID of the report to get. + /// + /// The ID of the report to get. + /// A for further configuration of the request. IGetReportDataRequestBuilder FromReport(int reportId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs index b6491f2..fc480ab 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs @@ -5,6 +5,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to get a report. + /// + /// public class GetReportRequestBuilder : IGetReportRequestBuilder, IGetReportDataRequestBuilder { private readonly IOnspringClient _client; @@ -12,6 +16,10 @@ public class GetReportRequestBuilder : IGetReportRequestBuilder, IGetReportDataR public DataFormat Format { get; private set; } public ReportDataType DataType { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal GetReportRequestBuilder(IOnspringClient client) { _client = client; From af0b56da4a434fffee65dd68603dcac265f179b5 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:38:39 -0500 Subject: [PATCH 116/168] docs: add comments to SaveListValueRequestBuilder --- .../ISaveListValueInListRequestBuilder.cs | 8 +++++ .../Save/ISaveListValueRequestBuilder.cs | 8 +++++ .../ISaveListValueWithIdRequestBuilder.cs | 16 ++++++++++ .../ISaveListValueWithNameRequestBuilder.cs | 31 +++++++++++++++++++ .../Lists/Save/SaveListValueRequestBuilder.cs | 8 +++++ 5 files changed, 71 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueInListRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueInListRequestBuilder.cs index bb62814..a7eb832 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueInListRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueInListRequestBuilder.cs @@ -2,8 +2,16 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to save a list value in a list. + /// public interface ISaveListValueInListRequestBuilder { + /// + /// Specifies the ID of the list to save the value in. If id is null, a new list value will be created. + /// + /// The ID of the list value to save. + /// A for further configuration of the request. ISaveListValueWithIdRequestBuilder WithId(Guid? id); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueRequestBuilder.cs index b6c2797..83f3a3e 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to save a list value. + /// public interface ISaveListValueRequestBuilder { + /// + /// Specifies the ID of the list to save the value in. + /// + /// The ID of the list to save the value in. + /// A for further configuration of the request. ISaveListValueInListRequestBuilder InList(int listId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithIdRequestBuilder.cs index 7733399..93d9c40 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithIdRequestBuilder.cs @@ -2,10 +2,26 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to save a list value with id in a list. + /// public interface ISaveListValueWithIdRequestBuilder { + /// + /// Gets the ID of the list to save the value in. + /// int ListId { get; } + + /// + /// Gets the ID of the list value to save. + /// Guid? Id { get; } + + /// + /// Specifies the name of the list value to save. + /// + /// The name of the list value to save. + /// A for further configuration of the request. ISaveListValueWithNameRequestBuilder WithName(string name); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs index 7f608b2..875b07e 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs @@ -4,13 +4,44 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to save a list value with name in a list. + /// public interface ISaveListValueWithNameRequestBuilder { + /// + /// Gets the ID of the list to save the value in. + /// int ListId { get; } + + /// + /// Gets the ID of the list value to save. + /// Guid? Id { get; } + + /// + /// Gets the name of the list value to save. + /// string Name { get; } + + /// + /// Specifies the color of the list value to save. + /// + /// The color of the list value to save. + /// A for further configuration of the request. ISaveListValueWithNameRequestBuilder WithColor(string color); + + /// + /// Specifies the numeric value of the list value to save. + /// + /// The numeric value of the list value to save. + /// A for further configuration of the request. ISaveListValueWithNameRequestBuilder WithNumericValue(decimal value); + + /// + /// Sends the request asynchronously. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs index 64df266..4ae39dc 100644 --- a/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs @@ -4,6 +4,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to save a list value. + /// + /// public class SaveListValueRequestBuilder : ISaveListValueRequestBuilder, ISaveListValueInListRequestBuilder, @@ -17,6 +21,10 @@ public class SaveListValueRequestBuilder : public decimal? NumericValue { get; private set; } public string Color { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal SaveListValueRequestBuilder(IOnspringClient client) { _client = client; From 9d89cb672cd76796ae9a7ff45383b5ff4ec3c0ad Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:39:30 -0500 Subject: [PATCH 117/168] docs: add comments to SaveListValueRequestBuilder --- .../Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs index 875b07e..31af26a 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs @@ -39,7 +39,7 @@ public interface ISaveListValueWithNameRequestBuilder ISaveListValueWithNameRequestBuilder WithNumericValue(decimal value); /// - /// Sends the request asynchronously. + /// Asynchronously sends the request to save the list value. /// /// An awaitable task that returns an when complete. Task> SendAsync(); From 2e2579aa0e283e5327f45699a87a9136674df72f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:45:04 -0500 Subject: [PATCH 118/168] docs: add comments to DeleteListValueRequestBuilder --- .../IDeleteListValueInListRequestBuilder.cs | 12 ++++++++++++ .../Delete/IDeleteListValueRequestBuilder.cs | 8 ++++++++ .../IDeleteListValueWithIdRequestBuilder.cs | 15 +++++++++++++++ .../Lists/Delete/DeleteListValueRequestBuilder.cs | 9 ++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueInListRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueInListRequestBuilder.cs index b12df72..58ced72 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueInListRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueInListRequestBuilder.cs @@ -2,9 +2,21 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete a list value in a list. + /// public interface IDeleteListValueInListRequestBuilder { + /// + /// Gets the ID of the list to delete the value in. + /// int ListId { get; } + + /// + /// Specifies the ID of the list value to delete. + /// + /// The ID of the list value to delete. + /// A for further configuration of the request. IDeleteListValueWithIdRequestBuilder WithId(Guid id); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueRequestBuilder.cs index d3056b4..c2266e4 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete a list value. + /// public interface IDeleteListValueRequestBuilder { + /// + /// Specifies the ID of the list where the list value to delete is located. + /// + /// The ID of the list where the list value to delete is located. + /// A for further configuration of the request. IDeleteListValueInListRequestBuilder InList(int listId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs index dae2107..8586b04 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs @@ -4,10 +4,25 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete a list value in a list. + /// public interface IDeleteListValueWithIdRequestBuilder { + /// + /// Gets the ID of the list to delete the value in. + /// int ListId { get; } + + /// + /// Gets the ID of the list value to delete. + /// Guid Id { get; } + + /// + /// Asynchronously sends the request to delete the list value. + /// + /// An awaitable task that returns an when complete. Task SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs index ce9a2f5..1bd65e0 100644 --- a/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs @@ -4,6 +4,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to delete a list value. + /// + /// public class DeleteListValueRequestBuilder : IDeleteListValueRequestBuilder, IDeleteListValueInListRequestBuilder, @@ -13,7 +17,10 @@ public class DeleteListValueRequestBuilder : public int ListId { get; private set; } public Guid Id { get; private set; } - + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal DeleteListValueRequestBuilder(IOnspringClient client) { _client = client; From 7deffe4b837b65b5ea1ff7c79ffa4e28b6d2f304 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:57:49 -0500 Subject: [PATCH 119/168] docs: add comments for get apps request builders --- .../Fluent/Apps/IGetAppByIdRequestBuilder.cs | 11 ++++++++++ .../Apps/IGetAppsByIdsRequestBuilder.cs | 11 ++++++++++ .../Fluent/Apps/IGetAppsRequestBuilder.cs | 20 +++++++++++++++++++ .../Apps/IGetPagedAppsRequestBuilder.cs | 18 +++++++++++++++++ .../Fluent/Apps/GetAppByIdRequestBuilder.cs | 10 ++++++++++ .../Fluent/Apps/GetAppsByIdsRequestBuilder.cs | 9 +++++++++ .../Fluent/Apps/GetAppsRequestBuilder.cs | 8 ++++++++ .../Fluent/Apps/GetPagedAppsRequestBuilder.cs | 9 +++++++++ 8 files changed, 96 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs index 317cc99..9f98692 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs @@ -3,9 +3,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve an app by ID. + /// public interface IGetAppByIdRequestBuilder { + /// + /// Gets the ID of the app to retrieve. + /// int AppId { get; } + + /// + /// Asynchronously sends the request to retrieve the app. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs index e9dc3fb..b92bbae 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs @@ -4,9 +4,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve apps by IDs + /// public interface IGetAppsByIdsRequestBuilder { + /// + /// Gets the IDs of the apps to retrieve. + /// IEnumerable AppIds { get; } + + /// + /// Asynchronously sends the request to retrieve the apps. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsRequestBuilder.cs index 32a6aef..c69d89d 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsRequestBuilder.cs @@ -2,10 +2,30 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve apps. + /// public interface IGetAppsRequestBuilder { + /// + /// Specifies the page number to retrieve. + /// + /// The page number to retrieve. + /// A for further configuration of the request. IGetPagedAppsRequestBuilder ForPage(int pageNumber); + + /// + /// Specifies the IDs of the apps to retrieve. + /// + /// The IDs of the apps to retrieve. + /// A for further configuration of the request. IGetAppsByIdsRequestBuilder WithIds(IEnumerable appIds); + + /// + /// Specifies the ID of the app to retrieve. + /// + /// The ID of the app to retrieve. + /// A for further configuration of the request. IGetAppByIdRequestBuilder WithId(int appId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs index 30f39eb..d44c89b 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs @@ -5,9 +5,27 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IGetPagedAppsRequestBuilder { + /// + /// Gets the page number of the apps to retrieve. + /// int PageNumber { get; } + + /// + /// Gets the page size of the apps to retrieve. The default is 50. + /// int PageSize { get; } + + /// + /// Specifies the page size of the apps to retrieve. + /// + /// The page size of the apps to retrieve. + /// A for further configuration of the request. IGetPagedAppsRequestBuilder WithPageSize(int pageSize); + + /// + /// Asynchronously sends the request to retrieve the apps. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs index f78afb8..04e196e 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs @@ -3,11 +3,21 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve an app by ID. + /// + /// public class GetAppByIdRequestBuilder : IGetAppByIdRequestBuilder { private readonly IOnspringClient _client; + public int AppId { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The client used to send the request. + /// The ID of the app to retrieve. internal GetAppByIdRequestBuilder(IOnspringClient client, int appId) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs index c394e7d..6ae38ef 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs @@ -4,11 +4,20 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve apps by IDs + /// + /// public class GetAppsByIdsRequestBuilder : IGetAppsByIdsRequestBuilder { private readonly IOnspringClient _client; public IEnumerable AppIds { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. + /// The IDs of the apps to retrieve. internal GetAppsByIdsRequestBuilder(IOnspringClient client, IEnumerable appIds) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs index c6e4623..28be7b7 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs @@ -3,10 +3,18 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve apps. + /// + /// public class GetAppsRequestBuilder : IGetAppsRequestBuilder { private readonly IOnspringClient _client; + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal GetAppsRequestBuilder(IOnspringClient client) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs index bb06941..ddbceb5 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs @@ -3,12 +3,21 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve apps that are paginated. + /// + /// public class GetPagedAppsRequestBuilder : IGetPagedAppsRequestBuilder { private readonly IOnspringClient _client; public int PageNumber { get; private set; } public int PageSize { get; private set; } = 50; + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. + /// The page number of the apps to retrieve. internal GetPagedAppsRequestBuilder(IOnspringClient client, int pageNumber) { _client = client; From b61f05d8c77778018d92a382b5eba3eef439a440 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:12:00 -0500 Subject: [PATCH 120/168] docs: add comments for get fields request builders --- .../Fields/IGetFieldByIdRequestBuilder.cs | 11 ++++++ .../Fields/IGetFieldsByAppRequestBuilder.cs | 37 +++++++++++++++++++ .../Fields/IGetFieldsByIdsRequestBuilder.cs | 11 ++++++ .../Fluent/Fields/IGetFieldsRequestBuilder.cs | 20 ++++++++++ .../Fields/GetFieldByIdRequestBuilder.cs | 7 ++++ .../Fields/GetFieldsByAppRequestBuilder.cs | 9 +++++ .../GetFieldsByAppRequestBuilderOptions.cs | 10 +++++ .../Fields/GetFieldsByIdsRequestBuilder.cs | 9 +++++ .../Fluent/Fields/GetFieldsRequestBuilder.cs | 8 ++++ 9 files changed, 122 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs index 15c696d..3d747ec 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs @@ -3,9 +3,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve fields by id. + /// public interface IGetFieldByIdRequestBuilder { + /// + /// Gets the ID of the field to retrieve. + /// int FieldId { get; } + + /// + /// Asynchronously sends the request to retrieve the field. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs index fd28f03..2075022 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs @@ -5,14 +5,51 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve fields by app. + /// public interface IGetFieldsByAppRequestBuilder { + /// + /// Gets the ID of the app to retrieve fields for. + /// int AppId { get; } + + /// + /// Gets the page number to retrieve. + /// int PageNumber { get; } + + /// + /// Gets the page size to retrieve. + /// int PageSize { get; } + + /// + /// Specifies the page number to retrieve. + /// + /// The page number to retrieve. + /// A for further configuration of the request. IGetFieldsByAppRequestBuilder ForPage(int pageNumber); + + /// + /// Specifies the page size to retrieve. + /// + /// The page size to retrieve. + /// A for further configuration of the request. IGetFieldsByAppRequestBuilder WithPageSize(int pageSize); + + /// + /// Asynchronously sends the request to retrieve the fields. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); + + /// + /// Asynchronously sends the request to retrieve the fields. + /// + /// An action constructs the options for the request. + /// An awaitable task that returns an when complete. Task> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs index 9540318..f3bc56c 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs @@ -4,9 +4,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve fields by IDs. + /// public interface IGetFieldsByIdsRequestBuilder { + /// + /// Gets the IDs of the fields to retrieve. + /// IEnumerable FieldIds { get; } + + /// + /// Asynchronously sends the request to retrieve the fields. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsRequestBuilder.cs index a1a22fb..492691f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsRequestBuilder.cs @@ -2,10 +2,30 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve fields. + /// public interface IGetFieldsRequestBuilder { + /// + /// Specifies the ID of the field to retrieve. + /// + /// The ID of the field to retrieve. + /// A for further configuration of the request. IGetFieldByIdRequestBuilder WithId(int fieldId); + + /// + /// Specifies the ID of the app to retrieve fields for. + /// + /// The ID of the app to retrieve fields for. + /// A for further configuration of the request. IGetFieldsByAppRequestBuilder FromApp(int appId); + + /// + /// Specifies the IDs of the fields to retrieve. + /// + /// The IDs of the fields to retrieve. + /// A for further configuration of the request. IGetFieldsByIdsRequestBuilder WithIds(IEnumerable fieldIds); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs index 9fbdbba..f4254bb 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs @@ -3,11 +3,18 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve fields by id. + /// + /// public class GetFieldByIdRequestBuilder : IGetFieldByIdRequestBuilder { private readonly IOnspringClient _client; public int FieldId { get; private set; } + /// + /// Initializes a new instance of the class. + /// internal GetFieldByIdRequestBuilder(IOnspringClient client, int fieldId) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs index 20c95d7..8307c16 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs @@ -4,6 +4,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve fields by app. + /// + /// public class GetFieldsByAppRequestBuilder : IGetFieldsByAppRequestBuilder { private readonly IOnspringClient _client; @@ -11,6 +15,11 @@ public class GetFieldsByAppRequestBuilder : IGetFieldsByAppRequestBuilder public int PageNumber { get; private set; } = 1; public int PageSize { get; private set; } = 50; + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. + /// The ID of the app to retrieve fields for. internal GetFieldsByAppRequestBuilder(IOnspringClient client, int appId) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilderOptions.cs index bf47bc4..34deec2 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilderOptions.cs @@ -1,8 +1,18 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents the options for a request to retrieve fields by app. + /// public class GetFieldsByAppRequestBuilderOptions { + /// + /// Gets or sets the page number to retrieve. The default is 1. + /// public int PageNumber { get; set; } = 1; + + /// + /// Gets or sets the page size to retrieve. The default is 50. + /// public int PageSize { get; set; } = 50; } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs index bcb4315..3174a60 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs @@ -4,11 +4,20 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve fields by IDs. + /// + /// public class GetFieldsByIdsRequestBuilder : IGetFieldsByIdsRequestBuilder { private readonly IOnspringClient _client; public IEnumerable FieldIds { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. + /// The IDs of the fields to retrieve. internal GetFieldsByIdsRequestBuilder(IOnspringClient client, IEnumerable fieldIds) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs index e3ebfa9..9836260 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs @@ -3,10 +3,18 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve fields. + /// + /// public class GetFieldsRequestBuilder : IGetFieldsRequestBuilder { private readonly IOnspringClient _client; + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal GetFieldsRequestBuilder(IOnspringClient client) { _client = client; From 21042543b61590c41af3f69f3df211a3263416fd Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:24:22 -0500 Subject: [PATCH 121/168] docs: add comments for getting file and file info builders --- .../Files/Get/IGetFileByIdRequestBuilder.cs | 19 +++++++++++++++++++ .../Get/IGetFileFromRecordRequestBuilder.cs | 12 ++++++++++++ .../Get/IGetFileInFieldRequestBuilder.cs | 16 ++++++++++++++++ .../Get/IGetFileInfoByIdRequestBuilder.cs | 19 +++++++++++++++++++ .../IGetFileInfoFromRecordRequestBuilder.cs | 12 ++++++++++++ .../Get/IGetFileInfoInFieldRequestBuilder.cs | 16 ++++++++++++++++ .../Files/Get/IGetFileInfoRequestBuilder.cs | 8 ++++++++ .../Files/Get/IGetFileRequestBuilder.cs | 8 ++++++++ .../Files/Get/GetFileInfoRequestBuilder.cs | 7 +++++++ .../Fluent/Files/Get/GetFileRequestBuilder.cs | 8 ++++++++ 10 files changed, 125 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs index 9d89e74..64a86a2 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs @@ -3,11 +3,30 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve files by id. + /// public interface IGetFileByIdRequestBuilder { + /// + /// Gets the ID of the record to retrieve the file from. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to retrieve the file from. + /// int FieldId { get; } + + /// + /// Gets the ID of the file to retrieve. + /// int FileId { get; } + + /// + /// Asynchronously sends the request to retrieve the file. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileFromRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileFromRecordRequestBuilder.cs index f6b8907..95ec64a 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileFromRecordRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileFromRecordRequestBuilder.cs @@ -1,8 +1,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve a file from a record. + /// public interface IGetFileFromRecordRequestBuilder { + /// + /// Gets the ID of the record to retrieve the file from. + /// int RecordId { get; } + + /// + /// Specifies the ID of the field to retrieve the file from. + /// + /// The ID of the field to retrieve the file from. + /// A for further configuration of the request. IGetFileInFieldRequestBuilder InField(int fieldId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInFieldRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInFieldRequestBuilder.cs index 8fb1876..e6b68f2 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInFieldRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInFieldRequestBuilder.cs @@ -1,9 +1,25 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve a file from a field. + /// public interface IGetFileInFieldRequestBuilder { + /// + /// Gets the ID of the record to retrieve the file from. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to retrieve the file from. + /// int FieldId { get; } + + /// + /// Specifies the ID of the file to retrieve. + /// + /// The ID of the file to retrieve. + /// A for further configuration of the request. IGetFileByIdRequestBuilder WithId(int fileId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs index 056c5f6..ff55d85 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs @@ -3,11 +3,30 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve information about a file by its ID. + /// public interface IGetFileInfoByIdRequestBuilder { + /// + /// Gets the ID of the record to retrieve the file information from. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to retrieve the file information from. + /// int FieldId { get; } + + /// + /// Gets the ID of the file to retrieve information about. + /// int FileId { get; } + + /// + /// Asynchronously sends the request to retrieve the file information. + /// + /// An awaitable task that returns an when complete. Task> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoFromRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoFromRecordRequestBuilder.cs index c5ff2cc..fa752ba 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoFromRecordRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoFromRecordRequestBuilder.cs @@ -1,8 +1,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve information about a file from a record. + /// public interface IGetFileInfoFromRecordRequestBuilder { + /// + /// Gets the ID of the record to retrieve the file information from. + /// int RecordId { get; } + + /// + /// Specifies the ID of the field to retrieve the file information from. + /// + /// The ID of the field to retrieve the file information from. + /// A for further configuration of the request. IGetFileInfoInFieldRequestBuilder InField(int fieldId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoInFieldRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoInFieldRequestBuilder.cs index fbaa8cf..5b03669 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoInFieldRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoInFieldRequestBuilder.cs @@ -1,9 +1,25 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve information about a file in a field. + /// public interface IGetFileInfoInFieldRequestBuilder { + /// + /// Gets the ID of the record to retrieve the file information from. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to retrieve the file information from. + /// int FieldId { get; } + + /// + /// Specifies the ID of the file to retrieve information about. + /// + /// The ID of the file to retrieve information about. + /// A for further configuration of the request. IGetFileInfoByIdRequestBuilder WithId(int fileId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoRequestBuilder.cs index 86a7975..2d38027 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve information about a file. + /// public interface IGetFileInfoRequestBuilder { + /// + /// Specifies the ID of the record to retrieve the file information from. + /// + /// The ID of the record to retrieve the file information from. + /// A for further configuration of the request. IGetFileInfoFromRecordRequestBuilder FromRecord(int recordId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileRequestBuilder.cs index 8c47c6e..bfb1f4b 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to retrieve a file. + /// public interface IGetFileRequestBuilder { + /// + /// Specifies the ID of the file to retrieve. + /// + /// The ID of the record to retrieve the file from. + /// A for further configuration of the request. IGetFileFromRecordRequestBuilder FromRecord(int recordId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs index 53697ff..e6846f4 100644 --- a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs @@ -3,6 +3,9 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve information about a file. + /// public class GetFileInfoRequestBuilder : IGetFileInfoRequestBuilder, IGetFileInfoFromRecordRequestBuilder, @@ -14,6 +17,10 @@ public class GetFileInfoRequestBuilder : public int FieldId { get; private set; } public int FileId { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal GetFileInfoRequestBuilder(IOnspringClient client) { _client = client; diff --git a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs index 5730462..e8f4a47 100644 --- a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs @@ -3,6 +3,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to retrieve a file. + /// + /// public class GetFileRequestBuilder : IGetFileRequestBuilder, IGetFileFromRecordRequestBuilder, @@ -14,6 +18,10 @@ public class GetFileRequestBuilder : public int FieldId { get; private set; } public int FileId { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal GetFileRequestBuilder(IOnspringClient client) { _client = client; From d72b963d7dc3e32e4c707304109b9525159ee620 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:32:45 -0500 Subject: [PATCH 122/168] docs: add comments to AddFileRequestBuilder --- .../Add/IAddFileInFieldRequestBuilder.cs | 16 ++++++++++ .../Files/Add/IAddFileRequestBuilder.cs | 8 +++++ .../Add/IAddFileToRecordRequestBuilder.cs | 12 +++++++ .../IAddFileWithModifiedDateRequestBuilder.cs | 32 +++++++++++++++++++ .../Add/IAddFileWithNameRequestBuilder.cs | 20 ++++++++++++ .../Add/IAddFileWithNotesRequestBuilder.cs | 32 +++++++++++++++++++ .../Add/IAddFileWithStreamRequestBuilder.cs | 24 ++++++++++++++ .../Add/IAddFileWithTypeRequestBuilder.cs | 28 ++++++++++++++++ .../Fluent/Files/Add/AddFileRequestBuilder.cs | 8 +++++ 9 files changed, 180 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileInFieldRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileInFieldRequestBuilder.cs index 8460bf4..d06f56c 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileInFieldRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileInFieldRequestBuilder.cs @@ -1,9 +1,25 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to add a file to a field. + /// public interface IAddFileInFieldRequestBuilder { + /// + /// Gets the ID of the record to add the file to. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to add the file to. + /// int FieldId { get; } + + /// + /// Specifies the name of the file to add. + /// + /// The name of the file to add. + /// A for further configuration of the request. IAddFileWithNameRequestBuilder WithName(string name); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileRequestBuilder.cs index d825ddf..bf81054 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to add a file. + /// public interface IAddFileRequestBuilder { + /// + /// Specifies the ID of the record to add the file to. + /// + /// The ID of the record to add the file to. + /// A for further configuration of the request. IAddFileToRecordRequestBuilder ToRecord(int recordId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileToRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileToRecordRequestBuilder.cs index fdc2358..8c52be0 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileToRecordRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileToRecordRequestBuilder.cs @@ -1,8 +1,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to add a file to a record. + /// public interface IAddFileToRecordRequestBuilder { + /// + /// Gets the ID of the record to add the file to. + /// int RecordId { get; } + + /// + /// Specifies the ID of the field to add the file to. + /// + /// The ID of the field to add the file to. + /// A for further configuration of the request. IAddFileInFieldRequestBuilder InField(int fieldId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs index a4617e3..23c7be5 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs @@ -7,13 +7,45 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IAddFileWithModifiedDateRequestBuilder { + /// + /// Gets the ID of the record to add the file to. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to add the file to. + /// int FieldId { get; } + + /// + /// Gets the name of the file to add. + /// string Name { get; } + + /// + /// Gets the stream of the file to add. + /// Stream FileStream { get; } + + /// + /// Gets the MIME type of the file to add. + /// string Type { get; } + + /// + /// Gets the notes of the file to add. + /// string Notes { get; } + + /// + /// Gets the modified date of the file to add. + /// DateTime? ModifiedDate { get; } + + /// + /// Asynchronously sends the request to add the file. + /// + /// An awaitable task that returns an when completed Task>> SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNameRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNameRequestBuilder.cs index 25eed51..a972bcb 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNameRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNameRequestBuilder.cs @@ -2,11 +2,31 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to add a file with a name. + /// public interface IAddFileWithNameRequestBuilder { + /// + /// Gets the ID of the record to add the file to. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to add the file to. + /// int FieldId { get; } + + /// + /// Gets the name of the file to add. + /// string Name { get; } + + /// + /// Specifies the Stream of the file to add. + /// + /// The Stream of the file to add. + /// A for further configuration of the request. IAddFileWithStreamRequestBuilder WithStream(Stream stream); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNotesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNotesRequestBuilder.cs index 0461baa..73a3514 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNotesRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithNotesRequestBuilder.cs @@ -3,14 +3,46 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to add a file with notes. + /// public interface IAddFileWithNotesRequestBuilder { + /// + /// Gets the ID of the record to add the file to. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to add the file to. + /// int FieldId { get; } + + /// + /// Gets the name of the file to add. + /// string Name { get; } + + /// + /// Gets the stream of the file to add. + /// Stream FileStream { get; } + + /// + /// Gets the MIME type of the file to add. + /// string Type { get; } + + /// + /// Gets the notes of the file to add. + /// string Notes { get; } + + /// + /// Specifies the modified date of the file to add. + /// + /// The modified date of the file to add. + /// A for further configuration of the request. IAddFileWithModifiedDateRequestBuilder WithModifiedDate(DateTime? modifiedDate); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithStreamRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithStreamRequestBuilder.cs index aa70998..b0318b7 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithStreamRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithStreamRequestBuilder.cs @@ -2,12 +2,36 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to add a file with a stream. + /// public interface IAddFileWithStreamRequestBuilder { + /// + /// Gets the ID of the record to add the file to. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to add the file to. + /// int FieldId { get; } + + /// + /// Gets the name of the file to add. + /// string Name { get; } + + /// + /// Gets the stream of the file to add. + /// Stream FileStream { get; } + + /// + /// Specifies the MIME type of the file to add. + /// + /// The MIME type of the file to add. + /// A for further configuration of the request. IAddFileWithTypeRequestBuilder WithType(string type); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithTypeRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithTypeRequestBuilder.cs index b0906bd..9013074 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithTypeRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithTypeRequestBuilder.cs @@ -2,13 +2,41 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to add a file with a type. + /// public interface IAddFileWithTypeRequestBuilder { + /// + /// Gets the ID of the record to add the file to. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to add the file to. + /// int FieldId { get; } + + /// + /// Gets the name of the file to add. + /// string Name { get; } + + /// + /// Gets the stream of the file to add. + /// Stream FileStream { get; } + + /// + /// Gets the MIME type of the file to add. + /// string Type { get; } + + /// + /// Specifies the notes of the file to add. + /// + /// The notes of the file to add. + /// A for further configuration of the request. IAddFileWithNotesRequestBuilder WithNotes(string notes); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs index 8904705..edb4b01 100644 --- a/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs @@ -5,6 +5,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to add a file. + /// + /// public class AddFileRequestBuilder : IAddFileRequestBuilder, IAddFileToRecordRequestBuilder, @@ -24,6 +28,10 @@ public class AddFileRequestBuilder : public string Notes { get; private set; } public DateTime? ModifiedDate { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal AddFileRequestBuilder(IOnspringClient client) { _client = client; From 493242c6635dc22f09ad7bc37e626ba0f0bc14e2 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:35:36 -0500 Subject: [PATCH 123/168] docs: add comments to DeleteFileRequestBuilder --- .../Delete/IDeleteFileByIdRequestBuilder.cs | 19 +++++++++++++++++++ .../IDeleteFileFromRecordRequestBuilder.cs | 12 ++++++++++++ .../IDeleteFileInFieldRequestBuilder.cs | 16 ++++++++++++++++ .../Files/Delete/IDeleteFileRequestBuilder.cs | 8 ++++++++ .../Files/Delete/DeleteFileRequestBuilder.cs | 8 ++++++++ 5 files changed, 63 insertions(+) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs index 7e31a07..2228cb6 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs @@ -3,11 +3,30 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete a file. + /// public interface IDeleteFileByIdRequestBuilder { + /// + /// Gets the ID of the record to delete the file from. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to delete the file from. + /// int FieldId { get; } + + /// + /// Gets the ID of the file to delete. + /// int FileId { get; } + + /// + /// Asynchronously sends the request to delete the file. + /// + /// An awaitable task that returns an when complete. Task SendAsync(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileFromRecordRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileFromRecordRequestBuilder.cs index 5b02c8d..c1fd261 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileFromRecordRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileFromRecordRequestBuilder.cs @@ -1,8 +1,20 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete a file from a record. + /// public interface IDeleteFileFromRecordRequestBuilder { + /// + /// Gets the ID of the record to delete the file from. + /// int RecordId { get; } + + /// + /// Specifies the ID of the field to delete the file from. + /// + /// The ID of the field to delete the file from. + /// A for further configuration of the request. IDeleteFileInFieldRequestBuilder InField(int fieldId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileInFieldRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileInFieldRequestBuilder.cs index 0ec4600..a4f02ba 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileInFieldRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileInFieldRequestBuilder.cs @@ -1,9 +1,25 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete a file from a field. + /// public interface IDeleteFileInFieldRequestBuilder { + /// + /// Gets the ID of the record to delete the file from. + /// int RecordId { get; } + + /// + /// Gets the ID of the field to delete the file from. + /// int FieldId { get; } + + /// + /// Specifies the ID of the file to delete. + /// + /// The ID of the file to delete. + /// A for further configuration of the request. IDeleteFileByIdRequestBuilder WithId(int fileId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileRequestBuilder.cs index fbe9acd..32db69d 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileRequestBuilder.cs @@ -1,7 +1,15 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a builder for constructing requests to delete a file. + /// public interface IDeleteFileRequestBuilder { + /// + /// Specifies the ID of the record to delete the file from. + /// + /// The ID of the record to delete the file from. + /// A for further configuration of the request. IDeleteFileFromRecordRequestBuilder FromRecord(int recordId); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs index f9a8565..342fa5a 100644 --- a/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs @@ -3,6 +3,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for constructing requests to delete a file. + /// + /// public class DeleteFileRequestBuilder : IDeleteFileRequestBuilder, IDeleteFileFromRecordRequestBuilder, @@ -14,6 +18,10 @@ public class DeleteFileRequestBuilder : public int FieldId { get; private set; } public int FileId { get; private set; } + /// + /// Initializes a new instance of the class. + /// + /// The to use for the request. internal DeleteFileRequestBuilder(IOnspringClient client) { _client = client; From bf4aaf6708727262d1056c59d2544d2a212b8e77 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 15:11:25 -0500 Subject: [PATCH 124/168] docs: update README.md with information about fluent interface --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 5ce08d9..f1d5e03 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,23 @@ Already using a previous version of the SDK? Check out our migration guides belo The examples that follow assume you have created an `OnspringClient` as described in the **Start Coding** section. +### Fluent Interface + +The `OnspringClient` provides a method named `CreateRequest` which returns an `IOnspringRequestBuilder` instance. This builder exposes a fluent interface for building a request to the Onspring API. This interface is intended to provide a more readable way to build a request and provide better discoverability of the ways in which the API can be used. + +```C# +var apiResponse = await _apiClient + .CreateRequest() + .ToGetRecords() + .FromApp(_appIdWithRecords) + .WithId(1) + .WithFieldIds(new[] { 1, 2, 3 }) + .WithFormat(DataFormat.Formatted) + .SendAsync(); +``` + +When using this interface you should find that each successful chained method walks you down the proper path to make a successful request as the ability to send the request is not exposed until you've provided all required information for making a request. + ### Verify connectivity ```C# From 6f8c7e0a43a9992466f856259ea8e514d0d4680e Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 15:13:23 -0500 Subject: [PATCH 125/168] docs: update README.md with information about fluent interface --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f1d5e03..2ea95e4 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ The examples that follow assume you have created an `OnspringClient` as describe ### Fluent Interface -The `OnspringClient` provides a method named `CreateRequest` which returns an `IOnspringRequestBuilder` instance. This builder exposes a fluent interface for building a request to the Onspring API. This interface is intended to provide a more readable way to build a request and provide better discoverability of the ways in which the API can be used. +The `OnspringClient` provides a method named `CreateRequest` which returns an `IOnspringRequestBuilder` instance. This builder exposes the same methods that are exposed by the `IOnspringClient` interface, but through a fluent API. This interface is intended to provide a more readable way to build a request and provide better discoverability of the ways in which the SDK can be used to make requests. ```C# var apiResponse = await _apiClient From a71cd6c739bb12bcd9a7e1412501bc4c3eedcf35 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 15:50:05 -0500 Subject: [PATCH 126/168] chore: run dotnet format on test files --- .editorconfig | 2 +- .../Integration/Fluent/OnspringClientAppsTests.cs | 4 ++-- .../Fluent/OnspringClientDiagnosticTests.cs | 4 ++-- .../Integration/Fluent/OnspringClientFieldTests.cs | 6 +++--- .../Integration/Fluent/OnspringClientFilesTests.cs | 10 +++++----- .../Integration/Fluent/OnspringClientListsTests.cs | 6 +++--- .../Integration/Fluent/OnspringClientReportsTests.cs | 5 ++--- .../Tests/Integration/OnspringClientAppsTests.cs | 2 +- .../Integration/OnspringClientConfigurationTests.cs | 2 +- .../Tests/Integration/OnspringClientDiagnosticTests.cs | 2 +- .../Tests/Integration/OnspringClientFilesTests.cs | 2 +- .../Tests/Integration/OnspringClientListsTests.cs | 2 +- .../Tests/Integration/OnspringClientRecordsTests.cs | 2 +- .../Tests/Integration/OnspringClientReportsTests.cs | 2 +- .../Tests/Integration/OnspringClientTests.cs | 2 +- .../Tests/Unit/FilterOperatorTests.cs | 2 +- Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs | 5 ++--- .../Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs | 6 +++--- .../Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs | 8 ++++---- .../Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs | 4 ++-- .../Fluent/Apps/GetPagedAppsRequestBuilderTests.cs | 6 +++--- .../Fluent/Fields/GetFieldByIdRequestBuilderTests.cs | 6 +++--- .../Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs | 6 +++--- .../Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs | 8 ++++---- .../Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs | 4 ++-- .../Fluent/Files/Add/AddFileRequestBuilderTests.cs | 8 ++++---- .../Files/Delete/DeleteFileRequestBuilderTests.cs | 5 ++--- .../Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs | 6 +++--- .../Fluent/Files/Get/GetFileRequestBuilderTests.cs | 6 +++--- .../Lists/Delete/DeleteListValueRequestBuilderTests.cs | 6 +++--- .../Lists/Save/SaveListValueRequestBuilderTests.cs | 8 ++++---- .../Tests/Unit/Fluent/OnspringRequestBuilderTests.cs | 2 +- .../Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs | 2 +- .../Delete/DeleteRecordByIdRequestBuilderTests.cs | 4 ++-- .../Delete/DeleteRecordsByAppRequestBuilderTests.cs | 2 +- .../Delete/DeleteRecordsByIdsRequestBuilderTests.cs | 4 ++-- .../Records/Delete/DeleteRecordsRequestBuilderTests.cs | 2 +- .../Records/Get/GetRecordByIdRequestBuilderTests.cs | 8 ++++---- .../Get/GetRecordsByAppPagedRequestBuilderTests.cs | 8 ++++---- .../Records/Get/GetRecordsByAppRequestBuilderTests.cs | 2 +- .../Records/Get/GetRecordsByIdsRequestBuilderTests.cs | 8 ++++---- .../Records/Get/GetRecordsRequestBuilderTests.cs | 2 +- .../Get/QueryRecordsByAppPagedRequestBuilderTests.cs | 8 ++++---- .../Records/Save/SaveRecordRequestBuilderTests.cs | 7 +++---- .../Fluent/Reports/GetReportRequestBuilderTests.cs | 6 +++--- .../Fluent/Reports/GetReportsRequestBuilderTests.cs | 6 +++--- .../Tests/Unit/OnspringClientTests.cs | 3 +-- 47 files changed, 108 insertions(+), 113 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2d85cea..5798e86 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,7 +19,7 @@ insert_final_newline = false # Organize usings dotnet_separate_import_directive_groups = false -dotnet_sort_system_directives_first = true +dotnet_sort_system_directives_first = false file_header_template = unset # this. and Me. preferences diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs index 444c403..e132a00 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs @@ -1,8 +1,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using Onspring.API.SDK.Tests.Infrastructure.Http; using Onspring.API.SDK.Tests.Infrastructure; -using System.Threading.Tasks; using Onspring.API.SDK.Tests.Infrastructure.Helpers; +using Onspring.API.SDK.Tests.Infrastructure.Http; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientDiagnosticTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientDiagnosticTests.cs index 2b452d2..1dbcbc5 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientDiagnosticTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientDiagnosticTests.cs @@ -1,8 +1,8 @@ -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Http; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs index 85f7790..f0f6476 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs @@ -1,10 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs index c531465..2cb0ca6 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFilesTests.cs @@ -1,11 +1,11 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using System; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { @@ -86,4 +86,4 @@ public async Task AddFile() AssertHelper.AssertSuccess(apiResponse); } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs index 44a0354..7bff45d 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientListsTests.cs @@ -1,10 +1,10 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using System; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs index acb74a2..f38ac78 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs @@ -1,11 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Models; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs index caac92d..30f7ec4 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs @@ -103,4 +103,4 @@ public async Task GetAppsBatch_Forbidden() AssertHelper.AssertError(getAppsResponse, HttpStatusCode.Forbidden); } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientConfigurationTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientConfigurationTests.cs index 21fdda0..2214b83 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientConfigurationTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientConfigurationTests.cs @@ -36,4 +36,4 @@ public void ParameteredCtor_GetParams() Assert.AreEqual(baseAddress, clientConfig.BaseAddress, "BaseAddress was not correct"); } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientDiagnosticTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientDiagnosticTests.cs index f1ae1f4..93dbc00 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientDiagnosticTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientDiagnosticTests.cs @@ -27,4 +27,4 @@ public async Task CanConnectAsync() Assert.IsTrue(canConnect, "Unable to connect"); } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFilesTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFilesTests.cs index eeb3996..2b19a07 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFilesTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFilesTests.cs @@ -60,4 +60,4 @@ public async Task SaveReadDeleteFileAsync() AssertHelper.AssertSuccess(deleteResponse); } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientListsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientListsTests.cs index dc5ec4c..c406e63 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientListsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientListsTests.cs @@ -56,4 +56,4 @@ public async Task AddUpdateRemoveListItemAsync() AssertHelper.AssertSuccess(deleteResponse); } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs index 676fc7c..b58b894 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs @@ -173,4 +173,4 @@ private static void UpdateRecordFields(ResultRecord record) } } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs index a63eb12..ac4f3b0 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs @@ -40,4 +40,4 @@ public async Task GetReportsForAppAsync() AssertHelper.AssertPaging(pagingRequest, getResponse.Value); } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs index 7b4cf1b..a4ac547 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs @@ -111,4 +111,4 @@ public void CreateRequest_WhenCalled_ItShouldReturnAnInstanceOfAnOnspringRequest Assert.IsInstanceOfType(request); } } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs index bb36fa8..4db13fe 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/FilterOperatorTests.cs @@ -1,6 +1,6 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs index e812d89..b3e50e8 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/FilterTests.cs @@ -1,9 +1,8 @@ -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; +using System; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs index 5dfc382..27b693e 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppByIdRequestBuilderTests.cs @@ -1,11 +1,11 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs index 26da0d3..c80aa51 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsByIdsRequestBuilderTests.cs @@ -1,12 +1,12 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs index bfcde36..0d2d975 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAppsRequestBuilderTests.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetPagedAppsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetPagedAppsRequestBuilderTests.cs index 10458df..494e8eb 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetPagedAppsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetPagedAppsRequestBuilderTests.cs @@ -1,11 +1,11 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldByIdRequestBuilderTests.cs index 247f91b..3b3c9fc 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldByIdRequestBuilderTests.cs @@ -1,11 +1,11 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs index 856e0af..e4b63d7 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByAppRequestBuilderTests.cs @@ -1,11 +1,11 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs index 68b9d03..77ba7a5 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsByIdsRequestBuilderTests.cs @@ -1,12 +1,12 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs index 48674e6..31525b2 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetFieldsRequestBuilderTests.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Add/AddFileRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Add/AddFileRequestBuilderTests.cs index 4e46f92..37118c1 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Add/AddFileRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Add/AddFileRequestBuilderTests.cs @@ -1,12 +1,12 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; using System; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Net; using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NSubstitute; -using Onspring.API.SDK.Models; -using Onspring.API.SDK.Models.Fluent; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Delete/DeleteFileRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Delete/DeleteFileRequestBuilderTests.cs index ef2164f..c90df3c 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Delete/DeleteFileRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Delete/DeleteFileRequestBuilderTests.cs @@ -1,10 +1,9 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs index 92814cb..1a8587a 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileInfoRequestBuilderTests.cs @@ -1,10 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs index 678e3fd..061641a 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Files/Get/GetFileRequestBuilderTests.cs @@ -1,10 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Delete/DeleteListValueRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Delete/DeleteListValueRequestBuilderTests.cs index e02c742..163f057 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Delete/DeleteListValueRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Delete/DeleteListValueRequestBuilderTests.cs @@ -1,10 +1,10 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Save/SaveListValueRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Save/SaveListValueRequestBuilderTests.cs index 56e4ff1..eb4a330 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Save/SaveListValueRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Lists/Save/SaveListValueRequestBuilderTests.cs @@ -1,11 +1,11 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs index 645eab3..a9ad801 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/OnspringRequestBuilderTests.cs @@ -1,8 +1,8 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs index 9023200..767907b 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Ping/ConnectionRequestBuilderTests.cs @@ -1,7 +1,7 @@ -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Models.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs index 03528a6..aca041b 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordByIdRequestBuilderTests.cs @@ -1,10 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs index 88e5766..1343791 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilderTests.cs @@ -1,8 +1,8 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs index 84ca8e4..2db6b3e 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilderTests.cs @@ -1,10 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs index f9ed8a2..5e6dba2 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Delete/DeleteRecordsRequestBuilderTests.cs @@ -1,8 +1,8 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs index 369f5db..76921fb 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordByIdRequestBuilderTests.cs @@ -1,13 +1,13 @@ -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs index 18ae438..e17bd52 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderTests.cs @@ -1,13 +1,13 @@ -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs index b70ecf7..19017bf 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByAppRequestBuilderTests.cs @@ -1,10 +1,10 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs index 5f42297..5365ec9 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsByIdsRequestBuilderTests.cs @@ -1,13 +1,13 @@ -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs index 4aeaf84..5063cf4 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetRecordsRequestBuilderTests.cs @@ -1,8 +1,8 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs index 8f9cafb..232e0e0 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderTests.cs @@ -1,12 +1,12 @@ -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Save/SaveRecordRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Save/SaveRecordRequestBuilderTests.cs index 690320f..5e867b6 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Save/SaveRecordRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Save/SaveRecordRequestBuilderTests.cs @@ -1,11 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs index 37f229d..60d0142 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportRequestBuilderTests.cs @@ -1,12 +1,12 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs index f217aad..f688a2b 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetReportsRequestBuilderTests.cs @@ -1,10 +1,10 @@ -using System.Diagnostics.CodeAnalysis; -using System.Net; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent { diff --git a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs index 9b16388..1945a7b 100644 --- a/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Unit/OnspringClientTests.cs @@ -1,7 +1,6 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Interfaces.Fluent; -using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; namespace Onspring.API.SDK.Tests.Tests.Unit { From 3d1ac6c4ae85bda81f10d01ee2f46d4b5aff4456 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 15:51:22 -0500 Subject: [PATCH 127/168] chore: run dotnet format on fluent models --- .../Models/Fluent/Apps/GetAppByIdRequestBuilder.cs | 2 +- .../Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs | 2 +- Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs | 2 +- .../Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs | 2 +- .../Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs | 2 +- .../Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs | 2 +- .../Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs | 2 +- .../Models/Fluent/Fields/GetFieldsRequestBuilder.cs | 2 +- .../Models/Fluent/Files/Add/AddFileRequestBuilder.cs | 2 +- .../Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs | 2 +- .../Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs | 2 +- .../Models/Fluent/Files/Get/GetFileRequestBuilder.cs | 2 +- .../Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs | 2 +- .../Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs | 2 +- .../Models/Fluent/Ping/ConnectionRequestBuilder.cs | 2 +- .../Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs | 2 +- .../Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs | 2 +- .../Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs | 2 +- .../Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs | 4 ++-- .../Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs | 2 +- .../Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs | 4 ++-- .../Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs | 2 +- .../Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs | 2 +- .../Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs | 4 ++-- .../Records/Get/GetRecordsByIdsRequestBuilderOptions.cs | 2 +- .../Records/Get/QueryRecordsByAppPagedRequestBuilder.cs | 4 ++-- .../Get/QueryRecordsByAppPagedRequestBuilderOptions.cs | 2 +- .../Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs | 2 +- .../Models/Fluent/Reports/GetReportRequestBuilder.cs | 4 ++-- .../Models/Fluent/Reports/GetReportsRequestBuilder.cs | 2 +- 30 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs index 04e196e..17d52d6 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs index 6ae38ef..953b600 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsByIdsRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System.Collections.Generic; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs index 28be7b7..b8c8d51 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAppsRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; using Onspring.API.SDK.Interfaces.Fluent; +using System.Collections.Generic; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs index ddbceb5..10683a6 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetPagedAppsRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs index f4254bb..3eafc2f 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs index 8307c16..2a4ecec 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByAppRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs index 3174a60..cf1a8c4 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsByIdsRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System.Collections.Generic; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs index 9836260..9cff157 100644 --- a/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetFieldsRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; using Onspring.API.SDK.Interfaces.Fluent; +using System.Collections.Generic; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs index edb4b01..cd00706 100644 --- a/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Files/Add/AddFileRequestBuilder.cs @@ -1,7 +1,7 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.IO; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs index 342fa5a..f9ce069 100644 --- a/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Files/Delete/DeleteFileRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs index e6846f4..0828b49 100644 --- a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileInfoRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs index e8f4a47..424bcc3 100644 --- a/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Files/Get/GetFileRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs index 1bd65e0..a7f179a 100644 --- a/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Lists/Delete/DeleteListValueRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs index 4ae39dc..fa9ca6a 100644 --- a/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Lists/Save/SaveListValueRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs index 5b9c8d8..b1dbe2a 100644 --- a/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Ping/ConnectionRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs index 44837c6..a30b847 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Interfaces.Fluent; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs index 1b9af22..d4df61a 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByAppRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; using Onspring.API.SDK.Interfaces.Fluent; +using System.Collections.Generic; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs index f568c94..d808bc5 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Delete/DeleteRecordsByIdsRequestBuilder.cs @@ -1,7 +1,7 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs index be948cf..18e3642 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilder.cs @@ -1,9 +1,9 @@ +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs index 55d63d5..175c0dc 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordByIdRequestBuilderOptions.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Enums; using System.Collections.Generic; using System.Linq; -using Onspring.API.SDK.Enums; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs index 025431a..29fae71 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilder.cs @@ -1,9 +1,9 @@ +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs index 73bab41..509c5fb 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppPagedRequestBuilderOptions.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Enums; using System.Collections.Generic; using System.Linq; -using Onspring.API.SDK.Enums; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs index 111a8c6..cbb668d 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByAppRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Collections.Generic; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs index ba8aeaf..3fb79c1 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilder.cs @@ -1,9 +1,9 @@ +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs index 30cf4d2..f53241b 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetRecordsByIdsRequestBuilderOptions.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Enums; using System.Collections.Generic; using System.Linq; -using Onspring.API.SDK.Enums; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs index c45dac7..6df2f3b 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilder.cs @@ -1,9 +1,9 @@ +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Onspring.API.SDK.Enums; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs index c97948c..aaebade 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/QueryRecordsByAppPagedRequestBuilderOptions.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Enums; using System.Collections.Generic; using System.Linq; -using Onspring.API.SDK.Enums; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs index 811b758..3cf3b3b 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Save/SaveRecordRequestBuilder.cs @@ -1,7 +1,7 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs index fc480ab..00f4202 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportRequestBuilder.cs @@ -1,7 +1,7 @@ -using System; -using System.Threading.Tasks; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Interfaces.Fluent; +using System; +using System.Threading.Tasks; namespace Onspring.API.SDK.Models.Fluent { diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs index d46da0e..cebde05 100644 --- a/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetReportsRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Interfaces.Fluent; using System; using System.Threading.Tasks; -using Onspring.API.SDK.Interfaces.Fluent; namespace Onspring.API.SDK.Models.Fluent { From b377095ee8ba6d374367382f8b68fb5d08e35de5 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 15:52:03 -0500 Subject: [PATCH 128/168] chore: run dotnet format on fluent interfaces --- .../Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs | 2 +- .../Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs | 2 +- .../Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs | 2 +- .../Fluent/Fields/IGetFieldByIdRequestBuilder.cs | 2 +- .../Fluent/Fields/IGetFieldsByAppRequestBuilder.cs | 4 ++-- .../Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs | 2 +- .../Files/Add/IAddFileWithModifiedDateRequestBuilder.cs | 2 +- .../Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs | 2 +- .../Fluent/Files/Get/IGetFileByIdRequestBuilder.cs | 2 +- .../Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs | 2 +- .../Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs | 2 +- .../Lists/Save/ISaveListValueWithNameRequestBuilder.cs | 2 +- .../Records/Delete/IDeleteRecordByIdRequestBuilder.cs | 2 +- .../Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs | 2 +- .../Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs | 8 ++++---- .../Records/Get/IGetRecordsByAppPagedRequestBuilder.cs | 6 +++--- .../Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs | 2 +- .../Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs | 6 +++--- .../Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs | 6 +++--- .../Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs | 2 +- .../Save/ISaveRecordByIdWithValuesRequestBuilder.cs | 2 +- .../Fluent/Reports/IGetReportDataRequestBuilder.cs | 4 ++-- .../Fluent/Reports/IGetReportsByAppRequestBuilder.cs | 4 ++-- 23 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs index 9f98692..75a3159 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Models; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs index b92bbae..ef8e93f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAppsByIdsRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Models; using System.Collections.Generic; using System.Threading.Tasks; -using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs index d44c89b..1101a5e 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Models; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs index 3d747ec..1656573 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Models; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs index 2075022..eb429c3 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByAppRequestBuilder.cs @@ -1,7 +1,7 @@ -using System; -using System.Threading.Tasks; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs index f3bc56c..771be5a 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetFieldsByIdsRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Models; using System.Collections.Generic; using System.Threading.Tasks; -using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs index 23c7be5..f0d2ca6 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Add/IAddFileWithModifiedDateRequestBuilder.cs @@ -1,7 +1,7 @@ +using Onspring.API.SDK.Models; using System; using System.IO; using System.Threading.Tasks; -using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs index 2228cb6..6aeb8dc 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Delete/IDeleteFileByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Models; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs index 64a86a2..fd58fe2 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Models; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs index ff55d85..0c7a286 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Files/Get/IGetFileInfoByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Models; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs index 8586b04..0fdfa7b 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Delete/IDeleteListValueWithIdRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Models; using System; using System.Threading.Tasks; -using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs index 31af26a..eedd29d 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Lists/Save/ISaveListValueWithNameRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Models; using System; using System.Threading.Tasks; -using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs index 84f80c1..77278eb 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using Onspring.API.SDK.Models; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs index c6e1820..b33bb48 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByIdsRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Models; using System.Collections.Generic; using System.Threading.Tasks; -using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs index cbe137f..93341e3 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordByIdRequestBuilder.cs @@ -1,9 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { @@ -59,4 +59,4 @@ public interface IGetRecordByIdRequestBuilder /// A builder for further configuration of the request. IGetRecordByIdRequestBuilder WithFormat(DataFormat dataFormat); } -} +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs index 3bcf1bd..7d25472 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs @@ -1,9 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs index 4e96eca..66a5b0f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Models; using System; using System.Collections.Generic; -using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs index cd9c0b6..0e7b718 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByIdsRequestBuilder.cs @@ -1,9 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs index 0e89a99..4d5689a 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IQueryRecordsByAppPagedRequestBuilder.cs @@ -1,9 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs index 4223445..0b3ea65 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdRequestBuilder.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; using Onspring.API.SDK.Models; +using System.Collections.Generic; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs index 8ebd7ae..e3be363 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Save/ISaveRecordByIdWithValuesRequestBuilder.cs @@ -1,6 +1,6 @@ +using Onspring.API.SDK.Models; using System.Collections.Generic; using System.Threading.Tasks; -using Onspring.API.SDK.Models; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs index 498dff4..300966f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportDataRequestBuilder.cs @@ -1,8 +1,8 @@ -using System; -using System.Threading.Tasks; using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs index d0f3091..5c771ec 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetReportsByAppRequestBuilder.cs @@ -1,7 +1,7 @@ -using System; -using System.Threading.Tasks; using Onspring.API.SDK.Models; using Onspring.API.SDK.Models.Fluent; +using System; +using System.Threading.Tasks; namespace Onspring.API.SDK.Interfaces.Fluent { From 2cf5b3e8580c61b537df3c131e3590b146e587f5 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 24 Sep 2023 15:55:02 -0500 Subject: [PATCH 129/168] docs: update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ea95e4..c9cf051 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ The examples that follow assume you have created an `OnspringClient` as describe ### Fluent Interface -The `OnspringClient` provides a method named `CreateRequest` which returns an `IOnspringRequestBuilder` instance. This builder exposes the same methods that are exposed by the `IOnspringClient` interface, but through a fluent API. This interface is intended to provide a more readable way to build a request and provide better discoverability of the ways in which the SDK can be used to make requests. +The `OnspringClient` provides a method named `CreateRequest` which returns an instance that implements the `IOnspringRequestBuilder` interface. This builder exposes the same methods that are exposed by the `IOnspringClient` interface, but through a fluent API. This interface is intended to provide a more readable way to build a request and provide better discoverability of the ways in which the SDK can be used to make requests. ```C# var apiResponse = await _apiClient @@ -102,7 +102,7 @@ var apiResponse = await _apiClient .SendAsync(); ``` -When using this interface you should find that each successful chained method walks you down the proper path to make a successful request as the ability to send the request is not exposed until you've provided all required information for making a request. +When using this interface you should find that each successful chained method walks you down the proper path to make a successful request as the ability to send the request is not exposed until you've provided all required information for making the request. ### Verify connectivity From e1b331d3e28ec0dad42c377fe599b22c328fe72f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:34:17 -0600 Subject: [PATCH 130/168] chore: update packages and update test project to .net 8 --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 10 +++++----- Onspring.API.SDK/Onspring.API.SDK.csproj | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index efad52a..c302a68 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -1,7 +1,7 @@ - + - net7.0 + net8.0 false @@ -15,8 +15,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + @@ -24,7 +24,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Onspring.API.SDK/Onspring.API.SDK.csproj b/Onspring.API.SDK/Onspring.API.SDK.csproj index c32bcdd..3f306dc 100644 --- a/Onspring.API.SDK/Onspring.API.SDK.csproj +++ b/Onspring.API.SDK/Onspring.API.SDK.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;netstandard2.1 Onspring.API.SDK @@ -23,7 +23,7 @@ - + From cef402ffdf06a23bd8b512c91de9c09b07cb4618 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:52:37 -0600 Subject: [PATCH 131/168] chore: update test command --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index c302a68..5b57a3e 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -34,7 +34,7 @@ - + From bff10a4afed5785c6991c403a4785b382aa8e680 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:28:34 -0600 Subject: [PATCH 132/168] tests: update to .NET 9 and update deps --- .../Onspring.API.SDK.Tests.csproj | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index 5b57a3e..8335c75 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 false @@ -11,20 +11,20 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + From c0b3d6d3c4a4d7cf923ad8fa22e68591443d1f4c Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:41:39 -0600 Subject: [PATCH 133/168] fix: use correct interface as return type when creating a request to get reports for an app. --- .../Fluent/OnspringClientReportsTests.cs | 35 +++++++++++++++++++ .../Fluent/IOnspringRequestBuilder.cs | 2 +- .../Models/Fluent/OnspringRequestBuilder.cs | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs index f38ac78..bcaf743 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; @@ -24,6 +25,40 @@ public static void ClassInit(TestContext testContext) _apiClient = new OnspringClient(testConfiguration.ApiKey, httpClient); } + [TestMethod] + public async Task GetReportsForAppAsync() + { + var pagingRequest = new PagingRequest(1, 10); + + var getResponse = await _apiClient.CreateRequest() + .ToGetReports() + .FromApp(_appIdWithReports) + .ForPage(pagingRequest.PageNumber) + .WithPageSize(pagingRequest.PageSize) + .SendAsync(); + + AssertHelper.AssertSuccess(getResponse); + AssertHelper.AssertPaging(pagingRequest, getResponse.Value); + } + + [TestMethod] + public async Task GetReportsForAppAsync_WithOptions() + { + var pagingRequest = new PagingRequest(1, 10); + + var getResponse = await _apiClient.CreateRequest() + .ToGetReports() + .FromApp(_appIdWithReports) + .SendAsync(options => + { + options.PageNumber = pagingRequest.PageNumber; + options.PageSize = pagingRequest.PageSize; + }); + + AssertHelper.AssertSuccess(getResponse); + AssertHelper.AssertPaging(pagingRequest, getResponse.Value); + } + [TestMethod] public async Task GetReportData() { diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index a8b262b..6b467c6 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -33,7 +33,7 @@ public interface IOnspringRequestBuilder /// Creates a builder for retrieving reports from Onspring. /// /// A builder instance for retrieving reports that implements the interface. - IGetReportsByAppRequestBuilder ToGetReports(); + IGetReportsRequestBuilder ToGetReports(); /// /// Creates a builder for retrieving report data from Onspring. diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index d1de48c..ffc6439 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -39,7 +39,7 @@ public IDeleteRecordsRequestBuilder ToDeleteRecords() return new DeleteRecordsRequestBuilder(_client); } - public IGetReportsByAppRequestBuilder ToGetReports() + public IGetReportsRequestBuilder ToGetReports() { return new GetReportsRequestBuilder(_client); } From da4ca1c63d906c409dbfa4d2e002a9a439135dee Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:44:24 -0600 Subject: [PATCH 134/168] chore: add async interfaces as a dep --- Onspring.API.SDK/Onspring.API.SDK.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK/Onspring.API.SDK.csproj b/Onspring.API.SDK/Onspring.API.SDK.csproj index 3f306dc..29a026d 100644 --- a/Onspring.API.SDK/Onspring.API.SDK.csproj +++ b/Onspring.API.SDK/Onspring.API.SDK.csproj @@ -22,6 +22,7 @@ + From f900aa56f6cc0eabbd14768a6797104bd205deba Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:54:18 -0600 Subject: [PATCH 135/168] chore: add mockhttp as dep for mocking http responses --- Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj index 8335c75..ff8f40b 100644 --- a/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj +++ b/Onspring.API.SDK.Tests/Onspring.API.SDK.Tests.csproj @@ -25,6 +25,7 @@ + From f5378be9be09f8767ffa7b94093b77f9eac46af1 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:51:56 -0600 Subject: [PATCH 136/168] chore: remove unnecessary extension recommendation --- .vscode/extensions.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d7886b3..f00a087 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,6 @@ { "recommendations": [ "ms-dotnettools.csdevkit", - "formulahendry.dotnet-test-explorer", "EditorConfig.EditorConfig", "oderwat.indent-rainbow", "aliasadidev.nugetpackagemanagergui" From e1da54ab6ae13b52d089aec994cc9b28e0c5d970 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:52:14 -0600 Subject: [PATCH 137/168] chore: clean up settings for vs code users --- .vscode/settings.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index bdf1da0..a36a90c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,5 @@ { - "dotnet-test-explorer.testArguments": "--settings runsettings/internal.runsettings" + "editor.formatOnSave": true, + "dotnet.defaultSolution": "./Onspring.API.SDK.sln", + "dotnet.unitTests.runSettingsPath": "./Onspring.API.SDK.Tests/runsettings/internal.runsettings", } From 6a86a17642ccb4e78da87a4adba632fc93e16dff Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:52:39 -0600 Subject: [PATCH 138/168] feat: add GetAllApps method --- .../Integration/OnspringClientAppsTests.cs | 112 ++++++++++++++++++ Onspring.API.SDK/IOnspringClient.cs | 9 ++ Onspring.API.SDK/OnspringClient.cs | 19 +++ 3 files changed, 140 insertions(+) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs index 30f7ec4..6bf4fc9 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs @@ -1,10 +1,16 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using RichardSzalay.MockHttp; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net; +using System.Net.Http; +using System.Text.Json; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration @@ -102,5 +108,111 @@ public async Task GetAppsBatch_Forbidden() AssertHelper.AssertError(getAppsResponse, HttpStatusCode.Forbidden); } + + [TestMethod] + public async Task GetAllAppsAsync_WhenUsingDefaultPageSize_ReturnsAllApps() + { + var testAddress = "https://localhost"; + + var mockHttp = new MockHttpMessageHandler(); + + var pageOneResponse = new GetPagedAppsResponse + { + PageNumber = 1, + TotalPages = 3, + TotalRecords = 3, + Items = + [ + new() + { + Href = testAddress, + Id = 1, + Name = $"Test App", + }, + ] + }; + + var pageTwoResponse = new GetPagedAppsResponse + { + PageNumber = 2, + TotalPages = 3, + TotalRecords = 3, + Items = + [ + new() + { + Href = testAddress, + Id = 2, + Name = $"Test App", + }, + ] + }; + + var pageThreeResponse = new GetPagedAppsResponse + { + PageNumber = 3, + TotalPages = 3, + TotalRecords = 3, + Items = + [ + new() + { + Href = testAddress, + Id = 3, + Name = $"Test App", + }, + ] + }; + + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=1&PageSize=50") + .Respond( + "application/json", + JsonSerializer.Serialize(pageOneResponse) + ); + + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=2&PageSize=50") + .Respond( + "application/json", + JsonSerializer.Serialize(pageTwoResponse) + ); + + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=3&PageSize=50") + .Respond( + "application/json", + JsonSerializer.Serialize(pageThreeResponse) + ); + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var appsResponse = apiClient.GetAllApps(); + + var responsePages = new List(); + + await foreach (var response in appsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + Assert.AreEqual(3, responsePages.Count); + + Assert.AreEqual(pageOneResponse.PageNumber, responsePages[0].PageNumber); + Assert.AreEqual(pageOneResponse.Items.Count, responsePages[0].Items.Count); + Assert.AreEqual(pageOneResponse.Items[0].Id, responsePages[0].Items[0].Id); + + Assert.AreEqual(pageTwoResponse.PageNumber, responsePages[1].PageNumber); + Assert.AreEqual(pageTwoResponse.Items.Count, responsePages[1].Items.Count); + Assert.AreEqual(pageTwoResponse.Items[0].Id, responsePages[1].Items[0].Id); + + Assert.AreEqual(pageThreeResponse.PageNumber, responsePages[2].PageNumber); + Assert.AreEqual(pageThreeResponse.Items.Count, responsePages[2].Items.Count); + Assert.AreEqual(pageThreeResponse.Items[0].Id, responsePages[2].Items[0].Id); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index bd935da..7bd7fbf 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -62,6 +62,13 @@ public interface IOnspringClient /// Task> GetAppAsync(int appId); + /// + /// Gets all accessible apps. + /// + /// The number of apps to return per page. + /// An async enumerable of where T is . + IAsyncEnumerable> GetAllApps(int pageSize = 50); + /// /// Gets all accessible apps. /// @@ -76,6 +83,7 @@ public interface IOnspringClient /// Task> GetAppsAsync(IEnumerable appIds); + /// /// Gets the requested field. /// @@ -182,5 +190,6 @@ public interface IOnspringClient /// /// Task> SaveRecordAsync(ResultRecord request); + } } \ No newline at end of file diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index ea190a0..07c1a83 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -103,6 +103,25 @@ public async Task CanConnectAsync() #region Apps + public async IAsyncEnumerable> GetAllApps(int pageSize = 50) + { + var initialResponse = await GetAppsAsync(new PagingRequest(1, pageSize)); + + yield return initialResponse; + + var totalPages = initialResponse.Value.TotalPages; + var nextPage = initialResponse.Value.PageNumber + 1; + + while (nextPage <= totalPages) + { + var pagingRequest = new PagingRequest(nextPage, pageSize); + var response = await GetAppsAsync(pagingRequest); + nextPage++; + + yield return response; + } + } + /// /// Gets all accessible apps. /// From 59a3da8ffa4638e3c244e0a0692fea46e1b696a0 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:54:49 -0600 Subject: [PATCH 139/168] docs: add missing xml comment --- Onspring.API.SDK/OnspringClient.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index 07c1a83..55dd691 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -103,6 +103,7 @@ public async Task CanConnectAsync() #region Apps + /// public async IAsyncEnumerable> GetAllApps(int pageSize = 50) { var initialResponse = await GetAppsAsync(new PagingRequest(1, pageSize)); From 6aaa72f839914890efdc71c59846d486801192f8 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 12:54:32 -0600 Subject: [PATCH 140/168] fix: add async to method name --- .../Tests/Integration/OnspringClientAppsTests.cs | 2 +- Onspring.API.SDK/IOnspringClient.cs | 2 +- Onspring.API.SDK/OnspringClient.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs index 6bf4fc9..c65ad6c 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs @@ -190,7 +190,7 @@ public async Task GetAllAppsAsync_WhenUsingDefaultPageSize_ReturnsAllApps() var apiClient = new OnspringClient("test", mockHttpClient); - var appsResponse = apiClient.GetAllApps(); + var appsResponse = apiClient.GetAllAppsAsync(); var responsePages = new List(); diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index 7bd7fbf..fb6ff33 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -67,7 +67,7 @@ public interface IOnspringClient /// /// The number of apps to return per page. /// An async enumerable of where T is . - IAsyncEnumerable> GetAllApps(int pageSize = 50); + IAsyncEnumerable> GetAllAppsAsync(int pageSize = 50); /// /// Gets all accessible apps. diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index 55dd691..c987eb7 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -104,7 +104,7 @@ public async Task CanConnectAsync() #region Apps /// - public async IAsyncEnumerable> GetAllApps(int pageSize = 50) + public async IAsyncEnumerable> GetAllAppsAsync(int pageSize = 50) { var initialResponse = await GetAppsAsync(new PagingRequest(1, pageSize)); From faf71262e3a47dd1ec9389487f18ce05859af532 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:00:48 -0600 Subject: [PATCH 141/168] chore: set lang version to 8 to support async streams --- Onspring.API.SDK/Onspring.API.SDK.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Onspring.API.SDK/Onspring.API.SDK.csproj b/Onspring.API.SDK/Onspring.API.SDK.csproj index 29a026d..bbe0a00 100644 --- a/Onspring.API.SDK/Onspring.API.SDK.csproj +++ b/Onspring.API.SDK/Onspring.API.SDK.csproj @@ -1,6 +1,7 @@ netstandard2.0;netstandard2.1 + 8.0 Onspring.API.SDK Onspring Technologies Onspring.API.SDK From 3c7118616456038a9adb0f5c018f7dcf3640fa4e Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:00:59 -0600 Subject: [PATCH 142/168] tests: add test for using specific page size --- .../Integration/OnspringClientAppsTests.cs | 112 +++++++++++++++++- 1 file changed, 109 insertions(+), 3 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs index c65ad6c..4009d1c 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs @@ -127,7 +127,7 @@ public async Task GetAllAppsAsync_WhenUsingDefaultPageSize_ReturnsAllApps() { Href = testAddress, Id = 1, - Name = $"Test App", + Name = "Test App", }, ] }; @@ -143,7 +143,7 @@ public async Task GetAllAppsAsync_WhenUsingDefaultPageSize_ReturnsAllApps() { Href = testAddress, Id = 2, - Name = $"Test App", + Name = "Test App", }, ] }; @@ -159,7 +159,7 @@ public async Task GetAllAppsAsync_WhenUsingDefaultPageSize_ReturnsAllApps() { Href = testAddress, Id = 3, - Name = $"Test App", + Name = "Test App", }, ] }; @@ -214,5 +214,111 @@ public async Task GetAllAppsAsync_WhenUsingDefaultPageSize_ReturnsAllApps() Assert.AreEqual(pageThreeResponse.Items.Count, responsePages[2].Items.Count); Assert.AreEqual(pageThreeResponse.Items[0].Id, responsePages[2].Items[0].Id); } + + [TestMethod] + public async Task GetAllAppsAsync_WhenUsingSpecificPageSize_ReturnsAllApps() + { + var testAddress = "https://localhost"; + + var mockHttp = new MockHttpMessageHandler(); + + var pageOneResponse = new GetPagedAppsResponse + { + PageNumber = 1, + TotalPages = 3, + TotalRecords = 3, + Items = + [ + new() + { + Href = testAddress, + Id = 1, + Name = "Test App", + }, + ] + }; + + var pageTwoResponse = new GetPagedAppsResponse + { + PageNumber = 2, + TotalPages = 3, + TotalRecords = 3, + Items = + [ + new() + { + Href = testAddress, + Id = 2, + Name = "Test App", + }, + ] + }; + + var pageThreeResponse = new GetPagedAppsResponse + { + PageNumber = 3, + TotalPages = 3, + TotalRecords = 3, + Items = + [ + new() + { + Href = testAddress, + Id = 3, + Name = "Test App", + }, + ] + }; + + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=1&PageSize=1") + .Respond( + "application/json", + JsonSerializer.Serialize(pageOneResponse) + ); + + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=2&PageSize=1") + .Respond( + "application/json", + JsonSerializer.Serialize(pageTwoResponse) + ); + + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=3&PageSize=1") + .Respond( + "application/json", + JsonSerializer.Serialize(pageThreeResponse) + ); + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var appsResponse = apiClient.GetAllAppsAsync(1); + + var responsePages = new List(); + + await foreach (var response in appsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + Assert.AreEqual(3, responsePages.Count); + + Assert.AreEqual(pageOneResponse.PageNumber, responsePages[0].PageNumber); + Assert.AreEqual(pageOneResponse.Items.Count, responsePages[0].Items.Count); + Assert.AreEqual(pageOneResponse.Items[0].Id, responsePages[0].Items[0].Id); + + Assert.AreEqual(pageTwoResponse.PageNumber, responsePages[1].PageNumber); + Assert.AreEqual(pageTwoResponse.Items.Count, responsePages[1].Items.Count); + Assert.AreEqual(pageTwoResponse.Items[0].Id, responsePages[1].Items[0].Id); + + Assert.AreEqual(pageThreeResponse.PageNumber, responsePages[2].PageNumber); + Assert.AreEqual(pageThreeResponse.Items.Count, responsePages[2].Items.Count); + Assert.AreEqual(pageThreeResponse.Items[0].Id, responsePages[2].Items[0].Id); + } } } \ No newline at end of file From fe12fd21d6ac9fc31b098a198f99ea94d9e583ad Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:13:23 -0600 Subject: [PATCH 143/168] tests: clean up test methods --- .../Infrastructure/TestDataFactory.cs | 32 +++ .../Integration/OnspringClientAppsTests.cs | 198 ++++-------------- 2 files changed, 71 insertions(+), 159 deletions(-) diff --git a/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs b/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs index ca09c20..9b9caca 100644 --- a/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs +++ b/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs @@ -32,5 +32,37 @@ public static ResultRecord GetFullyFilledOutRecord(int appId, int recordId) } }; } + + public static List GetPagesOfApps(int totalApps, int pageSize) + { + var pages = new List(); + var totalPages = (int)Math.Ceiling((double)totalApps / pageSize); + + for (var i = 1; i <= totalPages; i++) + { + var page = new GetPagedAppsResponse + { + PageNumber = i, + TotalPages = totalPages, + TotalRecords = totalApps, + Items = [] + }; + + for (var j = 1; j <= pageSize; j++) + { + var app = new App + { + Id = (i - 1) * pageSize + j, + Name = "App" + }; + + page.Items.Add(app); + } + + pages.Add(page); + } + + return pages; + } } } diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs index 4009d1c..efe53e5 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientAppsTests.cs @@ -114,76 +114,21 @@ public async Task GetAllAppsAsync_WhenUsingDefaultPageSize_ReturnsAllApps() { var testAddress = "https://localhost"; + var numberOfApps = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfApps(numberOfApps, pageSize); + var mockHttp = new MockHttpMessageHandler(); - var pageOneResponse = new GetPagedAppsResponse - { - PageNumber = 1, - TotalPages = 3, - TotalRecords = 3, - Items = - [ - new() - { - Href = testAddress, - Id = 1, - Name = "Test App", - }, - ] - }; - - var pageTwoResponse = new GetPagedAppsResponse + foreach (var page in pages) { - PageNumber = 2, - TotalPages = 3, - TotalRecords = 3, - Items = - [ - new() - { - Href = testAddress, - Id = 2, - Name = "Test App", - }, - ] - }; - - var pageThreeResponse = new GetPagedAppsResponse - { - PageNumber = 3, - TotalPages = 3, - TotalRecords = 3, - Items = - [ - new() - { - Href = testAddress, - Id = 3, - Name = "Test App", - }, - ] - }; - - mockHttp - .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=1&PageSize=50") - .Respond( - "application/json", - JsonSerializer.Serialize(pageOneResponse) - ); - - mockHttp - .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=2&PageSize=50") - .Respond( - "application/json", - JsonSerializer.Serialize(pageTwoResponse) - ); - - mockHttp - .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=3&PageSize=50") - .Respond( - "application/json", - JsonSerializer.Serialize(pageThreeResponse) - ); + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } var mockHttpClient = mockHttp.ToHttpClient(); mockHttpClient.BaseAddress = new(testAddress); @@ -200,19 +145,14 @@ public async Task GetAllAppsAsync_WhenUsingDefaultPageSize_ReturnsAllApps() responsePages.Add(response.Value); } - Assert.AreEqual(3, responsePages.Count); - - Assert.AreEqual(pageOneResponse.PageNumber, responsePages[0].PageNumber); - Assert.AreEqual(pageOneResponse.Items.Count, responsePages[0].Items.Count); - Assert.AreEqual(pageOneResponse.Items[0].Id, responsePages[0].Items[0].Id); - - Assert.AreEqual(pageTwoResponse.PageNumber, responsePages[1].PageNumber); - Assert.AreEqual(pageTwoResponse.Items.Count, responsePages[1].Items.Count); - Assert.AreEqual(pageTwoResponse.Items[0].Id, responsePages[1].Items[0].Id); + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); - Assert.AreEqual(pageThreeResponse.PageNumber, responsePages[2].PageNumber); - Assert.AreEqual(pageThreeResponse.Items.Count, responsePages[2].Items.Count); - Assert.AreEqual(pageThreeResponse.Items[0].Id, responsePages[2].Items[0].Id); + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } } [TestMethod] @@ -222,81 +162,26 @@ public async Task GetAllAppsAsync_WhenUsingSpecificPageSize_ReturnsAllApps() var mockHttp = new MockHttpMessageHandler(); - var pageOneResponse = new GetPagedAppsResponse - { - PageNumber = 1, - TotalPages = 3, - TotalRecords = 3, - Items = - [ - new() - { - Href = testAddress, - Id = 1, - Name = "Test App", - }, - ] - }; - - var pageTwoResponse = new GetPagedAppsResponse - { - PageNumber = 2, - TotalPages = 3, - TotalRecords = 3, - Items = - [ - new() - { - Href = testAddress, - Id = 2, - Name = "Test App", - }, - ] - }; - - var pageThreeResponse = new GetPagedAppsResponse + var numberOfApps = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfApps(numberOfApps, pageSize); + + foreach (var page in pages) { - PageNumber = 3, - TotalPages = 3, - TotalRecords = 3, - Items = - [ - new() - { - Href = testAddress, - Id = 3, - Name = "Test App", - }, - ] - }; - - mockHttp - .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=1&PageSize=1") - .Respond( - "application/json", - JsonSerializer.Serialize(pageOneResponse) - ); - - mockHttp - .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=2&PageSize=1") - .Respond( - "application/json", - JsonSerializer.Serialize(pageTwoResponse) - ); - - mockHttp - .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber=3&PageSize=1") - .Respond( - "application/json", - JsonSerializer.Serialize(pageThreeResponse) - ); + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } var mockHttpClient = mockHttp.ToHttpClient(); mockHttpClient.BaseAddress = new(testAddress); var apiClient = new OnspringClient("test", mockHttpClient); - var appsResponse = apiClient.GetAllAppsAsync(1); + var appsResponse = apiClient.GetAllAppsAsync(pageSize); var responsePages = new List(); @@ -306,19 +191,14 @@ public async Task GetAllAppsAsync_WhenUsingSpecificPageSize_ReturnsAllApps() responsePages.Add(response.Value); } - Assert.AreEqual(3, responsePages.Count); - - Assert.AreEqual(pageOneResponse.PageNumber, responsePages[0].PageNumber); - Assert.AreEqual(pageOneResponse.Items.Count, responsePages[0].Items.Count); - Assert.AreEqual(pageOneResponse.Items[0].Id, responsePages[0].Items[0].Id); - - Assert.AreEqual(pageTwoResponse.PageNumber, responsePages[1].PageNumber); - Assert.AreEqual(pageTwoResponse.Items.Count, responsePages[1].Items.Count); - Assert.AreEqual(pageTwoResponse.Items[0].Id, responsePages[1].Items[0].Id); + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); - Assert.AreEqual(pageThreeResponse.PageNumber, responsePages[2].PageNumber); - Assert.AreEqual(pageThreeResponse.Items.Count, responsePages[2].Items.Count); - Assert.AreEqual(pageThreeResponse.Items[0].Id, responsePages[2].Items[0].Id); + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } } } } \ No newline at end of file From ed271e40e76e59d6e9ec20951818746c8ee176ad Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:58:29 -0600 Subject: [PATCH 144/168] tests: add method to support get page of items to share between helper methods --- .../Infrastructure/TestDataFactory.cs | 60 ++++++++++++++----- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs b/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs index 9b9caca..cb23ac9 100644 --- a/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs +++ b/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs @@ -33,36 +33,64 @@ public static ResultRecord GetFullyFilledOutRecord(int appId, int recordId) }; } - public static List GetPagesOfApps(int totalApps, int pageSize) + public static List GetPagesOfApps(int totalApps, int pageSize) => GetPages( + totalApps, + pageSize, + i => new App { Id = i, Name = "App" }, + (pageNumber, totalPages, totalRecords, items) => new GetPagedAppsResponse + { + PageNumber = pageNumber, + TotalPages = totalPages, + TotalRecords = totalRecords, + Items = items + } + ); + + public static List GetPagesOfFields(int totalFields, int pageSize) => GetPages( + totalFields, + pageSize, + i => new Field { Id = i, Name = "Field" }, + (pageNumber, totalPages, totalRecords, items) => new GetPagedFieldsResponse + { + PageNumber = pageNumber, + TotalPages = totalPages, + TotalRecords = totalRecords, + Items = items + } + ); + + public static List GetPages( + int totalItems, + int pageSize, + Func createItem, + Func, TResponse> createResponse + ) where TResponse : class { - var pages = new List(); - var totalPages = (int)Math.Ceiling((double)totalApps / pageSize); + var pages = new List(); + var totalPages = (int)Math.Ceiling((double)totalItems / pageSize); for (var i = 1; i <= totalPages; i++) { - var page = new GetPagedAppsResponse - { - PageNumber = i, - TotalPages = totalPages, - TotalRecords = totalApps, - Items = [] - }; + var items = new List(); for (var j = 1; j <= pageSize; j++) { - var app = new App + var itemIndex = (i - 1) * pageSize + j; + + if (itemIndex > totalItems) { - Id = (i - 1) * pageSize + j, - Name = "App" - }; + break; + } - page.Items.Add(app); + items.Add(createItem(itemIndex)); } - pages.Add(page); + var response = createResponse(i, totalPages, totalItems, items); + pages.Add(response); } return pages; } + } } From ca1ddbc0c581d63d500454dcca30bc5be918dbb2 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:59:34 -0600 Subject: [PATCH 145/168] feat: allow page response model to not require type parameter --- Onspring.API.SDK/Models/PagedResponse.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Onspring.API.SDK/Models/PagedResponse.cs b/Onspring.API.SDK/Models/PagedResponse.cs index 709d9b6..0b1b33c 100644 --- a/Onspring.API.SDK/Models/PagedResponse.cs +++ b/Onspring.API.SDK/Models/PagedResponse.cs @@ -13,18 +13,13 @@ namespace Onspring.API.SDK.Models /// /// Represents a response to request that has paged items. /// - public class PagedResponse + public class PagedResponse { /// /// Gets the page number of the response. /// public int PageNumber { get; set; } - /// - /// Gets the size of the page. - /// - public int PageSize => Items?.Count ?? 0; - /// /// Gets the total amount of pages. /// @@ -34,10 +29,19 @@ public class PagedResponse /// Gets the total amount of records. /// public int TotalRecords { get; set; } + } + /// + public class PagedResponse : PagedResponse + { /// /// Gets the collection of items in the response. /// public List Items { get; set; } = new List(); + + /// + /// Gets the size of the page. + /// + public int PageSize => Items?.Count ?? 0; } } From 4b7938e64583342138a24b045cbe3496830fdc8d Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:59:48 -0600 Subject: [PATCH 146/168] feat: added method for getting all fields in app --- .../Integration/OnspringClientFieldTests.cs | 97 +++++++++++++++++++ Onspring.API.SDK/IOnspringClient.cs | 8 ++ Onspring.API.SDK/OnspringClient.cs | 41 +++++--- 3 files changed, 134 insertions(+), 12 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs index 8d118c7..dfce8b2 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs @@ -1,9 +1,14 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using RichardSzalay.MockHttp; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Net.Http; +using System.Text.Json; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration @@ -45,5 +50,97 @@ public async Task GetFieldsForAppAsync() var getResponse = await _apiClient.GetFieldsForAppAsync(_appIdWithFields); AssertHelper.AssertSuccess(getResponse); } + + [TestMethod] + public async Task GetAllFieldsAsync_WhenUsingDefaultPageSize_ReturnsAllFields() + { + var testAddress = "https://localhost"; + + var numberOfFields = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfFields(numberOfFields, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/fields/appId/1?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var fieldsResponse = apiClient.GetAllFieldsForAppAsync(1); + + var responsePages = new List(); + + await foreach (var response in fieldsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } + + [TestMethod] + public async Task GetAllFieldsAsync_WhenUsingSpecificPageSize_ReturnsAllFields() + { + var testAddress = "https://localhost"; + + var numberOfFields = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfFields(numberOfFields, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/fields/appId/1?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var fieldsResponse = apiClient.GetAllFieldsForAppAsync(appId: 1, pageSize: 1); + + var responsePages = new List(); + + await foreach (var response in fieldsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index fb6ff33..4e18461 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -91,6 +91,14 @@ public interface IOnspringClient /// Task> GetFieldAsync(int fieldId); + /// + /// Gets all accessible fields. + /// + /// The identifier of the app to get fields for. + /// The number of fields to return per page. + /// An async enumerable of where T is . + IAsyncEnumerable> GetAllFieldsForAppAsync(int appId, int pageSize = 50); + /// /// Gets the requested fields. /// diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index c987eb7..357ed0b 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -106,19 +106,8 @@ public async Task CanConnectAsync() /// public async IAsyncEnumerable> GetAllAppsAsync(int pageSize = 50) { - var initialResponse = await GetAppsAsync(new PagingRequest(1, pageSize)); - - yield return initialResponse; - - var totalPages = initialResponse.Value.TotalPages; - var nextPage = initialResponse.Value.PageNumber + 1; - - while (nextPage <= totalPages) + await foreach (var response in GetAllPagesAsync(page => GetAppsAsync(new PagingRequest(page, pageSize)))) { - var pagingRequest = new PagingRequest(nextPage, pageSize); - var response = await GetAppsAsync(pagingRequest); - nextPage++; - yield return response; } } @@ -165,6 +154,15 @@ public async Task> GetAppsAsync(IEnumerable ap #region Fields + /// + public async IAsyncEnumerable> GetAllFieldsForAppAsync(int appId, int pageSize = 50) + { + await foreach (var response in GetAllPagesAsync(page => GetFieldsForAppAsync(appId, new PagingRequest(page, pageSize)))) + { + yield return response; + } + } + /// /// Gets the requested field. Returns null if field could not be found. /// @@ -485,6 +483,25 @@ public async Task> GetReportsForAppAsync(i // ------------------------------------ Client internals ------------------------------------ + // Common method to use for methods that return paged resposnes + private async IAsyncEnumerable> GetAllPagesAsync(Func>> callback) where T : PagedResponse + { + var initialResponse = await callback(1); + + yield return initialResponse; + + var totalPages = initialResponse.Value.TotalPages; + var nextPage = initialResponse.Value.PageNumber + 1; + + while (nextPage <= totalPages) + { + var response = await callback(nextPage); + nextPage++; + + yield return response; + } + } + /// /// Performs an HTTP DELETE request to the and adds an API Key header. /// From 1c8603525ed8b9e98f8e2dddde1bbae4bde70a11 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 14:02:31 -0600 Subject: [PATCH 147/168] docs: add missing xml docs for new client internal method --- Onspring.API.SDK/OnspringClient.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index 357ed0b..d086104 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -483,7 +483,12 @@ public async Task> GetReportsForAppAsync(i // ------------------------------------ Client internals ------------------------------------ - // Common method to use for methods that return paged resposnes + /// + /// Gets all pages of a paged response. + /// + /// Where T is a paged response. + /// The callback to get a page of the response. + /// An async enumerable of the paged response. private async IAsyncEnumerable> GetAllPagesAsync(Func>> callback) where T : PagedResponse { var initialResponse = await callback(1); From 2312378991e5ded72cf6f92470ef198082660ded Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 8 Dec 2024 14:07:11 -0600 Subject: [PATCH 148/168] chore: whitelist words --- .vscode/settings.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index a36a90c..3ba0bbc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,4 +2,8 @@ "editor.formatOnSave": true, "dotnet.defaultSolution": "./Onspring.API.SDK.sln", "dotnet.unitTests.runSettingsPath": "./Onspring.API.SDK.Tests/runsettings/internal.runsettings", + "cSpell.words": [ + "netstandard", + "Szalay" + ], } From 92fd3f55939f60e64bb3c0132bbdfcef6ac9f310 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:03:20 -0600 Subject: [PATCH 149/168] feat: add GetAllReportsForAppAsync method --- .../Infrastructure/TestDataFactory.cs | 13 +++ .../Integration/OnspringClientReportsTests.cs | 97 +++++++++++++++++++ Onspring.API.SDK/IOnspringClient.cs | 8 ++ Onspring.API.SDK/OnspringClient.cs | 9 ++ 4 files changed, 127 insertions(+) diff --git a/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs b/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs index cb23ac9..0a24623 100644 --- a/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs +++ b/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs @@ -59,6 +59,19 @@ public static List GetPagesOfFields(int totalFields, int } ); + public static List GetPagesOfReports(int totalReports, int pageSize) => GetPages( + totalReports, + pageSize, + i => new Report { Id = i, Name = "Report" }, + (pageNumber, totalPages, totalRecords, items) => new GetReportsForAppResponse + { + PageNumber = pageNumber, + TotalPages = totalPages, + TotalRecords = totalRecords, + Items = items + } + ); + public static List GetPages( int totalItems, int pageSize, diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs index ac4f3b0..7d86646 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs @@ -3,7 +3,12 @@ using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using RichardSzalay.MockHttp; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net.Http; +using System.Text.Json; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration @@ -39,5 +44,97 @@ public async Task GetReportsForAppAsync() AssertHelper.AssertSuccess(getResponse); AssertHelper.AssertPaging(pagingRequest, getResponse.Value); } + + [TestMethod] + public async Task GetAllReportsAsync_WhenUsingDefaultPageSize_ReturnsAllFields() + { + var testAddress = "https://localhost"; + + var numberOfReports = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfFields(numberOfReports, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/reports/appId/1?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var fieldsResponse = apiClient.GetAllReportsForAppAsync(1); + + var responsePages = new List(); + + await foreach (var response in fieldsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } + + [TestMethod] + public async Task GetAllReportsAsync_WhenUsingSpecificPageSize_ReturnsAllFields() + { + var testAddress = "https://localhost"; + + var numberOfReports = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfReports(numberOfReports, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/reports/appId/1?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var fieldsResponse = apiClient.GetAllReportsForAppAsync(appId: 1, pageSize: 1); + + var responsePages = new List(); + + await foreach (var response in fieldsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index 4e18461..181b830 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -170,6 +170,14 @@ public interface IOnspringClient /// Task> GetReportsForAppAsync(int appId, PagingRequest pagingRequest = null); + /// + /// Gets all reports associated to the . + /// + /// The identifier of the app to get reports for. + /// The number of reports to return per page. + /// An async enumerable of where T is . + IAsyncEnumerable> GetAllReportsForAppAsync(int appId, int pageSize = 50); + /// /// Queries records. /// diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index d086104..d1f830e 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -479,6 +479,15 @@ public async Task> GetReportsForAppAsync(i return getReportsResponse; } + /// + public async IAsyncEnumerable> GetAllReportsForAppAsync(int appId, int pageSize = 50) + { + await foreach (var response in GetAllPagesAsync(page => GetReportsForAppAsync(appId, new PagingRequest(page, pageSize)))) + { + yield return response; + } + } + #endregion // ------------------------------------ Client internals ------------------------------------ From 213b60af6dc5a7e9563a4fef2c6daed6364160f4 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:26:54 -0600 Subject: [PATCH 150/168] tests: fix copy pasta mistakes --- .../Integration/OnspringClientReportsTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs index 7d86646..660c4d0 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs @@ -46,13 +46,13 @@ public async Task GetReportsForAppAsync() } [TestMethod] - public async Task GetAllReportsAsync_WhenUsingDefaultPageSize_ReturnsAllFields() + public async Task GetAllReportsAsync_WhenUsingDefaultPageSize_ReturnsAllReports() { var testAddress = "https://localhost"; var numberOfReports = 3; var pageSize = 50; - var pages = TestDataFactory.GetPagesOfFields(numberOfReports, pageSize); + var pages = TestDataFactory.GetPagesOfReports(numberOfReports, pageSize); var mockHttp = new MockHttpMessageHandler(); @@ -71,11 +71,11 @@ public async Task GetAllReportsAsync_WhenUsingDefaultPageSize_ReturnsAllFields() var apiClient = new OnspringClient("test", mockHttpClient); - var fieldsResponse = apiClient.GetAllReportsForAppAsync(1); + var reportsResponse = apiClient.GetAllReportsForAppAsync(1); var responsePages = new List(); - await foreach (var response in fieldsResponse) + await foreach (var response in reportsResponse) { AssertHelper.AssertSuccess(response); responsePages.Add(response.Value); @@ -92,7 +92,7 @@ public async Task GetAllReportsAsync_WhenUsingDefaultPageSize_ReturnsAllFields() } [TestMethod] - public async Task GetAllReportsAsync_WhenUsingSpecificPageSize_ReturnsAllFields() + public async Task GetAllReportsAsync_WhenUsingSpecificPageSize_ReturnsAllReports() { var testAddress = "https://localhost"; @@ -117,11 +117,11 @@ public async Task GetAllReportsAsync_WhenUsingSpecificPageSize_ReturnsAllFields( var apiClient = new OnspringClient("test", mockHttpClient); - var fieldsResponse = apiClient.GetAllReportsForAppAsync(appId: 1, pageSize: 1); + var reportsResponse = apiClient.GetAllReportsForAppAsync(appId: 1, pageSize: 1); var responsePages = new List(); - await foreach (var response in fieldsResponse) + await foreach (var response in reportsResponse) { AssertHelper.AssertSuccess(response); responsePages.Add(response.Value); From fb6305251e92d9f4145169c368268859976b80f9 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:30:14 -0600 Subject: [PATCH 151/168] tests: fix method names --- .../Tests/Integration/OnspringClientFieldTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs index dfce8b2..6971338 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientFieldTests.cs @@ -52,7 +52,7 @@ public async Task GetFieldsForAppAsync() } [TestMethod] - public async Task GetAllFieldsAsync_WhenUsingDefaultPageSize_ReturnsAllFields() + public async Task GetAllFieldsForAppAsync_WhenUsingDefaultPageSize_ReturnsAllFields() { var testAddress = "https://localhost"; @@ -98,7 +98,7 @@ public async Task GetAllFieldsAsync_WhenUsingDefaultPageSize_ReturnsAllFields() } [TestMethod] - public async Task GetAllFieldsAsync_WhenUsingSpecificPageSize_ReturnsAllFields() + public async Task GetAllFieldsForAppAsync_WhenUsingSpecificPageSize_ReturnsAllFields() { var testAddress = "https://localhost"; From ae1654cad38dbf74ab95b99d095b3b88a43c5d54 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:30:27 -0600 Subject: [PATCH 152/168] fix: method names --- .../Tests/Integration/OnspringClientReportsTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs index 660c4d0..9302d9a 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientReportsTests.cs @@ -46,7 +46,7 @@ public async Task GetReportsForAppAsync() } [TestMethod] - public async Task GetAllReportsAsync_WhenUsingDefaultPageSize_ReturnsAllReports() + public async Task GetAllReportsForAppAsync_WhenUsingDefaultPageSize_ReturnsAllReports() { var testAddress = "https://localhost"; @@ -92,7 +92,7 @@ public async Task GetAllReportsAsync_WhenUsingDefaultPageSize_ReturnsAllReports( } [TestMethod] - public async Task GetAllReportsAsync_WhenUsingSpecificPageSize_ReturnsAllReports() + public async Task GetAllReportsForAppAsync_WhenUsingSpecificPageSize_ReturnsAllReports() { var testAddress = "https://localhost"; From bfeec210f06cf50121205acf5c8c29e633d6cedd Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:17:29 -0600 Subject: [PATCH 153/168] tests: add test for getting all records for an app --- .../Infrastructure/TestDataFactory.cs | 13 +++ .../Integration/OnspringClientRecordsTests.cs | 98 +++++++++++++++++++ 2 files changed, 111 insertions(+) diff --git a/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs b/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs index 0a24623..c25c1a4 100644 --- a/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs +++ b/Onspring.API.SDK.Tests/Infrastructure/TestDataFactory.cs @@ -72,6 +72,19 @@ public static List GetPagesOfReports(int totalReports, } ); + public static List GetPagesOfRecords(int totalRecords, int pageSize) => GetPages( + totalRecords, + pageSize, + i => new ResultRecord { RecordId = i }, + (pageNumber, totalPages, totalRecords, items) => new GetPagedRecordsResponse + { + PageNumber = pageNumber, + TotalPages = totalPages, + TotalRecords = totalRecords, + Items = items + } + ); + public static List GetPages( int totalItems, int pageSize, diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs index b58b894..9381102 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs @@ -1,11 +1,16 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Enums; using Onspring.API.SDK.Models; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using RichardSzalay.MockHttp; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net.Http; +using System.Text.Json; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration @@ -104,6 +109,99 @@ public async Task CrudAsync() AssertHelper.AssertSuccess(batchDeleteResponse); } + [TestMethod] + public async Task GetAllRecordsForAppAsync_WhenUsingDefaultPageSize_ReturnsAllRecords() + { + var testAddress = "https://localhost"; + + var numberOfReports = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfRecords(numberOfReports, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/records/appId/1?dataFormat={DataFormat.Raw}&PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var reportsResponse = apiClient.GetAllRecordsForAppAsync(new GetRecordsByAppRequest(1)); + + var responsePages = new List(); + + await foreach (var response in reportsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].RecordId, responsePage.Items[0].RecordId); + } + } + + [TestMethod] + public async Task GetAllRecordsForAppAsync_WhenUsingSpecificPageSize_ReturnsAllRecords() + { + var testAddress = "https://localhost"; + + var numberOfReports = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfRecords(numberOfReports, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/records/appId/1?dataFormat={DataFormat.Raw}&PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var reportsResponse = apiClient.GetAllRecordsForAppAsync(new GetRecordsByAppRequest(1, new PagingRequest(1, pageSize))); + + var responsePages = new List(); + + await foreach (var response in reportsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].RecordId, responsePage.Items[0].RecordId); + } + } + + private static void UpdateRecordFields(ResultRecord record) { var random = new Random(); From a65e41d5716a984c0a3d55b7d667c0390065da03 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:17:43 -0600 Subject: [PATCH 154/168] feat: add GetAllRecordsForAppAsync --- Onspring.API.SDK/IOnspringClient.cs | 7 +++++++ Onspring.API.SDK/OnspringClient.cs | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index 181b830..0385ce3 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -153,6 +153,13 @@ public interface IOnspringClient /// Task> GetRecordsForAppAsync(GetRecordsByAppRequest request); + /// + /// Gets all records associated to an app. + /// + /// An instance of . + /// An async enumerable of where T is . + IAsyncEnumerable> GetAllRecordsForAppAsync(GetRecordsByAppRequest request); + /// /// Gets the report for . /// diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index d1f830e..cd0a725 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -361,6 +361,21 @@ public async Task> GetRecordsForAppAsync(Ge return apiResponse; } + /// + public async IAsyncEnumerable> GetAllRecordsForAppAsync(GetRecordsByAppRequest request) + { + var callback = new Func>>(page => + { + request.PagingRequest = new PagingRequest(page, request.PagingRequest?.PageSize ?? 50); + return GetRecordsForAppAsync(request); + }); + + await foreach (var response in GetAllPagesAsync(callback)) + { + yield return response; + } + } + /// /// Gets a record by its identifier. /// From c09ab93391b7330292d67ad026833f3e232b6fef Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 9 Dec 2024 23:36:07 -0600 Subject: [PATCH 155/168] feat: add GetAllRecordsByQueryAsync method --- .../Integration/OnspringClientRecordsTests.cs | 91 +++++++++++++++++++ Onspring.API.SDK/IOnspringClient.cs | 51 ++++++----- Onspring.API.SDK/OnspringClient.cs | 9 ++ 3 files changed, 130 insertions(+), 21 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs index 9381102..3934097 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientRecordsTests.cs @@ -201,6 +201,97 @@ public async Task GetAllRecordsForAppAsync_WhenUsingSpecificPageSize_ReturnsAllR } } + [TestMethod] + public async Task GetAllRecordsByQueryAsync_WhenUsingDefaultPageSize_ReturnsAllRecords() + { + var testAddress = "https://localhost"; + + var numberOfReports = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfRecords(numberOfReports, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Post, $"{testAddress}/records/query?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var reportsResponse = apiClient.GetAllRecordsByQueryAsync(new QueryRecordsRequest { AppId = 1 }); + + var responsePages = new List(); + + await foreach (var response in reportsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].RecordId, responsePage.Items[0].RecordId); + } + } + + [TestMethod] + public async Task GetAllRecordsByQueryAsync_WhenUsingSpecificPageSize_ReturnsAllRecords() + { + var testAddress = "https://localhost"; + + var numberOfReports = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfRecords(numberOfReports, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Post, $"{testAddress}/records/query?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var reportsResponse = apiClient.GetAllRecordsByQueryAsync(new QueryRecordsRequest { AppId = 1 }, pageSize); + + var responsePages = new List(); + + await foreach (var response in reportsResponse) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].RecordId, responsePage.Items[0].RecordId); + } + } private static void UpdateRecordFields(ResultRecord record) { diff --git a/Onspring.API.SDK/IOnspringClient.cs b/Onspring.API.SDK/IOnspringClient.cs index 0385ce3..1f93f4e 100644 --- a/Onspring.API.SDK/IOnspringClient.cs +++ b/Onspring.API.SDK/IOnspringClient.cs @@ -91,6 +91,13 @@ public interface IOnspringClient /// Task> GetFieldAsync(int fieldId); + /// + /// Gets the requested fields. + /// + /// + /// + Task> GetFieldsAsync(IEnumerable fieldIds); + /// /// Gets all accessible fields. /// @@ -99,12 +106,6 @@ public interface IOnspringClient /// An async enumerable of where T is . IAsyncEnumerable> GetAllFieldsForAppAsync(int appId, int pageSize = 50); - /// - /// Gets the requested fields. - /// - /// - /// - Task> GetFieldsAsync(IEnumerable fieldIds); /// /// Gets the fields associated to the . @@ -146,13 +147,6 @@ public interface IOnspringClient /// Task> GetRecordsAsync(GetRecordsRequest request); - /// - /// Gets the records associated to an app. - /// - /// - /// - Task> GetRecordsForAppAsync(GetRecordsByAppRequest request); - /// /// Gets all records associated to an app. /// @@ -160,6 +154,21 @@ public interface IOnspringClient /// An async enumerable of where T is . IAsyncEnumerable> GetAllRecordsForAppAsync(GetRecordsByAppRequest request); + /// + /// Gets all records by query. + /// + /// An instance of . + /// The number of records to return per page. + /// An async enumerable of where T is . + IAsyncEnumerable> GetAllRecordsByQueryAsync(QueryRecordsRequest request, int pageSize = 50); + + /// + /// Gets the records associated to an app. + /// + /// + /// + Task> GetRecordsForAppAsync(GetRecordsByAppRequest request); + /// /// Gets the report for . /// @@ -169,14 +178,6 @@ public interface IOnspringClient /// Task> GetReportAsync(int reportId, ReportDataType dataType = ReportDataType.ReportData, DataFormat dataFormat = DataFormat.Raw); - /// - /// Gets the reports associated to the . - /// - /// - /// - /// - Task> GetReportsForAppAsync(int appId, PagingRequest pagingRequest = null); - /// /// Gets all reports associated to the . /// @@ -185,6 +186,14 @@ public interface IOnspringClient /// An async enumerable of where T is . IAsyncEnumerable> GetAllReportsForAppAsync(int appId, int pageSize = 50); + /// + /// Gets the reports associated to the . + /// + /// + /// + /// + Task> GetReportsForAppAsync(int appId, PagingRequest pagingRequest = null); + /// /// Queries records. /// diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index cd0a725..9d24dbb 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -376,6 +376,15 @@ public async IAsyncEnumerable> GetAllRecord } } + /// + public async IAsyncEnumerable> GetAllRecordsByQueryAsync(QueryRecordsRequest request, int pageSize = 50) + { + await foreach (var response in GetAllPagesAsync(page => QueryRecordsAsync(request, new PagingRequest(page, pageSize)))) + { + yield return response; + } + } + /// /// Gets a record by its identifier. /// From a1181dfa1e4518de9d5cca12041fc77fd7fd9462 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 9 Dec 2024 23:57:39 -0600 Subject: [PATCH 156/168] docs: update README with section about methods that assist with pagination using IAsyncEnumerable --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9cf051..3e50fd7 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ In order to successfully interact with the Onspring API, you must use an API key 2. On the list page, add a new API Key (requires Create permissions) or click an existing API Key to view its details. 3. On the details page for an API Key, expand the **Developer Information** section. Copy the **X-ApiKey Header** value from this section. -#### Important +### Important - An API Key must have a **Status** of _Enabled_ (available on the details page) in order to be used. - Each API Key has an associated **Role** that controls the permissions for requests made using that API Key. An Onspring administrator may configure those permissions as they would any other Role in Onspring. If the API Key does not have sufficient permissions to perform the requested action, an error will be returned. @@ -114,7 +114,7 @@ bool canConnect = await onspringClient.CanConnectAsync(); Returns a paged collection of apps/surveys, which can be paged through using the `Onspring.API.SDK.Models.PagingRequest`. -##### Basic +#### Basic ```C# var apps = await onspringClient.GetAppsAsync(); @@ -124,7 +124,7 @@ foreach (App app in apps) } ``` -##### Paged +#### Paged Async and synchronous methods allow use of `Onspring.API.SDK.Models.PagingRequest`. @@ -379,3 +379,42 @@ using (var result = getFileResponse.Value) } } ``` + +### Pagination Done For You + +There are several methods on the `IOnspringClient` that return a paged collection of items. These include: + +- `GetAppsAsync` +- `GetFieldsForAppAsync` +- `GetReportsForAppAsync` +- `QueryRecordsAsync` +- `GetRecordsForAppAsync` + +Using these methods allows the caller to page through the results, but requires the caller to handle the pagination process themselves. This can feel like a chore, given that in the vast majority of cases the caller will want to iterate through all the pages. In order to improve developer experience, the SDK provides a set of wrapper methods that handle the pagination process for you by leveraging the `IAsyncEnumerable` interface. These methods accept all the same parameters as the methods they wrap, but when it comes to paging they only allow you to control the size of each page and they internally can moving from the first page to the last for you. These methods include: + +- `GetAllAppsAsync` +- `GetAllFieldsForAppAsync` +- `GetAllReportsForAppAsync` +- `GetAllRecordsByQueryAsync` +- `GetAllRecordsForAppAsync` + +These methods return an `IAsyncEnumerable` that allows the caller to iterate through all pages. The caller can use the `await foreach` construct to iterate through the items. The value of each iteration is an `ApiResponse` where `T` is the response that was received for that page. The following example demonstrates how to use these methods: + +```C# +var appsResponses = onspringClient.GetAllAppsAsync(); + +await foreach (var response in appsResponses) +{ + if (response.IsSuccessful) + { + foreach (var app in response.Value.Items) + { + Console.WriteLine($"{app.Id}, {app.Name}"); + } + } + else + { + Console.WriteLine($"Error: {response.Message}"); + } +} +``` From ededcb71825f0025cd463faeeb4751f00d493365 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 10 Dec 2024 00:13:15 -0600 Subject: [PATCH 157/168] feat: begin to think through fluent API for new methods that return IAsyncEnumerable --- .../Fluent/OnspringClientAppsTests.cs | 14 ++++++++++++++ .../Fluent/IOnspringRequestBuilder.cs | 2 ++ .../Fluent/Pagination/IPagedRequestBuilder.cs | 10 ++++++++++ .../Models/Fluent/OnspringRequestBuilder.cs | 5 +++++ .../Fluent/Pagination/PagedRequestBuilder.cs | 19 +++++++++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs index e132a00..05be41c 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs @@ -55,5 +55,19 @@ public async Task GetApps() AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task GetAllApps() + { + var apiResponse = await _apiClient + .CreateRequest() + .ToGetAllPages() + .OfApps() + .SendAsync(); // TODO: Need to refactor to separate class and interface + // so that we can call the GetAllAppsAsync method as + // the send async implementation + + AssertHelper.AssertSuccess(apiResponse); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index 6b467c6..aa8b800 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -88,5 +88,7 @@ public interface IOnspringRequestBuilder /// /// A builder instance for retrieving apps that implements the interface. IGetAppsRequestBuilder ToGetApps(); + + IPagedRequestBuilder ToGetAllPages(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs new file mode 100644 index 0000000..41519c2 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs @@ -0,0 +1,10 @@ +using Onspring.API.SDK.Models; +using System.Threading.Tasks; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IPagedRequestBuilder + { + IGetPagedAppsRequestBuilder OfApps(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs index ffc6439..d2f03be 100644 --- a/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/OnspringRequestBuilder.cs @@ -88,5 +88,10 @@ public IGetAppsRequestBuilder ToGetApps() { return new GetAppsRequestBuilder(_client); } + + public IPagedRequestBuilder ToGetAllPages() + { + return new PagedRequestBuilder(_client); + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs new file mode 100644 index 0000000..7ab4d65 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs @@ -0,0 +1,19 @@ +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class PagedRequestBuilder : IPagedRequestBuilder + { + private readonly IOnspringClient _client; + + internal PagedRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetPagedAppsRequestBuilder OfApps() + { + return new GetPagedAppsRequestBuilder(_client, 1); + } + } +} \ No newline at end of file From 0434dddb85b5f551d13183ae52f43bd01cfa6afa Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 10 Dec 2024 21:56:23 -0600 Subject: [PATCH 158/168] feat: add fluent interface support for getting all app pages --- .../Fluent/OnspringClientAppsTests.cs | 54 +++++++++++++++++-- .../Apps/IGetAllAppsPagesRequestBuilder.cs | 14 +++++ .../Fluent/Pagination/IPagedRequestBuilder.cs | 2 +- .../Apps/GetAllAppsPagesRequestBuilder.cs | 30 +++++++++++ .../Fluent/Pagination/PagedRequestBuilder.cs | 4 +- 5 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs index 05be41c..d0fc906 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs @@ -1,11 +1,19 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using RichardSzalay.MockHttp; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net.Http; +using System.Text.Json; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent { + [TestClass, ExcludeFromCodeCoverage] public class OnspringClientAppsTests { private static OnspringClient _apiClient; @@ -59,15 +67,51 @@ public async Task GetApps() [TestMethod] public async Task GetAllApps() { - var apiResponse = await _apiClient + var testAddress = "https://localhost"; + + var numberOfApps = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfApps(numberOfApps, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var appsResponses = apiClient .CreateRequest() .ToGetAllPages() .OfApps() - .SendAsync(); // TODO: Need to refactor to separate class and interface - // so that we can call the GetAllAppsAsync method as - // the send async implementation + .SendAsync(); - AssertHelper.AssertSuccess(apiResponse); + var responsePages = new List(); + + await foreach (var response in appsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs new file mode 100644 index 0000000..9a151b7 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs @@ -0,0 +1,14 @@ +using Onspring.API.SDK.Models; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + public interface IGetAllAppsPagesRequestBuilder + { + int PageSize { get; } + + IGetAllAppsPagesRequestBuilder WithPageSize(int pageSize); + + IAsyncEnumerable> SendAsync(); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs index 41519c2..f6462f3 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs @@ -5,6 +5,6 @@ namespace Onspring.API.SDK.Interfaces.Fluent { public interface IPagedRequestBuilder { - IGetPagedAppsRequestBuilder OfApps(); + IGetAllAppsPagesRequestBuilder OfApps(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs new file mode 100644 index 0000000..fef5615 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs @@ -0,0 +1,30 @@ +using Onspring.API.SDK.Interfaces.Fluent; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetAllAppsPagesRequestBuilder : IGetAllAppsPagesRequestBuilder + { + private readonly IOnspringClient _client; + public int PageSize { get; private set; } = 50; + + internal GetAllAppsPagesRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetAllAppsPagesRequestBuilder WithPageSize(int pageSize) + { + PageSize = pageSize; + return this; + } + + public async IAsyncEnumerable> SendAsync() + { + await foreach (var response in _client.GetAllAppsAsync(PageSize)) + { + yield return response; + } + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs index 7ab4d65..62169db 100644 --- a/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs @@ -11,9 +11,9 @@ internal PagedRequestBuilder(IOnspringClient client) _client = client; } - public IGetPagedAppsRequestBuilder OfApps() + public IGetAllAppsPagesRequestBuilder OfApps() { - return new GetPagedAppsRequestBuilder(_client, 1); + return new GetAllAppsPagesRequestBuilder(_client); } } } \ No newline at end of file From e6e26c44bea0746653030e4415b9db0bdb221532 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 30 Dec 2024 22:19:17 -0600 Subject: [PATCH 159/168] feat: add sendasync overload that allows supplying page size via action --- .../Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs | 4 ++++ .../Interfaces/Fluent/IOnspringRequestBuilder.cs | 4 ++++ .../Fluent/Apps/GetAllAppsPagesRequestBuilder.cs | 12 ++++++++++++ .../Apps/GetAllAppsPagesRequestBuilderOptions.cs | 13 +++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilderOptions.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs index 9a151b7..022bed7 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs @@ -1,4 +1,6 @@ using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System; using System.Collections.Generic; namespace Onspring.API.SDK.Interfaces.Fluent @@ -10,5 +12,7 @@ public interface IGetAllAppsPagesRequestBuilder IGetAllAppsPagesRequestBuilder WithPageSize(int pageSize); IAsyncEnumerable> SendAsync(); + + IAsyncEnumerable> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs index aa8b800..6b9a69f 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/IOnspringRequestBuilder.cs @@ -89,6 +89,10 @@ public interface IOnspringRequestBuilder /// A builder instance for retrieving apps that implements the interface. IGetAppsRequestBuilder ToGetApps(); + /// + /// Creates a builder for retrieving all pages of an entity that supports pagination. + /// + /// A builder instance for retrieving all pages that implements the interface. IPagedRequestBuilder ToGetAllPages(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs index fef5615..47375d2 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs @@ -1,4 +1,5 @@ using Onspring.API.SDK.Interfaces.Fluent; +using System; using System.Collections.Generic; namespace Onspring.API.SDK.Models.Fluent @@ -26,5 +27,16 @@ public async IAsyncEnumerable> SendAsync() yield return response; } } + + public async IAsyncEnumerable> SendAsync(Action options) + { + var opts = new GetAllAppsPagesRequestBuilderOptions(); + options.Invoke(opts); + + await foreach (var response in _client.GetAllAppsAsync(opts.PageSize)) + { + yield return response; + } + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilderOptions.cs new file mode 100644 index 0000000..196a794 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilderOptions.cs @@ -0,0 +1,13 @@ +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents the options for a request to retrieve all pages of apps. + /// + public class GetAllAppsPagesRequestBuilderOptions + { + /// + /// Gets or sets the page size to retrieve. The default is 50. + /// + public int PageSize { get; set; } = 50; + } +} \ No newline at end of file From 261e07bcc354f32dd32b8b34131dbcb8b5f5a158 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 30 Dec 2024 22:21:14 -0600 Subject: [PATCH 160/168] tests: add test for send async overload --- .../Fluent/OnspringClientAppsTests.cs | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs index d0fc906..437331b 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientAppsTests.cs @@ -65,7 +65,7 @@ public async Task GetApps() } [TestMethod] - public async Task GetAllApps() + public async Task GetAllApps_WhenUsingDefaultPageSize_ItShouldReturnAllPages() { var testAddress = "https://localhost"; @@ -113,5 +113,55 @@ public async Task GetAllApps() Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); } } + + [TestMethod] + public async Task GetAllApps_WhenUsingCustomPageSize_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var numberOfApps = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfApps(numberOfApps, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/apps?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var appsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfApps() + .SendAsync(o => o.PageSize = pageSize); + + var responsePages = new List(); + + await foreach (var response in appsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } } } \ No newline at end of file From 9490a28c79f6a8501ef347e1c2b6f8260b39cb4d Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:56:57 -0600 Subject: [PATCH 161/168] docs: fix xml comments --- .../Apps/IGetAllAppsPagesRequestBuilder.cs | 18 ++++++++++++++++++ .../Fluent/Apps/IGetPagedAppsRequestBuilder.cs | 3 +++ .../Get/IGetRecordsByAppPagedRequestBuilder.cs | 6 +++--- .../Get/IGetRecordsByAppRequestBuilder.cs | 4 ++-- .../Apps/GetAllAppsPagesRequestBuilder.cs | 4 ++++ Onspring.API.SDK/Models/PagedResponse.cs | 2 +- Onspring.API.SDK/Models/RecordFieldValue.cs | 2 +- Onspring.API.SDK/OnspringClient.cs | 6 +++--- 8 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs index 022bed7..20e9fe5 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetAllAppsPagesRequestBuilder.cs @@ -5,14 +5,32 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a request builder for getting all pages of apps. + /// public interface IGetAllAppsPagesRequestBuilder { + /// + /// Gets the page size to retrieve. + /// int PageSize { get; } + /// + /// Sets the page size to retrieve. + /// IGetAllAppsPagesRequestBuilder WithPageSize(int pageSize); + /// + /// Sends the request to retrieve all pages of apps. + /// + /// An async enumerable of where T is . IAsyncEnumerable> SendAsync(); + /// + /// Sends the request to retrieve all pages of apps with the specified options. + /// + /// The options to use for the request. + /// An async enumerable of where T is . IAsyncEnumerable> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs index 1101a5e..af5ee52 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Apps/IGetPagedAppsRequestBuilder.cs @@ -3,6 +3,9 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Represents a request builder for getting paged apps. + /// public interface IGetPagedAppsRequestBuilder { /// diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs index 7d25472..1fcc645 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppPagedRequestBuilder.cs @@ -54,21 +54,21 @@ public interface IGetRecordsByAppPagedRequestBuilder /// Specifies the page size to retrieve. /// /// The size of page to retrieve - /// A builder for further configuration of the request. + /// A for further configuration of the request. IGetRecordsByAppPagedRequestBuilder WithPageSize(int pageSize); /// /// Specifies the IDs of the fields to retrieve. /// /// The IDs of the fields to retrieve. - /// A builder for further configuration of the request. + /// A for further configuration of the request. IGetRecordsByAppPagedRequestBuilder WithFieldIds(IEnumerable fieldIds); /// /// Specifies the data format for the response. /// /// The data format for the response. - /// A builder for further configuration of the request. + /// A for further configuration of the request. IGetRecordsByAppPagedRequestBuilder WithFormat(DataFormat dataFormat); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs index 66a5b0f..2180881 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetRecordsByAppRequestBuilder.cs @@ -25,14 +25,14 @@ public interface IGetRecordsByAppRequestBuilder /// Specifies the record ID to retrieve. /// /// The ID of the record to retrieve. - /// A builder for further configuration of the request. + /// A for further configuration of the request. IGetRecordByIdRequestBuilder WithId(int recordId); /// /// Specifies the IDs of the records to retrieve. /// /// The IDs of the records to retrieve. - /// A builder for further configuration of the request. + /// A for further configuration of the request. IGetRecordsByIdsRequestBuilder WithIds(IEnumerable recordIds); /// diff --git a/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs index 47375d2..cfd1a81 100644 --- a/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Apps/GetAllAppsPagesRequestBuilder.cs @@ -4,6 +4,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a request builder for getting all pages of apps. + /// + /// public class GetAllAppsPagesRequestBuilder : IGetAllAppsPagesRequestBuilder { private readonly IOnspringClient _client; diff --git a/Onspring.API.SDK/Models/PagedResponse.cs b/Onspring.API.SDK/Models/PagedResponse.cs index 0b1b33c..460c715 100644 --- a/Onspring.API.SDK/Models/PagedResponse.cs +++ b/Onspring.API.SDK/Models/PagedResponse.cs @@ -31,7 +31,7 @@ public class PagedResponse public int TotalRecords { get; set; } } - /// + /// public class PagedResponse : PagedResponse { /// diff --git a/Onspring.API.SDK/Models/RecordFieldValue.cs b/Onspring.API.SDK/Models/RecordFieldValue.cs index 011a512..4e74bda 100644 --- a/Onspring.API.SDK/Models/RecordFieldValue.cs +++ b/Onspring.API.SDK/Models/RecordFieldValue.cs @@ -28,7 +28,7 @@ public class RecordFieldValue public int FieldId { get; set; } } - /// + /// public class RecordFieldValue : RecordFieldValue { /// diff --git a/Onspring.API.SDK/OnspringClient.cs b/Onspring.API.SDK/OnspringClient.cs index 9d24dbb..ac61947 100644 --- a/Onspring.API.SDK/OnspringClient.cs +++ b/Onspring.API.SDK/OnspringClient.cs @@ -75,7 +75,7 @@ public OnspringClient(OnspringClientConfiguration clientConfig) // ------------------------------------ Fluent Interface ------------------------------------ - /// + /// public IOnspringRequestBuilder CreateRequest() { return new OnspringRequestBuilder(this); @@ -103,7 +103,7 @@ public async Task CanConnectAsync() #region Apps - /// + /// public async IAsyncEnumerable> GetAllAppsAsync(int pageSize = 50) { await foreach (var response in GetAllPagesAsync(page => GetAppsAsync(new PagingRequest(page, pageSize)))) @@ -154,7 +154,7 @@ public async Task> GetAppsAsync(IEnumerable ap #region Fields - /// + /// public async IAsyncEnumerable> GetAllFieldsForAppAsync(int appId, int pageSize = 50) { await foreach (var response in GetAllPagesAsync(page => GetFieldsForAppAsync(appId, new PagingRequest(page, pageSize)))) From 78c82b2e2b52f484e7d59f1ee0ca5f110fa37865 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:57:27 -0600 Subject: [PATCH 162/168] fix: remove unnecessary usings --- .../Fluent/OnspringClientFieldTests.cs | 110 ++++++++++++++++++ .../Tests/Integration/OnspringClientTests.cs | 1 - .../IDeleteRecordsByAppRequestBuilder.cs | 1 - 3 files changed, 110 insertions(+), 2 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs index f0f6476..acad5ee 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs @@ -1,9 +1,14 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; +using Onspring.API.SDK.Models; using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using RichardSzalay.MockHttp; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Net.Http; +using System.Text.Json; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent @@ -78,5 +83,110 @@ public async Task GetFieldsFromApp_WithOptions() AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task GetAllFields_WhenUsingDefaultPageSize_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var numberOfFields = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfFields(numberOfFields, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When( + HttpMethod.Get, + $"{testAddress}/fields/appId/{_appIdWithFields}?PageNumber={page.PageNumber}&PageSize={pageSize}" + ) + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var fieldsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfFields() + .FromApp(_appIdWithFields) + .SendAsync(); + + var responsePages = new List(); + + await foreach (var response in fieldsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } + + [TestMethod] + public async Task GetAllFields_WhenUsingCustomPageSize_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var numberOfFields = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfFields(numberOfFields, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/fields/appId/{_appIdWithFields}?PageNumber={page.PageNumber}&PageSize={pageSize}") + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var appsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfFields() + .FromApp(_appIdWithFields) + .SendAsync(o => o.PageSize = pageSize); + + var responsePages = new List(); + + await foreach (var response in appsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } } } \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs index a4ac547..97dbcc7 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/OnspringClientTests.cs @@ -1,6 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Onspring.API.SDK.Interfaces.Fluent; -using Onspring.API.SDK.Models.Fluent; using Onspring.API.SDK.Tests.Infrastructure; using System; using System.Diagnostics.CodeAnalysis; diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs index 6734c66..3dc2115 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Delete/IDeleteRecordsByAppRequestBuilder.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; namespace Onspring.API.SDK.Interfaces.Fluent From d766a2a298ad9543838708706f4210871cdb89ee Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:57:54 -0600 Subject: [PATCH 163/168] feat: implement fluent interface for record paging with async enumerable --- .../IGetAllFieldsPagesByAppRequestBuilder.cs | 43 ++++++++ .../IGetAllFieldsPagesRequestBuilder.cs | 15 +++ .../Fluent/Pagination/IPagedRequestBuilder.cs | 5 +- .../IGetAllRecordsPagesByAppRequestBuilder.cs | 82 ++++++++++++++ ...GetAllRecordsPagesByQueryRequestBuilder.cs | 87 +++++++++++++++ .../Get/IGetAllRecordsPagesRequestBuilder.cs | 15 +++ .../GetAllFieldsPagesByAppRequestBuilder.cs | 48 ++++++++ ...llFieldsPagesByAppRequestBuilderOptions.cs | 13 +++ .../Fields/GetAllFieldsPagesRequestBuilder.cs | 23 ++++ .../Fluent/Pagination/PagedRequestBuilder.cs | 12 +- .../GetAllRecordsPagesByAppRequestBuilder.cs | 104 ++++++++++++++++++ ...lRecordsPagesByAppRequestBuilderOptions.cs | 27 +++++ ...GetAllRecordsPagesByQueryRequestBuilder.cs | 104 ++++++++++++++++++ ...ecordsPagesByQueryRequestBuilderOptions.cs | 32 ++++++ .../Get/GetAllRecordsPagesRequestBuilder.cs | 19 ++++ 15 files changed, 625 insertions(+), 4 deletions(-) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Fields/IGetAllFieldsPagesByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Fields/IGetAllFieldsPagesRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByQueryRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilderOptions.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilderOptions.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderOptions.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetAllFieldsPagesByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetAllFieldsPagesByAppRequestBuilder.cs new file mode 100644 index 0000000..4ef0b57 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetAllFieldsPagesByAppRequestBuilder.cs @@ -0,0 +1,43 @@ +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + /// + /// Represents a request builder to retrieve all pages of fields. + /// + public interface IGetAllFieldsPagesByAppRequestBuilder + { + /// + /// Gets the app ID to retrieve fields for. + /// + int AppId { get; } + + /// + /// Gets the page size to retrieve. The default is 50. + /// + int PageSize { get; } + + /// + /// Sets the page size to retrieve. + /// + /// The page size to retrieve. + /// The current instance of the . + IGetAllFieldsPagesByAppRequestBuilder WithPageSize(int pageSize); + + /// + /// Sends the request to retrieve all pages of fields for an app. + /// + /// An async enumerable of where T is . + IAsyncEnumerable> SendAsync(); + + /// + /// Sends the request to retrieve all pages of fields for an app with the specified options. + /// + /// The options to use for the request. + /// An async enumerable of where T is . + IAsyncEnumerable> SendAsync(Action options); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetAllFieldsPagesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetAllFieldsPagesRequestBuilder.cs new file mode 100644 index 0000000..3f4297c --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Fields/IGetAllFieldsPagesRequestBuilder.cs @@ -0,0 +1,15 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + /// + /// Represents a request builder for getting all pages of fields. + /// + public interface IGetAllFieldsPagesRequestBuilder + { + /// + /// Specifies the ID of the app to retrieve fields for. + /// + /// The ID of the app to retrieve fields for. + /// A for further configuration of the request. + IGetAllFieldsPagesByAppRequestBuilder FromApp(int appId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs index f6462f3..c661578 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs @@ -1,10 +1,9 @@ -using Onspring.API.SDK.Models; -using System.Threading.Tasks; - namespace Onspring.API.SDK.Interfaces.Fluent { public interface IPagedRequestBuilder { IGetAllAppsPagesRequestBuilder OfApps(); + IGetAllFieldsPagesRequestBuilder OfFields(); + IGetAllRecordsPagesRequestBuilder OfRecords(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByAppRequestBuilder.cs new file mode 100644 index 0000000..804c944 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByAppRequestBuilder.cs @@ -0,0 +1,82 @@ +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + /// + /// Represents a request builder for getting all pages of records from an app. + /// + public interface IGetAllRecordsPagesByAppRequestBuilder + { + /// + /// Gets the ID of the app to retrieve records from. + /// + int AppId { get; } + + /// + /// Gets the page size to use when retrieving records. The default is 50. + /// + int PageSize { get; } + + /// + /// Gets the data format to use when retrieving records. The default is . + /// + DataFormat DataFormat { get; } + + /// + /// Gets the IDs of the fields to retrieve with the records. + /// + IEnumerable FieldIds { get; } + + /// + /// Specifies the fields to retrieve with the records. + /// + /// The IDs of the fields to retrieve with the records. + /// A for further configuration of the request. + IGetAllRecordsPagesByAppRequestBuilder WithFields(IEnumerable fieldIds); + + /// + /// Specifies the data format to use when retrieving records. + /// + /// The data format to use when retrieving records. + /// A for further configuration of the request. + IGetAllRecordsPagesByAppRequestBuilder WithDataFormat(DataFormat dataFormat); + + /// + /// Specifies the page size to use when retrieving records. + /// + /// The page size to use when retrieving records. Must be greater than zero. + /// A for further configuration of the request. + IGetAllRecordsPagesByAppRequestBuilder WithPageSize(int pageSize); + + /// + /// Specifies the filter to be used to query records. + /// + /// The filter to be used to query records. + /// A for further configuration of the request. + IGetAllRecordsPagesByQueryRequestBuilder WithFilter(string filter); + + /// + /// Specifies the filter to be used to query records. + /// + /// An action that constructs the filter to be used to query records. + /// A for further configuration of the request. + IGetAllRecordsPagesByQueryRequestBuilder WithFilter(Action filter); + + /// + /// Sends the request to get all pages of records from the app. + /// + /// An async enumerable of where T is . + IAsyncEnumerable> SendAsync(); + + /// + /// Sends the request to get all pages of records from the app. + /// + /// An action that configures the request options. + /// An async enumerable of where T is . + IAsyncEnumerable> SendAsync(Action options); + } +} diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByQueryRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByQueryRequestBuilder.cs new file mode 100644 index 0000000..6a36c85 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByQueryRequestBuilder.cs @@ -0,0 +1,87 @@ +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + /// + /// Represents a builder for constructing requests to get all pages of records from an app by query. + /// + public interface IGetAllRecordsPagesByQueryRequestBuilder + { + /// + /// Gets the ID of the app from which to retrieve records. + /// + int AppId { get; } + + /// + /// Gets the page size to use when retrieving records. The default is 50. + /// + int PageSize { get; } + + /// + /// Gets the IDs of the fields to retrieve with the records. + /// + IEnumerable FieldIds { get; } + + /// + /// Gets the data format to use when retrieving records. The default is . + /// + DataFormat DataFormat { get; } + + /// + /// Gets the filter to be used to query records. + /// + string Filter { get; } + + /// + /// Specifies the fields to retrieve with the records. + /// + /// The IDs of the fields to retrieve with the records. + /// A for further configuration of the request. + IGetAllRecordsPagesByQueryRequestBuilder WithFields(IEnumerable fieldIds); + + /// + /// Specifies the data format to use when retrieving records. + /// + /// The data format to use when retrieving records. + /// A for further configuration of the request. + IGetAllRecordsPagesByQueryRequestBuilder WithDataFormat(DataFormat dataFormat); + + /// + /// Specifies the page size to use when retrieving records. + /// + /// The page size to use when retrieving records. Must be greater than zero. + /// A for further configuration of the request. + IGetAllRecordsPagesByQueryRequestBuilder WithPageSize(int pageSize); + + /// + /// Specifies the filter to be used to query records. + /// + /// The filter to be used to query records. + /// A for further configuration of the request. + IGetAllRecordsPagesByQueryRequestBuilder WithFilter(string filter); + + /// + /// Specifies the filter to be used to query records. + /// + /// An action that constructs the filter to be used to query records. + /// A for further configuration of the request. + IGetAllRecordsPagesByQueryRequestBuilder WithFilter(Action filter); + + /// + /// Sends the request to get all pages of records from the app. + /// + /// An async enumerable of where T is . + IAsyncEnumerable> SendAsync(); + + /// + /// Sends the request to get all pages of records from the app. + /// + /// The options to use when sending the request. + /// An async enumerable of where T is . + IAsyncEnumerable> SendAsync(Action options); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesRequestBuilder.cs new file mode 100644 index 0000000..af6fbc1 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesRequestBuilder.cs @@ -0,0 +1,15 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + /// + /// Represents a request builder for getting all pages of records. + /// + public interface IGetAllRecordsPagesRequestBuilder + { + /// + /// Specifies the app to retrieve records from. + /// + /// The ID of the app to retrieve records from. + /// A for further configuration of the request. + IGetAllRecordsPagesByAppRequestBuilder FromApp(int appId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilder.cs new file mode 100644 index 0000000..674b0e6 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilder.cs @@ -0,0 +1,48 @@ +using Onspring.API.SDK.Interfaces.Fluent; +using System; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents a request builder for getting all pages of fields. + /// + /// + public class GetAllFieldsPagesByAppRequestBuilder : IGetAllFieldsPagesByAppRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; private set; } + public int PageSize { get; private set; } = 50; + + internal GetAllFieldsPagesByAppRequestBuilder(IOnspringClient client, int appId) + { + _client = client; + AppId = appId; + } + + public IGetAllFieldsPagesByAppRequestBuilder WithPageSize(int pageSize) + { + PageSize = pageSize; + return this; + } + + public async IAsyncEnumerable> SendAsync() + { + await foreach (var response in _client.GetAllFieldsForAppAsync(AppId, PageSize)) + { + yield return response; + } + } + + public async IAsyncEnumerable> SendAsync(Action options) + { + var opts = new GetAllFieldsPagesByAppRequestBuilderOptions(); + options.Invoke(opts); + + await foreach (var response in _client.GetAllFieldsForAppAsync(AppId, opts.PageSize)) + { + yield return response; + } + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilderOptions.cs new file mode 100644 index 0000000..4e27ac0 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilderOptions.cs @@ -0,0 +1,13 @@ +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents the options for a request to retrieve all pages of fields for an app. + /// + public class GetAllFieldsPagesByAppRequestBuilderOptions + { + /// + /// Gets or sets the page size to retrieve. The default is 50. + /// + public int PageSize { get; set; } = 50; + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesRequestBuilder.cs new file mode 100644 index 0000000..3f18284 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Fields/GetAllFieldsPagesRequestBuilder.cs @@ -0,0 +1,23 @@ +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents a request builder for getting all pages of fields. + /// + /// + public class GetAllFieldsPagesRequestBuilder : IGetAllFieldsPagesRequestBuilder + { + private readonly IOnspringClient _client; + + internal GetAllFieldsPagesRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetAllFieldsPagesByAppRequestBuilder FromApp(int appId) + { + return new GetAllFieldsPagesByAppRequestBuilder(_client, appId); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs index 62169db..02f4731 100644 --- a/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs @@ -15,5 +15,15 @@ public IGetAllAppsPagesRequestBuilder OfApps() { return new GetAllAppsPagesRequestBuilder(_client); } + + public IGetAllFieldsPagesRequestBuilder OfFields() + { + return new GetAllFieldsPagesRequestBuilder(_client); + } + + public IGetAllRecordsPagesRequestBuilder OfRecords() + { + return new GetAllRecordsPagesRequestBuilder(_client); + } } -} \ No newline at end of file +} diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs new file mode 100644 index 0000000..79eeaf0 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs @@ -0,0 +1,104 @@ +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents a request builder for getting all pages of records from an app. + /// + /// + public class GetAllRecordsPagesByAppRequestBuilder : IGetAllRecordsPagesByAppRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; } + public int PageSize { get; private set; } = 50; + public DataFormat DataFormat { get; private set; } = DataFormat.Raw; + public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); + + internal GetAllRecordsPagesByAppRequestBuilder(IOnspringClient client, int appId) + { + _client = client; + AppId = appId; + } + + public IGetAllRecordsPagesByAppRequestBuilder WithDataFormat(DataFormat dataFormat) + { + DataFormat = dataFormat; + return this; + } + + public IGetAllRecordsPagesByAppRequestBuilder WithFields(IEnumerable fieldIds) + { + FieldIds = fieldIds; + return this; + } + + public IGetAllRecordsPagesByAppRequestBuilder WithPageSize(int pageSize) + { + PageSize = pageSize; + return this; + } + + public IGetAllRecordsPagesByQueryRequestBuilder WithFilter(string filter) + { + return new GetAllRecordsPagesByQueryRequestBuilder( + _client, + AppId, + PageSize, + FieldIds, + DataFormat, + filter + ); + } + + public IGetAllRecordsPagesByQueryRequestBuilder WithFilter(Action filter) + { + return new GetAllRecordsPagesByQueryRequestBuilder( + _client, + AppId, + PageSize, + FieldIds, + DataFormat, + filter.ToString() + ); + } + + public async IAsyncEnumerable> SendAsync() + { + var request = new GetRecordsByAppRequest + { + AppId = AppId, + PagingRequest = new PagingRequest { PageSize = PageSize }, + DataFormat = DataFormat, + FieldIds = FieldIds.ToList(), + }; + + await foreach (var response in _client.GetAllRecordsForAppAsync(request)) + { + yield return response; + } + } + + public async IAsyncEnumerable> SendAsync(Action options) + { + var opts = new GetAllRecordsPagesByAppRequestBuilderOptions(); + options.Invoke(opts); + + var request = new GetRecordsByAppRequest + { + AppId = AppId, + PagingRequest = new PagingRequest { PageSize = opts.PageSize }, + DataFormat = opts.DataFormat, + FieldIds = opts.FieldIds.ToList(), + }; + + await foreach (var response in _client.GetAllRecordsForAppAsync(request)) + { + yield return response; + } + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilderOptions.cs new file mode 100644 index 0000000..a65d4bb --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilderOptions.cs @@ -0,0 +1,27 @@ +using Onspring.API.SDK.Enums; +using System.Collections.Generic; +using System.Linq; + +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents the options for a request to retrieve all pages of records for an app. + /// + public class GetAllRecordsPagesByAppRequestBuilderOptions + { + /// + /// Gets or sets the IDs of the fields to retrieve. + /// + public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + + /// + /// Gets or sets the data format to retrieve. The default is . + /// + public DataFormat DataFormat { get; set; } = DataFormat.Raw; + + /// + /// Gets or sets the page size to retrieve. The default is 50. + /// + public int PageSize { get; set; } = 50; + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs new file mode 100644 index 0000000..84659c7 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs @@ -0,0 +1,104 @@ +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents a builder for constructing requests to get all pages of records from an app by query. + /// + /// + public class GetAllRecordsPagesByQueryRequestBuilder : IGetAllRecordsPagesByQueryRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; } + public int PageSize { get; private set; } = 50; + public DataFormat DataFormat { get; private set; } = DataFormat.Raw; + public IEnumerable FieldIds { get; private set; } = Enumerable.Empty(); + public string Filter { get; private set; } + + internal GetAllRecordsPagesByQueryRequestBuilder( + IOnspringClient client, + int appId, + int pageSize, + IEnumerable fieldIds, + DataFormat dataFormat, + string filter + ) + { + _client = client; + AppId = appId; + PageSize = pageSize; + FieldIds = fieldIds; + DataFormat = dataFormat; + Filter = filter; + } + + public IGetAllRecordsPagesByQueryRequestBuilder WithDataFormat(DataFormat dataFormat) + { + DataFormat = dataFormat; + return this; + } + + public IGetAllRecordsPagesByQueryRequestBuilder WithFields(IEnumerable fieldIds) + { + FieldIds = fieldIds; + return this; + } + + public IGetAllRecordsPagesByQueryRequestBuilder WithPageSize(int pageSize) + { + PageSize = pageSize; + return this; + } + + public IGetAllRecordsPagesByQueryRequestBuilder WithFilter(string filter) + { + Filter = filter; + return this; + } + + public IGetAllRecordsPagesByQueryRequestBuilder WithFilter(Action filter) + { + Filter = filter.ToString(); + return this; + } + + public async IAsyncEnumerable> SendAsync() + { + var request = new QueryRecordsRequest + { + AppId = AppId, + DataFormat = DataFormat, + FieldIds = FieldIds.ToList(), + Filter = Filter + }; + + await foreach (var response in _client.GetAllRecordsByQueryAsync(request, PageSize)) + { + yield return response; + } + } + + public async IAsyncEnumerable> SendAsync(Action options) + { + var opts = new GetAllRecordsPagesByQueryRequestBuilderOptions(); + options.Invoke(opts); + + var request = new QueryRecordsRequest + { + AppId = AppId, + DataFormat = DataFormat, + FieldIds = FieldIds.ToList(), + Filter = Filter + }; + + await foreach (var response in _client.GetAllRecordsByQueryAsync(request, opts.PageSize)) + { + yield return response; + } + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderOptions.cs new file mode 100644 index 0000000..4c68fa3 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderOptions.cs @@ -0,0 +1,32 @@ +using Onspring.API.SDK.Enums; +using System.Collections.Generic; +using System.Linq; + +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents the options for a request to retrieve all pages of records by query. + /// + public class GetAllRecordsPagesByQueryRequestBuilderOptions + { + /// + /// Gets or sets the IDs of the fields to retrieve. + /// + public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); + + /// + /// Gets or sets the data format to retrieve. The default is . + /// + public DataFormat DataFormat { get; set; } = DataFormat.Raw; + + /// + /// Gets or sets the page size to retrieve. The default is 50. + /// + public int PageSize { get; set; } = 50; + + /// + /// Gets or sets the filter to apply to the records. + /// + public string Filter { get; set; } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesRequestBuilder.cs new file mode 100644 index 0000000..269bbe3 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesRequestBuilder.cs @@ -0,0 +1,19 @@ +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + public class GetAllRecordsPagesRequestBuilder : IGetAllRecordsPagesRequestBuilder + { + private readonly IOnspringClient _client; + + internal GetAllRecordsPagesRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetAllRecordsPagesByAppRequestBuilder FromApp(int appId) + { + return new GetAllRecordsPagesByAppRequestBuilder(_client, appId); + } + } +} From bf6dd5b8214f48e49834528df63595556bb46431 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 31 Dec 2024 12:45:30 -0600 Subject: [PATCH 164/168] tests: add integration tests for fluent get all record pages by query --- .../Fluent/OnspringClientFieldTests.cs | 5 +- .../Fluent/OnspringClientRecordsTests.cs | 272 ++++++++++++++++++ ...GetAllRecordsPagesByQueryRequestBuilder.cs | 2 +- ...GetAllRecordsPagesByQueryRequestBuilder.cs | 8 +- ...ecordsPagesByQueryRequestBuilderOptions.cs | 32 --- 5 files changed, 281 insertions(+), 38 deletions(-) delete mode 100644 Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderOptions.cs diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs index acad5ee..78a884f 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientFieldTests.cs @@ -152,7 +152,10 @@ public async Task GetAllFields_WhenUsingCustomPageSize_ItShouldReturnAllPages() foreach (var page in pages) { mockHttp - .When(HttpMethod.Get, $"{testAddress}/fields/appId/{_appIdWithFields}?PageNumber={page.PageNumber}&PageSize={pageSize}") + .When( + HttpMethod.Get, + $"{testAddress}/fields/appId/{_appIdWithFields}?PageNumber={page.PageNumber}&PageSize={pageSize}" + ) .Respond( "application/json", JsonSerializer.Serialize(page) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs index f0b0247..b99c29d 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientRecordsTests.cs @@ -4,7 +4,12 @@ using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using RichardSzalay.MockHttp; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net.Http; +using System.Text.Json; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent @@ -232,5 +237,272 @@ public async Task UpdateRecord() AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task GetAllRecords_WhenUsingDefaultOptions_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var numberOfRecords = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfRecords(numberOfRecords, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When( + HttpMethod.Get, + $"{testAddress}/records/appId/{_appIdWithRecords}" + ) + .WithQueryString(new Dictionary + { + { "PageNumber", page.PageNumber.ToString() }, + { "PageSize", pageSize.ToString() }, + { "dataFormat", DataFormat.Raw.ToString() } + }) + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var recordsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfRecords() + .FromApp(_appIdWithRecords) + .SendAsync(); + + var responsePages = new List(); + + await foreach (var response in recordsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].RecordId, responsePage.Items[0].RecordId); + } + } + + [TestMethod] + public async Task GetAllRecords_WhenUsingCustomOptions_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var numberOfRecords = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfRecords(numberOfRecords, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When( + HttpMethod.Get, + $"{testAddress}/records/appId/{_appIdWithRecords}" + ) + .WithQueryString(new Dictionary + { + { "PageNumber", page.PageNumber.ToString() }, + { "PageSize", pageSize.ToString() }, + { "dataFormat", DataFormat.Formatted.ToString() }, + { "fieldIds", "1,2,3" } + }) + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var recordsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfRecords() + .FromApp(_appIdWithRecords) + .SendAsync(o => + { + o.FieldIds = [1, 2, 3]; + o.DataFormat = DataFormat.Formatted; + o.PageSize = pageSize; + }); + + var responsePages = new List(); + + await foreach (var response in recordsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].RecordId, responsePage.Items[0].RecordId); + } + } + + [TestMethod] + public async Task GetAllRecordsByQuery_WhenUsingDefaultOptions_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var testFilter = "testFilter"; + var numberOfRecords = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfRecords(numberOfRecords, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When( + HttpMethod.Post, + $"{testAddress}/records/query" + ) + .WithQueryString(new Dictionary + { + { "PageNumber", page.PageNumber.ToString() }, + { "PageSize", pageSize.ToString() } + }) + .WithJsonContent(req => + { + return req.AppId == _appIdWithRecords + && req.Filter == testFilter + && req.FieldIds.SequenceEqual([]) + && req.DataFormat == DataFormat.Raw; + }) + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var recordsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfRecords() + .FromApp(_appIdWithRecords) + .WithFilter(testFilter) + .SendAsync(); + + var responsePages = new List(); + + await foreach (var response in recordsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].RecordId, responsePage.Items[0].RecordId); + } + } + + [TestMethod] + public async Task GetAllRecordsByQuery_WhenUsingCustomOptions_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var testFilter = "testFilter"; + var numberOfRecords = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfRecords(numberOfRecords, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When( + HttpMethod.Post, + $"{testAddress}/records/query" + ) + .WithQueryString(new Dictionary + { + { "PageNumber", page.PageNumber.ToString() }, + { "PageSize", pageSize.ToString() } + }) + .WithJsonContent(req => + { + return req.AppId == _appIdWithRecords + && req.Filter == testFilter + && req.FieldIds.SequenceEqual([1, 2, 3]) + && req.DataFormat == DataFormat.Formatted; + }) + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var recordsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfRecords() + .FromApp(_appIdWithRecords) + .WithFilter(testFilter) + .SendAsync(o => + { + o.FieldIds = [1, 2, 3]; + o.DataFormat = DataFormat.Formatted; + o.PageSize = pageSize; + }); + + var responsePages = new List(); + + await foreach (var response in recordsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].RecordId, responsePage.Items[0].RecordId); + } + } } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByQueryRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByQueryRequestBuilder.cs index 6a36c85..015c805 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByQueryRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Records/Get/IGetAllRecordsPagesByQueryRequestBuilder.cs @@ -82,6 +82,6 @@ public interface IGetAllRecordsPagesByQueryRequestBuilder /// /// The options to use when sending the request. /// An async enumerable of where T is . - IAsyncEnumerable> SendAsync(Action options); + IAsyncEnumerable> SendAsync(Action options); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs index 84659c7..a050d13 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs @@ -82,16 +82,16 @@ public async IAsyncEnumerable> SendAsync() } } - public async IAsyncEnumerable> SendAsync(Action options) + public async IAsyncEnumerable> SendAsync(Action options) { - var opts = new GetAllRecordsPagesByQueryRequestBuilderOptions(); + var opts = new GetAllRecordsPagesByAppRequestBuilderOptions(); options.Invoke(opts); var request = new QueryRecordsRequest { AppId = AppId, - DataFormat = DataFormat, - FieldIds = FieldIds.ToList(), + DataFormat = opts.DataFormat, + FieldIds = opts.FieldIds.ToList(), Filter = Filter }; diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderOptions.cs deleted file mode 100644 index 4c68fa3..0000000 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderOptions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Onspring.API.SDK.Enums; -using System.Collections.Generic; -using System.Linq; - -namespace Onspring.API.SDK.Models.Fluent -{ - /// - /// Represents the options for a request to retrieve all pages of records by query. - /// - public class GetAllRecordsPagesByQueryRequestBuilderOptions - { - /// - /// Gets or sets the IDs of the fields to retrieve. - /// - public IEnumerable FieldIds { get; set; } = Enumerable.Empty(); - - /// - /// Gets or sets the data format to retrieve. The default is . - /// - public DataFormat DataFormat { get; set; } = DataFormat.Raw; - - /// - /// Gets or sets the page size to retrieve. The default is 50. - /// - public int PageSize { get; set; } = 50; - - /// - /// Gets or sets the filter to apply to the records. - /// - public string Filter { get; set; } - } -} \ No newline at end of file From 864a7d8a3cb87372da6afd3dbfccecb5d7ccbf69 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:12:00 -0600 Subject: [PATCH 165/168] feat: add fluent interface for retrieving all report pages via async enumerable --- .../Fluent/Pagination/IPagedRequestBuilder.cs | 23 +++++++++ .../IGetAllReportsPagesByAppRequestBuilder.cs | 43 +++++++++++++++++ .../IGetAllReportsPagesRequestBuilder.cs | 15 ++++++ .../Fluent/Pagination/PagedRequestBuilder.cs | 9 ++++ .../GetAllRecordsPagesByAppRequestBuilder.cs | 2 +- .../GetAllReportsPagesByAppRequestBuilder.cs | 48 +++++++++++++++++++ ...lReportsPagesByAppRequestBuilderOptions.cs | 13 +++++ .../GetAllReportsPagesRequestBuilder.cs | 23 +++++++++ 8 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Reports/IGetAllReportsPagesByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Interfaces/Fluent/Reports/IGetAllReportsPagesRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesByAppRequestBuilder.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesByAppRequestBuilderOptions.cs create mode 100644 Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesRequestBuilder.cs diff --git a/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs index c661578..7ded694 100644 --- a/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs +++ b/Onspring.API.SDK/Interfaces/Fluent/Pagination/IPagedRequestBuilder.cs @@ -1,9 +1,32 @@ namespace Onspring.API.SDK.Interfaces.Fluent { + /// + /// Interface for building paged requests. + /// public interface IPagedRequestBuilder { + /// + /// Creates a builder to get all pages of apps. + /// + /// A for further configuration of the request. IGetAllAppsPagesRequestBuilder OfApps(); + + /// + /// Creates a builder to get all pages of fields for a specific app. + /// + /// A for further configuration of the request. IGetAllFieldsPagesRequestBuilder OfFields(); + + /// + /// Creates a builder to get all pages of records for a specific app. + /// + /// A for further configuration of the request. IGetAllRecordsPagesRequestBuilder OfRecords(); + + /// + /// Creates a builder to get all pages of reports for a specific app. + /// + /// A for further configuration of the request. + IGetAllReportsPagesRequestBuilder OfReports(); } } \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetAllReportsPagesByAppRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetAllReportsPagesByAppRequestBuilder.cs new file mode 100644 index 0000000..9c75a33 --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetAllReportsPagesByAppRequestBuilder.cs @@ -0,0 +1,43 @@ +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Interfaces.Fluent +{ + /// + /// Interface for building requests to get all pages of reports for a specific app. + /// + public interface IGetAllReportsPagesByAppRequestBuilder + { + /// + /// Gets the app ID for the request. + /// + int AppId { get; } + + /// + /// Gets the page size for the request. Default is 50. + /// + int PageSize { get; } + + /// + /// Sets the page size for the request. + /// + /// The page size. + /// A for further configuration of the request. + IGetAllReportsPagesByAppRequestBuilder WithPageSize(int pageSize); + + /// + /// Sends the request to retrieve all pages of reports for the app. + /// + /// An async enumerable of where T is . + IAsyncEnumerable> SendAsync(); + + /// + /// Sends the request to retrieve all pages of reports for the app with the specified options. + /// + /// The options to use for the request. + /// An async enumerable of where T is . + IAsyncEnumerable> SendAsync(Action options); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetAllReportsPagesRequestBuilder.cs b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetAllReportsPagesRequestBuilder.cs new file mode 100644 index 0000000..e475baa --- /dev/null +++ b/Onspring.API.SDK/Interfaces/Fluent/Reports/IGetAllReportsPagesRequestBuilder.cs @@ -0,0 +1,15 @@ +namespace Onspring.API.SDK.Interfaces.Fluent +{ + /// + /// Interface for building requests to get all pages of reports. + /// + public interface IGetAllReportsPagesRequestBuilder + { + /// + /// Sets the app ID for the request. + /// + /// The app ID. + /// A for further configuration of the request. + IGetAllReportsPagesByAppRequestBuilder FromApp(int appId); + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs index 02f4731..d0832a3 100644 --- a/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Pagination/PagedRequestBuilder.cs @@ -2,6 +2,10 @@ namespace Onspring.API.SDK.Models.Fluent { + /// + /// Represents a builder for paged requests. + /// + /// public class PagedRequestBuilder : IPagedRequestBuilder { private readonly IOnspringClient _client; @@ -25,5 +29,10 @@ public IGetAllRecordsPagesRequestBuilder OfRecords() { return new GetAllRecordsPagesRequestBuilder(_client); } + + public IGetAllReportsPagesRequestBuilder OfReports() + { + return new GetAllReportsPagesRequestBuilder(_client); + } } } diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs index 79eeaf0..b016b2a 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs @@ -9,7 +9,7 @@ namespace Onspring.API.SDK.Models.Fluent /// /// Represents a request builder for getting all pages of records from an app. /// - /// + /// public class GetAllRecordsPagesByAppRequestBuilder : IGetAllRecordsPagesByAppRequestBuilder { private readonly IOnspringClient _client; diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesByAppRequestBuilder.cs new file mode 100644 index 0000000..7ee9c26 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesByAppRequestBuilder.cs @@ -0,0 +1,48 @@ +using Onspring.API.SDK.Interfaces.Fluent; +using System; +using System.Collections.Generic; + +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents a builder for requests to get all pages of reports. + /// + /// + public class GetAllReportsPagesByAppRequestBuilder : IGetAllReportsPagesByAppRequestBuilder + { + private readonly IOnspringClient _client; + public int AppId { get; } + public int PageSize { get; private set; } = 50; + + internal GetAllReportsPagesByAppRequestBuilder(IOnspringClient client, int appId) + { + _client = client; + AppId = appId; + } + + public IGetAllReportsPagesByAppRequestBuilder WithPageSize(int pageSize) + { + PageSize = pageSize; + return this; + } + + public async IAsyncEnumerable> SendAsync() + { + await foreach (var response in _client.GetAllReportsForAppAsync(AppId, PageSize)) + { + yield return response; + } + } + + public async IAsyncEnumerable> SendAsync(Action options) + { + var opts = new GetAllReportsPagesByAppRequestBuilderOptions(); + options.Invoke(opts); + + await foreach (var response in _client.GetAllReportsForAppAsync(AppId, opts.PageSize)) + { + yield return response; + } + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesByAppRequestBuilderOptions.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesByAppRequestBuilderOptions.cs new file mode 100644 index 0000000..2ebdffe --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesByAppRequestBuilderOptions.cs @@ -0,0 +1,13 @@ +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents options for building requests to get all pages of reports for a specific app. + /// + public class GetAllReportsPagesByAppRequestBuilderOptions + { + /// + /// Gets or sets the page size for the request. Default is 50. + /// + public int PageSize { get; set; } = 50; + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesRequestBuilder.cs new file mode 100644 index 0000000..24f8e99 --- /dev/null +++ b/Onspring.API.SDK/Models/Fluent/Reports/GetAllReportsPagesRequestBuilder.cs @@ -0,0 +1,23 @@ +using Onspring.API.SDK.Interfaces.Fluent; + +namespace Onspring.API.SDK.Models.Fluent +{ + /// + /// Represents a builder for requests to get all pages of reports. + /// + /// + public class GetAllReportsPagesRequestBuilder : IGetAllReportsPagesRequestBuilder + { + private readonly IOnspringClient _client; + + internal GetAllReportsPagesRequestBuilder(IOnspringClient client) + { + _client = client; + } + + public IGetAllReportsPagesByAppRequestBuilder FromApp(int appId) + { + return new GetAllReportsPagesByAppRequestBuilder(_client, appId); + } + } +} \ No newline at end of file From 2d72d73d51f6579b75376fd42abac3cbcb3b2e2f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:21:35 -0600 Subject: [PATCH 166/168] tests: add integration tests for retrieving all report pages --- .../Fluent/OnspringClientReportsTests.cs | 123 +++++++++++++++++- 1 file changed, 120 insertions(+), 3 deletions(-) diff --git a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs index bcaf743..9250394 100644 --- a/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs +++ b/Onspring.API.SDK.Tests/Tests/Integration/Fluent/OnspringClientReportsTests.cs @@ -4,7 +4,12 @@ using Onspring.API.SDK.Tests.Infrastructure; using Onspring.API.SDK.Tests.Infrastructure.Helpers; using Onspring.API.SDK.Tests.Infrastructure.Http; +using RichardSzalay.MockHttp; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net.Http; +using System.Text.Json; using System.Threading.Tasks; namespace Onspring.API.SDK.Tests.Tests.Integration.Fluent @@ -36,7 +41,7 @@ public async Task GetReportsForAppAsync() .ForPage(pagingRequest.PageNumber) .WithPageSize(pagingRequest.PageSize) .SendAsync(); - + AssertHelper.AssertSuccess(getResponse); AssertHelper.AssertPaging(pagingRequest, getResponse.Value); } @@ -45,7 +50,7 @@ public async Task GetReportsForAppAsync() public async Task GetReportsForAppAsync_WithOptions() { var pagingRequest = new PagingRequest(1, 10); - + var getResponse = await _apiClient.CreateRequest() .ToGetReports() .FromApp(_appIdWithReports) @@ -54,7 +59,7 @@ public async Task GetReportsForAppAsync_WithOptions() options.PageNumber = pagingRequest.PageNumber; options.PageSize = pagingRequest.PageSize; }); - + AssertHelper.AssertSuccess(getResponse); AssertHelper.AssertPaging(pagingRequest, getResponse.Value); } @@ -88,5 +93,117 @@ public async Task GetReportData_WithOptions() AssertHelper.AssertSuccess(apiResponse); } + + [TestMethod] + public async Task GetAllReports_WhenUsingDefaultPageSize_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var numberOfReports = 3; + var pageSize = 50; + var pages = TestDataFactory.GetPagesOfReports(numberOfReports, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/reports/appId/{_appIdWithReports}") + .WithQueryString(new Dictionary + { + { "PageNumber", page.PageNumber.ToString() }, + { "PageSize", pageSize.ToString() } + }) + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var reportsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfReports() + .FromApp(_appIdWithReports) + .SendAsync(); + + var responsePages = new List(); + + await foreach (var response in reportsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } + + [TestMethod] + public async Task GetAllReports_WhenUsingCustomPageSize_ItShouldReturnAllPages() + { + var testAddress = "https://localhost"; + + var numberOfReports = 3; + var pageSize = 1; + var pages = TestDataFactory.GetPagesOfReports(numberOfReports, pageSize); + + var mockHttp = new MockHttpMessageHandler(); + + foreach (var page in pages) + { + mockHttp + .When(HttpMethod.Get, $"{testAddress}/reports/appId/{_appIdWithReports}") + .WithQueryString(new Dictionary + { + { "PageNumber", page.PageNumber.ToString() }, + { "PageSize", pageSize.ToString() } + }) + .Respond( + "application/json", + JsonSerializer.Serialize(page) + ); + } + + var mockHttpClient = mockHttp.ToHttpClient(); + mockHttpClient.BaseAddress = new(testAddress); + + var apiClient = new OnspringClient("test", mockHttpClient); + + var reportsResponses = apiClient + .CreateRequest() + .ToGetAllPages() + .OfReports() + .FromApp(_appIdWithReports) + .SendAsync(o => o.PageSize = pageSize); + + var responsePages = new List(); + + await foreach (var response in reportsResponses) + { + AssertHelper.AssertSuccess(response); + responsePages.Add(response.Value); + } + + foreach (var page in pages) + { + var responsePage = responsePages.Single(x => x.PageNumber == page.PageNumber); + + Assert.AreEqual(page.PageNumber, responsePage.PageNumber); + Assert.AreEqual(page.Items.Count, responsePage.Items.Count); + Assert.AreEqual(page.Items[0].Id, responsePage.Items[0].Id); + } + } } } \ No newline at end of file From 3fe7df32a3ab9377dbc4210437e9276876f9a9ca Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:23:20 -0600 Subject: [PATCH 167/168] docs: add note about done for you pagination in the fluent interface --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3e50fd7..99a209f 100644 --- a/README.md +++ b/README.md @@ -418,3 +418,6 @@ await foreach (var response in appsResponses) } } ``` + +> [!NOTE] +> This same pagination API is exposed for the `IOnspringRequestBuilder` interface through the `ToGetAllPages` method. From 5099c89948a3a5b1eb4378d4a7a9ed5c4c562b30 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:16:52 -0600 Subject: [PATCH 168/168] tests: add unit tests for fluent interface that cover the new async enumerable builders --- .../GetAllAppsPagesRequestBuilderTests.cs | 60 ++++++ ...tAllFieldsPagesByAppRequestBuilderTests.cs | 62 ++++++ .../GetAllFieldsPagesRequestBuilderTests.cs | 37 ++++ ...AllRecordsPagesByAppRequestBuilderTests.cs | 127 ++++++++++++ ...lRecordsPagesByQueryRequestBuilderTests.cs | 183 ++++++++++++++++++ .../GetAllRecordsPagesRequestBuilderTests.cs | 40 ++++ ...AllReportsPagesByAppRequestBuilderTests.cs | 62 ++++++ .../GetAllReportsPagesRequestBuilderTests.cs | 42 ++++ .../GetAllRecordsPagesByAppRequestBuilder.cs | 5 +- ...GetAllRecordsPagesByQueryRequestBuilder.cs | 4 +- 10 files changed, 620 insertions(+), 2 deletions(-) create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAllAppsPagesRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetAllFieldsPagesRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetAllReportsPagesByAppRequestBuilderTests.cs create mode 100644 Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetAllReportsPagesRequestBuilderTests.cs diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAllAppsPagesRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAllAppsPagesRequestBuilderTests.cs new file mode 100644 index 0000000..bac1c7a --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Apps/GetAllAppsPagesRequestBuilderTests.cs @@ -0,0 +1,60 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAllAppsPagesRequestBuilderTests + { + private static IOnspringClient _client; + private static GetAllAppsPagesRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAllAppsPagesRequestBuilder(_client); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstance() + { + var builder = new GetAllAppsPagesRequestBuilder(_client); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldSetPageSize() + { + var pageSize = 100; + + var builder = new GetAllAppsPagesRequestBuilder(_client).WithPageSize(pageSize); + + Assert.AreEqual(pageSize, builder.PageSize); + } + + [TestMethod] + public void SendAsync_WhenCalled_ItShouldReturnAnAsyncEnumerableApiResponse() + { + var result = _builder.SendAsync(); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType>>(result); + } + + [TestMethod] + public void SendAsyncWithOptions_WhenCalled_ItShouldReturnAnAsyncEnumerableApiResponse() + { + var result = _builder.SendAsync(options => options.PageSize = 100); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType>>(result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilderTests.cs new file mode 100644 index 0000000..aeec49e --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetAllFieldsPagesByAppRequestBuilderTests.cs @@ -0,0 +1,62 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAllFieldsPagesByAppRequestBuilderTests + { + private static readonly int _appId = 1; + private static IOnspringClient _client; + private static GetAllFieldsPagesByAppRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAllFieldsPagesByAppRequestBuilder(_client, _appId); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet() + { + var builder = new GetAllFieldsPagesByAppRequestBuilder(_client, _appId); + + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appId, builder.AppId); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldReturnInstanceWithPageSizeSet() + { + var pageSize = 100; + + var result = _builder.WithPageSize(pageSize); + + Assert.IsInstanceOfType(result); + Assert.AreEqual(pageSize, result.PageSize); + } + + [TestMethod] + public void SendAsync_WhenCalled_ItShouldReturnAsyncEnumerable() + { + var result = _builder.SendAsync(); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType>>(result); + } + + [TestMethod] + public void SendAsyncWithOptions_WhenCalled_ItShouldReturnAsyncEnumerable() + { + var result = _builder.SendAsync(options => options.PageSize = 100); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType>>(result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetAllFieldsPagesRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetAllFieldsPagesRequestBuilderTests.cs new file mode 100644 index 0000000..d4d0e90 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Fields/GetAllFieldsPagesRequestBuilderTests.cs @@ -0,0 +1,37 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAllFieldsPagesRequestBuilderTests + { + private static IOnspringClient _client; + private static GetAllFieldsPagesRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAllFieldsPagesRequestBuilder(_client); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnInstance() + { + var builder = new GetAllFieldsPagesRequestBuilder(_client); + + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void FromApp_WhenCalled_ItShouldReturnInstance() + { + var result = _builder.FromApp(1); + + Assert.IsInstanceOfType(result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilderTests.cs new file mode 100644 index 0000000..f44404d --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilderTests.cs @@ -0,0 +1,127 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAllRecordsPagesByAppRequestBuilderTests + { + private static readonly int _appId = 1; + private static IOnspringClient _client; + private static GetAllRecordsPagesByAppRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAllRecordsPagesByAppRequestBuilder(_client, _appId); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstance() + { + var builder = new GetAllRecordsPagesByAppRequestBuilder(_client, _appId); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appId, builder.AppId); + Assert.AreEqual(50, builder.PageSize); + Assert.AreEqual(DataFormat.Raw, builder.DataFormat); + Assert.AreEqual(0, builder.FieldIds.Count()); + } + + [TestMethod] + public void WithDataFormat_WhenCalled_ItShouldReturnAnInstance() + { + var dataFormat = DataFormat.Raw; + var builder = new GetAllRecordsPagesByAppRequestBuilder(_client, _appId) + .WithDataFormat(dataFormat); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(dataFormat, builder.DataFormat); + } + + [TestMethod] + public void WithFields_WhenCalled_ItShouldReturnAnInstance() + { + var fieldIds = new[] { 1, 2, 3 }; + var builder = new GetAllRecordsPagesByAppRequestBuilder(_client, _appId) + .WithFields(fieldIds); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(fieldIds, builder.FieldIds); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldReturnAnInstance() + { + var pageSize = 100; + var builder = new GetAllRecordsPagesByAppRequestBuilder(_client, _appId) + .WithPageSize(pageSize); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(pageSize, builder.PageSize); + } + + [TestMethod] + public void WithFilter_WhenCalledWithFilterString_ItShouldReturnAnInstanceWithPropertiesSet() + { + var filter = "filter"; + var builder = new GetAllRecordsPagesByAppRequestBuilder(_client, _appId) + .WithFilter(filter); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(filter, builder.Filter); + } + + [TestMethod] + public void WithFilter_WhenCalledWithFilterAction_ItShouldReturnAnInstanceWithPropertiesSet() + { + var filter = new Filter(1, FilterOperator.Equal, "value"); + var builder = new GetAllRecordsPagesByAppRequestBuilder(_client, _appId) + .WithFilter(f => + { + f.FieldId = filter.FieldId; + f.Operator = filter.Operator; + f.Value = filter.Value; + }); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(filter.ToString(), builder.Filter); + } + + [TestMethod] + public void SendAsync_WhenCalled_ItShouldReturnAnAsyncEnumerable() + { + var result = _builder.SendAsync(); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType>>(result); + } + + [TestMethod] + public void SendAsync_WhenCalledWithOptions_ItShouldReturnAnAsyncEnumerable() + { + var result = _builder.SendAsync(o => + { + o.PageSize = 100; + o.FieldIds = [1, 2, 3]; + o.DataFormat = DataFormat.Formatted; + }); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType>>(result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderTests.cs new file mode 100644 index 0000000..a897126 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilderTests.cs @@ -0,0 +1,183 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAllRecordsPagesByQueryRequestBuilderTests + { + private static readonly int _appId = 1; + private static IOnspringClient _client; + private static GetAllRecordsPagesByQueryRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAllRecordsPagesByQueryRequestBuilder( + _client, + _appId, + 50, + [], + DataFormat.Raw, + null + ); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstance() + { + var builder = new GetAllRecordsPagesByQueryRequestBuilder( + _client, + _appId, + 50, + [], + DataFormat.Raw, + null + ); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(_appId, builder.AppId); + Assert.AreEqual(50, builder.PageSize); + Assert.AreEqual(DataFormat.Raw, builder.DataFormat); + Assert.AreEqual(0, builder.FieldIds.Count()); + } + + [TestMethod] + public void WithDataFormat_WhenCalled_ItShouldReturnAnInstance() + { + var dataFormat = DataFormat.Formatted; + var builder = new GetAllRecordsPagesByQueryRequestBuilder( + _client, + _appId, + 50, + [], + DataFormat.Raw, + null + ); + + builder.WithDataFormat(dataFormat); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(dataFormat, builder.DataFormat); + } + + [TestMethod] + public void WithFields_WhenCalled_ItShouldReturnAnInstance() + { + var fieldIds = new[] { 1, 2, 3 }; + var builder = new GetAllRecordsPagesByQueryRequestBuilder( + _client, + _appId, + 50, + [], + DataFormat.Raw, + null + ); + + builder.WithFields(fieldIds); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(fieldIds, builder.FieldIds); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldReturnAnInstance() + { + var pageSize = 100; + var builder = new GetAllRecordsPagesByQueryRequestBuilder( + _client, + _appId, + 50, + [], + DataFormat.Raw, + null + ); + + builder.WithPageSize(pageSize); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(pageSize, builder.PageSize); + } + + [TestMethod] + public void WithFilter_WhenCalledWithFilterString_ItShouldReturnAnInstanceWithPropertiesSet() + { + var filter = "filter"; + var builder = new GetAllRecordsPagesByQueryRequestBuilder( + _client, + _appId, + 50, + [], + DataFormat.Raw, + null + ); + + builder.WithFilter(filter); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(filter, builder.Filter); + } + + [TestMethod] + public void WithFilter_WhenCalledWithFilterAction_ItShouldReturnAnInstanceWithPropertiesSet() + { + var filter = new Filter(1, FilterOperator.Equal, "value"); + var builder = new GetAllRecordsPagesByQueryRequestBuilder( + _client, + _appId, + 50, + [], + DataFormat.Raw, + null + ); + + builder.WithFilter(f => + { + f.FieldId = filter.FieldId; + f.Operator = filter.Operator; + f.Value = filter.Value; + }); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + Assert.AreEqual(filter.ToString(), builder.Filter); + } + + [TestMethod] + public void SendAsync_WhenCalled_ItShouldReturnAnAsyncEnumerable() + { + var result = _builder.SendAsync(); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType>>(result); + } + + [TestMethod] + public void SendAsync_WhenCalledWithOptions_ItShouldReturnAnAsyncEnumerable() + { + var result = _builder + .WithFilter("filter") + .SendAsync(o => + { + o.PageSize = 100; + o.FieldIds = [1, 2, 3]; + o.DataFormat = DataFormat.Formatted; + }); + + Assert.IsNotNull(result); + Assert.IsInstanceOfType>>(result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesRequestBuilderTests.cs new file mode 100644 index 0000000..da5eeea --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Records/Get/GetAllRecordsPagesRequestBuilderTests.cs @@ -0,0 +1,40 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Models.Fluent; +using System.Diagnostics.CodeAnalysis; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAllRecordsPagesRequestBuilderTests + { + private static IOnspringClient _client; + private static GetAllRecordsPagesRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAllRecordsPagesRequestBuilder(_client); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnAnInstance() + { + var builder = new GetAllRecordsPagesRequestBuilder(_client); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + } + + [TestMethod] + public void FromApp_WhenCalled_ItShouldReturnAnInstance() + { + var appId = 1; + var builder = _builder.FromApp(appId); + + Assert.IsNotNull(builder); + Assert.IsInstanceOfType(builder); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetAllReportsPagesByAppRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetAllReportsPagesByAppRequestBuilderTests.cs new file mode 100644 index 0000000..ae76528 --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetAllReportsPagesByAppRequestBuilderTests.cs @@ -0,0 +1,62 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAllReportsPagesByAppRequestBuilderTests + { + private static readonly int _appId = 1; + private static IOnspringClient _client; + private static GetAllReportsPagesByAppRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAllReportsPagesByAppRequestBuilder(_client, _appId); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnBuilderInstanceWithPropertiesSet() + { + Assert.AreEqual(_appId, _builder.AppId); + Assert.AreEqual(50, _builder.PageSize); + } + + [TestMethod] + public void WithPageSize_WhenCalled_ItShouldSetPageSizeProperty() + { + var pageSize = 100; + + var builder = new GetAllReportsPagesByAppRequestBuilder(_client, _appId) + .WithPageSize(pageSize); + + Assert.AreEqual(pageSize, builder.PageSize); + } + + [TestMethod] + public void SendAsync_WhenCalled_ItShouldReturnAsyncEnumerable() + { + var result = _builder.SendAsync(); + + Assert.IsInstanceOfType>>(result); + } + + [TestMethod] + public void SendAsync_WhenCalledWithOptions_ItShouldReturnAsyncEnumerable() + { + var result = _builder.SendAsync(o => o.PageSize = 100); + + Assert.IsInstanceOfType>>(result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetAllReportsPagesRequestBuilderTests.cs b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetAllReportsPagesRequestBuilderTests.cs new file mode 100644 index 0000000..315674f --- /dev/null +++ b/Onspring.API.SDK.Tests/Tests/Unit/Fluent/Reports/GetAllReportsPagesRequestBuilderTests.cs @@ -0,0 +1,42 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using NSubstitute; +using Onspring.API.SDK.Enums; +using Onspring.API.SDK.Interfaces.Fluent; +using Onspring.API.SDK.Models; +using Onspring.API.SDK.Models.Fluent; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Threading.Tasks; + +namespace Onspring.API.SDK.Tests.Tests.Unit.Fluent +{ + [TestClass, ExcludeFromCodeCoverage] + public class GetAllReportsPagesRequestBuilderTests + { + private static readonly int _appId = 1; + private static IOnspringClient _client; + private static GetAllReportsPagesRequestBuilder _builder; + + [ClassInitialize] + public static void ClassInit(TestContext testContext) + { + _client = Substitute.For(); + _builder = new GetAllReportsPagesRequestBuilder(_client); + } + + [TestMethod] + public void Constructor_WhenCalled_ItShouldReturnBuilderInstance() + { + Assert.IsInstanceOfType(_builder); + } + + [TestMethod] + public void FromApp_WhenCalled_ItShouldReturnGetAllReportsPagesByAppRequestBuilderInstance() + { + var result = _builder.FromApp(_appId); + + Assert.IsInstanceOfType(result); + } + } +} \ No newline at end of file diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs index b016b2a..16cfc52 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByAppRequestBuilder.cs @@ -56,13 +56,16 @@ public IGetAllRecordsPagesByQueryRequestBuilder WithFilter(string filter) public IGetAllRecordsPagesByQueryRequestBuilder WithFilter(Action filter) { + var newFilter = new Filter(); + filter.Invoke(newFilter); + return new GetAllRecordsPagesByQueryRequestBuilder( _client, AppId, PageSize, FieldIds, DataFormat, - filter.ToString() + newFilter.ToString() ); } diff --git a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs index a050d13..26edc61 100644 --- a/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs +++ b/Onspring.API.SDK/Models/Fluent/Records/Get/GetAllRecordsPagesByQueryRequestBuilder.cs @@ -62,7 +62,9 @@ public IGetAllRecordsPagesByQueryRequestBuilder WithFilter(string filter) public IGetAllRecordsPagesByQueryRequestBuilder WithFilter(Action filter) { - Filter = filter.ToString(); + var newFilter = new Filter(); + filter.Invoke(newFilter); + Filter = newFilter.ToString(); return this; }