Skip to content

Commit

Permalink
Updated webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalii-bezuhlyi committed Mar 20, 2024
1 parent b72a8bd commit 2d6160a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Apps.Lionbridge/Webhooks/Handlers/BaseWebhookHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task UnsubscribeAsync(IEnumerable<AuthenticationCredentialsProvider
var response = await Client.ExecuteWithErrorHandling<ListenersResponse>(request);

// Lionbridge api returns eventtype without 'ed' at the end: REQUEST_UPDATED (it will be REQUEST_UPDATE)
return response.Embedded.Listeners.FirstOrDefault(x => x.Type.Contains(SubscriptionEvent));
return response.Embedded.listeners.FirstOrDefault(x => SubscriptionEvent.Contains(x.Type));
}

private async Task<ListenerDto> CreateListenerAsync()
Expand All @@ -82,4 +82,6 @@ private async Task DeleteListenerAsync(string listenerId)
}

protected abstract string[] GetStatusCodes();

protected abstract string GetEventType();
}
5 changes: 5 additions & 0 deletions Apps.Lionbridge/Webhooks/Handlers/JobStatusUpdatedHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ protected override string[] GetStatusCodes()
{
return new[] { "IN_TRANSLATION", "CANCELLED", "SENT_TO_PROVIDER" };
}

protected override string GetEventType()
{
return "JOB_UPDATE";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ protected override string[] GetStatusCodes()
{
return new[] { "IN_TRANSLATION", "CANCELLED", "REVIEW_TRANSLATION" };
}

protected override string GetEventType()
{
return "REQUEST_UPDATE";
}
}
2 changes: 1 addition & 1 deletion Apps.Lionbridge/Webhooks/Responses/ListenersResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public class ListenersResponse : EmbeddedItemsWrapper<ListenersWrapper>

}

public record ListenersWrapper(IEnumerable<ListenerDto> Listeners);
public record ListenersWrapper(IEnumerable<ListenerDto> listeners);

0 comments on commit 2d6160a

Please sign in to comment.