Skip to content

Commit

Permalink
Merge pull request #3526 from signalco-io/feat/entity-contact-fixed-t…
Browse files Browse the repository at this point in the history
…ags-and-methods

Feat/entity contact fixed tags and methods
  • Loading branch information
AleksandarDev authored Sep 30, 2023
2 parents fbb44d0 + 274962a commit 99ce971
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ContactDeleteFunction(
[OpenApiOperation<ContactDeleteFunction>("Contact", Description = "Deletes the contact.")]
[OpenApiResponseWithoutBody]
public async Task<HttpResponseData> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "entity/{id:guid}/contacts/{channelName}/{contactName}")]
[HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "entity/{id:guid}/contacts/{channelName}/{contactName}")]
HttpRequestData req,
string id,
string channelName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ public ContactHistoryRetrieveFunction(
IEntityService entityService,
IAzureStorageDao storage)
{
this.functionAuthenticator =
functionAuthenticator ?? throw new ArgumentNullException(nameof(functionAuthenticator));
this.entityService = entityService ?? throw new ArgumentNullException(nameof(entityService));
this.storageDao = storage ?? throw new ArgumentNullException(nameof(storage));
this.functionAuthenticator = functionAuthenticator;
this.entityService = entityService;
this.storageDao = storage;
}

[Function("Contact-HistoryRetrieve")]
Expand All @@ -44,7 +43,7 @@ public async Task<HttpResponseData> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "contact/history")]
HttpRequestData req,
CancellationToken cancellationToken = default) =>
await req.UserRequest<ContactHistoryResponseDto>(cancellationToken, this.functionAuthenticator, async context =>
await req.UserRequest(cancellationToken, this.functionAuthenticator, async context =>
{
var entityId = req.Query["entityId"];
var channelName = req.Query["channelName"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ await req.UserRequest<ContactSetDto>(cancellationToken, this.functionAuthenticat

[Function("Entity-Contact-Set")]
[OpenApiSecurityAuth0Token]
[Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes.OpenApiOperation("EntityContactSet", "Contact", Description = "Sets contact value.")]
[Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes.OpenApiOperation("EntityContactSet", "Entity", Description = "Sets contact value.")]
[OpenApiJsonRequestBody<ContactSetDto>]
[OpenApiResponseWithoutBody]
[OpenApiResponseBadRequestValidation]
public async Task<HttpResponseData> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "put", Route = "entity/{id:guid}/contacts/{channelName}/{contactName}")]
[HttpTrigger(AuthorizationLevel.Anonymous, "put", "post", Route = "entity/{id:guid}/contacts/{channelName}/{contactName}")]
HttpRequestData req,
string id,
string channelName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Octokit;
using Signal.Core.Secrets;
using Signalco.Channel.GitHubApp.Secrets;
using ProductHeaderValue = Octokit.ProductHeaderValue;

namespace Signalco.Channel.GitHubApp.Functions
{
Expand Down
11 changes: 2 additions & 9 deletions web/apps/app/src/contacts/ContactRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,14 @@ export async function setMetadataAsync(pointer: IContactPointer, metadataSeriali
}

export async function setAsync(pointer: IContactPointer, valueSerialized: string | undefined, timeStamp?: Date | undefined) {
await requestAsync('/contact/set', 'post', {
entityId: pointer.entityId,
contactName: pointer.contactName,
channelName: pointer.channelName,
await requestAsync(`/entity/${pointer.entityId}/contacts/${pointer.channelName}/${pointer.contactName}`, 'put', {
valueSerialized: valueSerialized,
timeStamp: timeStamp?.toISOString()
});
}

export async function deleteContactAsync(pointer: IContactPointer) {
await requestAsync('/contact', 'delete', {
entityId: pointer.entityId,
contactName: pointer.contactName,
channelName: pointer.channelName
});
await requestAsync(`/entity/${pointer.entityId}/contacts/${pointer.channelName}/${pointer.contactName}`, 'delete');
}

export async function historiesAsync(targets: IContactPointer[] | undefined, duration: number) {
Expand Down

0 comments on commit 99ce971

Please sign in to comment.