-
-
Notifications
You must be signed in to change notification settings - Fork 44
Adding advanced search. Fixes issue #216. #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
332b7a4
Adding advanced search. Fixes issue #216.
kevbite b0c41e0
Update tests/CompaniesHouse.IntegrationTests/Keys.cs
kevbite 6fffb41
Update src/CompaniesHouse/UriBuilders/SearchUriBuilder.cs
kevbite 0727fd4
Upgrade .NET SDK version to 9.0 in Dockerfile
kevbite 27729d5
Refactor Dockerfile for build stage syntax
kevbite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/CompaniesHouse/ICompaniesHouseSearchCompanyAdvancedClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using CompaniesHouse.Request; | ||
| using CompaniesHouse.Response.Search.CompanySearch; | ||
|
|
||
| namespace CompaniesHouse; | ||
|
|
||
| public interface ICompaniesHouseSearchCompanyAdvancedClient | ||
| { | ||
| Task<CompaniesHouseClientResponse<CompanySearch>> SearchCompanyAdvancedAsync( | ||
| AdvancedSearchCompanyRequest request, CancellationToken cancellationToken = default(CancellationToken)); | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/CompaniesHouse/Request/AdvancedSearchCompanyRequest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #nullable enable | ||
| using CompaniesHouse.Response; | ||
| using CompaniesHouse.Response.Search.CompanySearch; | ||
|
|
||
| namespace CompaniesHouse.Request; | ||
|
|
||
| public class AdvancedSearchCompanyRequest : SearchRequest<CompanySearch> | ||
| { | ||
| public string? CompanyNameIncludes { get; set; } | ||
| public string? CompanyNameExcludes { get; set; } | ||
| public IReadOnlyCollection<CompanyStatus> CompanyStatus { get; set; } = []; | ||
| public IReadOnlyCollection<CompanySubType> CompanySubtype { get; set; } = []; | ||
| public IReadOnlyCollection<CompanyType> CompanyType { get; set; } = []; | ||
| public DateTime? DissolvedFrom { get; set; } | ||
| public DateTime? DissolvedTo { get; set; } | ||
| public DateTime? IncorporatedFrom { get; set; } | ||
| public DateTime? IncorporatedTo { get; set; } | ||
| public string? Location { get; set; } | ||
| public IReadOnlyCollection<string> SicCodes { get; set; } = []; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace CompaniesHouse.Request; | ||
|
|
||
| public interface IQuerySearchRequest : ISearchRequest | ||
| { | ||
| string Query { get; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| using CompaniesHouse.Response.Search.CompanySearch; | ||
| #nullable enable | ||
| using CompaniesHouse.Response.Search.CompanySearch; | ||
|
|
||
| namespace CompaniesHouse.Request; | ||
|
|
||
| public class SearchCompanyRequest : SearchRequest<CompanySearch> | ||
| public class SearchCompanyRequest : QuerySearchRequest<CompanySearch> | ||
| { | ||
| public string Restrictions { get; set; } | ||
| public string? Restrictions { get; set; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| using System.Runtime.Serialization; | ||
|
|
||
| namespace CompaniesHouse.Response; | ||
|
|
||
| public enum CompanySubType | ||
| { | ||
| [EnumMember(Value = "")] None = 0, | ||
|
|
||
| [EnumMember(Value = "community-interest-company")] | ||
| CommunityInterestCompany, | ||
|
|
||
| [EnumMember(Value = "private-fund-limited-partnership")] | ||
| PrivateFundLimitedPartnership, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/CompaniesHouse/UriBuilders/AdvancedSearchCompanyUriBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using System.Text; | ||
| using CompaniesHouse.Request; | ||
|
|
||
| namespace CompaniesHouse.UriBuilders; | ||
|
|
||
| public class AdvancedSearchCompanyUriBuilder : SearchUriBuilder<AdvancedSearchCompanyRequest> | ||
| { | ||
| public AdvancedSearchCompanyUriBuilder(string path) : base(path) | ||
| { | ||
| } | ||
|
|
||
| protected override string BuildQuery(AdvancedSearchCompanyRequest request) | ||
| { | ||
| var queryBuilder = new StringBuilder(base.BuildQuery(request)); | ||
|
|
||
| AppendParameterIfValid(queryBuilder, "company_name_includes", request.CompanyNameIncludes, value => !string.IsNullOrWhiteSpace(value)); | ||
| AppendParameterIfValid(queryBuilder, "company_name_excludes", request.CompanyNameExcludes, value => !string.IsNullOrWhiteSpace(value)); | ||
| AppendParameterIfValid(queryBuilder, "company_status", request.CompanyStatus); | ||
| AppendParameterIfValid(queryBuilder, "company_subtype", request.CompanySubtype); | ||
| AppendParameterIfValid(queryBuilder, "company_type", request.CompanyType); | ||
| AppendParameterIfValid(queryBuilder, "dissolved_from", request.DissolvedFrom, value => value.HasValue); | ||
| AppendParameterIfValid(queryBuilder, "dissolved_to", request.DissolvedTo, value =>value.HasValue); | ||
| AppendParameterIfValid(queryBuilder, "incorporated_from", request.IncorporatedFrom, value =>value.HasValue); | ||
kevbite marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| AppendParameterIfValid(queryBuilder, "incorporated_to", request.IncorporatedTo, value => value.HasValue); | ||
| AppendParameterIfValid(queryBuilder, "location", request.Location, value => !string.IsNullOrWhiteSpace(value)); | ||
| AppendParameterIfValid(queryBuilder, "sic_codes", request.SicCodes); | ||
|
|
||
| return queryBuilder.ToString(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.