Skip to content

Commit

Permalink
Consumer Api: Add get Tags endpoint (#917)
Browse files Browse the repository at this point in the history
* feat: Add Tags Module

* feat: Add Module class, configuration and Tag Provider service

* feat: Add Tags Module to Consumer Api

* feat: Add Tags controller and basic GET /Tags endpoint

* chore: Make Tag title optional

* chore: Add custom Json converter for the List Tags response to prevent camel case

* feat: Add bruno file for GET /Tags endpoint

* refactor: Rewrite ListTagsResponse Writer to reflect current specification

* refactor: Add validators for options

* refactor: Rewrite response to match current specification

* feat: Add Tags module and GET /Tags endpoint to the Consumer Api Sdk

* feat: Add integration test for the GET /Tags endpoint

* chore: Add test attribute data

* chore: Typo

* chore: Add Tag infos to other appsettings.override files

* chore: Move Tags projects into correct folder

* chore: Minor fixes, typos and formatting

* chore: Let Tags controller authorize the clients, but allow anonymous access for the GET /Tags endpoint

* refactor: Move TagInfo into Domain project, use ITagsRepository instead of TagProvider

* refactor: Remove custom json serializer

* feat: Use custom validation for tags

* refactor: Implement current structure in appsettings json files

* feat: Add validation for language codes

* chore: Add custom json converter again to prevent camel case conversion

* refactor: use PascalCaseDictionaryConverter

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Timo Notheisen <[email protected]>
  • Loading branch information
3 people authored Oct 28, 2024
1 parent 2676c01 commit fa74950
Show file tree
Hide file tree
Showing 31 changed files with 795 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .ci/appsettings.override.postgres.docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,76 @@
}
}
},
"Tags": {
"Application": {
"SupportedLanguages": [
"de",
"en"
],
"TagsForAttributeValueTypes": {
"IdentityFileReference": {
"schulabschluss": {
"displayNames": {
"de": "Abschluss",
"en": "Degree"
},
"children": {
"realschule": {
"displayNames": {
"de": "Realschule",
"en": "Secondary School"
},
"children": {
"zeugnis": {
"displayNames": {
"de": "Zeugnis",
"en": "Diploma"
}
}
}
},
"gymnasium": {
"displayNames": {
"de": "Gymnasium",
"en": "High School"
},
"children": {
"zeugnis": {
"displayNames": {
"de": "Zeugnis",
"en": "Diploma"
}
}
}
}
}
}
},
"PhoneNumber": {
"notfall": {
"displayNames": {
"de": "Notfallkontakt",
"en": "Emergency Contact"
}
}
},
"StreetAddress": {
"lieferung": {
"displayNames": {
"de": "Lieferadresse",
"en": "Deliver Address"
}
},
"heimat": {
"displayNames": {
"de": "Heimatadresse",
"en": "Home Address"
}
}
}
}
}
},
"Tokens": {
"Infrastructure": {
"SqlDatabase": {
Expand Down
70 changes: 70 additions & 0 deletions .ci/appsettings.override.postgres.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,76 @@
}
}
},
"Tags": {
"Application": {
"SupportedLanguages": [
"de",
"en"
],
"TagsForAttributeValueTypes": {
"IdentityFileReference": {
"schulabschluss": {
"displayNames": {
"de": "Abschluss",
"en": "Degree"
},
"children": {
"realschule": {
"displayNames": {
"de": "Realschule",
"en": "Secondary School"
},
"children": {
"zeugnis": {
"displayNames": {
"de": "Zeugnis",
"en": "Diploma"
}
}
}
},
"gymnasium": {
"displayNames": {
"de": "Gymnasium",
"en": "High School"
},
"children": {
"zeugnis": {
"displayNames": {
"de": "Zeugnis",
"en": "Diploma"
}
}
}
}
}
}
},
"PhoneNumber": {
"notfall": {
"displayNames": {
"de": "Notfallkontakt",
"en": "Emergency Contact"
}
}
},
"StreetAddress": {
"lieferung": {
"displayNames": {
"de": "Lieferadresse",
"en": "Deliver Address"
}
},
"heimat": {
"displayNames": {
"de": "Heimatadresse",
"en": "Home Address"
}
}
}
}
}
},
"Tokens": {
"Infrastructure": {
"SqlDatabase": {
Expand Down
70 changes: 70 additions & 0 deletions .ci/appsettings.override.sqlserver.docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,76 @@
}
}
},
"Tags": {
"Application": {
"SupportedLanguages": [
"de",
"en"
],
"TagsForAttributeValueTypes": {
"IdentityFileReference": {
"schulabschluss": {
"displayNames": {
"de": "Abschluss",
"en": "Degree"
},
"children": {
"realschule": {
"displayNames": {
"de": "Realschule",
"en": "Secondary School"
},
"children": {
"zeugnis": {
"displayNames": {
"de": "Zeugnis",
"en": "Diploma"
}
}
}
},
"gymnasium": {
"displayNames": {
"de": "Gymnasium",
"en": "High School"
},
"children": {
"zeugnis": {
"displayNames": {
"de": "Zeugnis",
"en": "Diploma"
}
}
}
}
}
}
},
"PhoneNumber": {
"notfall": {
"displayNames": {
"de": "Notfallkontakt",
"en": "Emergency Contact"
}
}
},
"StreetAddress": {
"lieferung": {
"displayNames": {
"de": "Lieferadresse",
"en": "Deliver Address"
}
},
"heimat": {
"displayNames": {
"de": "Heimatadresse",
"en": "Home Address"
}
}
}
}
}
},
"Tokens": {
"Infrastructure": {
"SqlDatabase": {
Expand Down
70 changes: 70 additions & 0 deletions .ci/appsettings.override.sqlserver.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,76 @@
}
}
},
"Tags": {
"Application": {
"SupportedLanguages": [
"de",
"en"
],
"TagsForAttributeValueTypes": {
"IdentityFileReference": {
"schulabschluss": {
"displayNames": {
"de": "Abschluss",
"en": "Degree"
},
"children": {
"realschule": {
"displayNames": {
"de": "Realschule",
"en": "Secondary School"
},
"children": {
"zeugnis": {
"displayNames": {
"de": "Zeugnis",
"en": "Diploma"
}
}
}
},
"gymnasium": {
"displayNames": {
"de": "Gymnasium",
"en": "High School"
},
"children": {
"zeugnis": {
"displayNames": {
"de": "Zeugnis",
"en": "Diploma"
}
}
}
}
}
}
},
"PhoneNumber": {
"notfall": {
"displayNames": {
"de": "Notfallkontakt",
"en": "Emergency Contact"
}
}
},
"StreetAddress": {
"lieferung": {
"displayNames": {
"de": "Lieferadresse",
"en": "Deliver Address"
}
},
"heimat": {
"displayNames": {
"de": "Heimatadresse",
"en": "Home Address"
}
}
}
}
}
},
"Tokens": {
"Infrastructure": {
"SqlDatabase": {
Expand Down
1 change: 1 addition & 0 deletions Applications/ConsumerApi/src/ConsumerApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<ProjectReference Include="..\..\..\Modules\Quotas\src\Quotas.ConsumerApi\Quotas.ConsumerApi.csproj" />
<ProjectReference Include="..\..\..\Modules\Relationships\src\Relationships.ConsumerApi\Relationships.ConsumerApi.csproj" />
<ProjectReference Include="..\..\..\Modules\Synchronization\src\Synchronization.ConsumerApi\Synchronization.ConsumerApi.csproj" />
<ProjectReference Include="..\..\..\Modules\Tags\src\Tags.ConsumerApi\Tags.ConsumerApi.csproj" />
<ProjectReference Include="..\..\..\Modules\Tokens\src\Tokens.ConsumerApi\Tokens.ConsumerApi.csproj" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions Applications/ConsumerApi/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Backbone.Modules.Relationships.Infrastructure.Persistence.Database;
using Backbone.Modules.Synchronization.ConsumerApi;
using Backbone.Modules.Synchronization.Infrastructure.Persistence.Database;
using Backbone.Modules.Tags.ConsumerApi;
using Backbone.Modules.Tokens.ConsumerApi;
using Backbone.Modules.Tokens.Infrastructure.Persistence.Database;
using Backbone.Tooling.Extensions;
Expand Down Expand Up @@ -147,6 +148,7 @@ static void ConfigureServices(IServiceCollection services, IConfiguration config
.AddModule<QuotasModule>(configuration)
.AddModule<RelationshipsModule>(configuration)
.AddModule<SynchronizationModule>(configuration)
.AddModule<TagsModule>(configuration)
.AddModule<TokensModule>(configuration);

var quotasSqlDatabaseConfiguration = parsedConfiguration.Modules.Quotas.Infrastructure.SqlDatabase;
Expand Down
11 changes: 11 additions & 0 deletions Applications/ConsumerApi/src/http/Tags/ListTags.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: /Tags
type: http
seq: 1
}

get {
url: {{baseUrl}}/Tags
body: none
auth: none
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@Integration
Feature: GET /Tags

User requests available Tags

Scenario: Requesting the available Tags
When A GET request to the /Tags endpoint gets sent
Then the response status code is 200 (OK)
And the response supports the English language
And the response attributes contain tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Backbone.BuildingBlocks.SDK.Endpoints.Common.Types;
using Backbone.ConsumerApi.Sdk.Endpoints.Tags.Types.Responses;
using Backbone.ConsumerApi.Tests.Integration.Contexts;
using Backbone.ConsumerApi.Tests.Integration.Helpers;

namespace Backbone.ConsumerApi.Tests.Integration.StepDefinitions;

[Binding]
public class TagsStepDefinitions
{
private readonly ResponseContext _responseContext;
private readonly ClientPool _clientPool;

private ApiResponse<ListTagsResponse>? _listTagsResponse;

public TagsStepDefinitions(ResponseContext responseContext, ClientPool clientPool)
{
_responseContext = responseContext;
_clientPool = clientPool;
}

[When("A GET request to the /Tags endpoint gets sent")]
public async Task WhenAGETRequestToTheTagsEndpointGetsSent()
{
var client = _clientPool.Anonymous;
_responseContext.WhenResponse = _listTagsResponse = await client.Tags.ListTags();
}

[Then("the response supports the English language")]
public void AndTheResponseSupportsTheEnglishLanguage()
{
_listTagsResponse!.Result!.SupportedLanguages.Should().Contain("en");
}

[Then("the response attributes contain tags")]
public void AndTheResponseAttributesContainTags()
{
foreach (var attr in _listTagsResponse!.Result!.TagsForAttributeValueTypes.Values)
{
attr.Should().NotBeEmpty();
}
}
}
Loading

0 comments on commit fa74950

Please sign in to comment.