< Summary - Syki

Information
Class: Syki.Back.Features.Academic.CreateWebhookSubscription.WebhookSubscription
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CreateWebhookSubscription/WebhookSubscription.cs
Tag: 4_16869239191
Line coverage
51%
Covered lines: 21
Uncovered lines: 20
Coverable lines: 41
Total lines: 68
Line coverage: 51.2%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_InstitutionId()100%11100%
get_Name()100%11100%
get_Url()100%11100%
get_CreatedAt()100%11100%
get_Events()100%11100%
get_Authentication()100%11100%
get_Calls()100%210%
.ctor()100%11100%
.ctor(...)100%11100%
ToOut()100%11100%
ToGetWebhooksOut()100%210%
ToGetWebhookOut()100%210%

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/CreateWebhookSubscription/WebhookSubscription.cs

#LineLine coverage
 1using Syki.Back.Features.Academic.CallWebhooks;
 2
 3namespace Syki.Back.Features.Academic.CreateWebhookSubscription;
 4
 5/// <summary>
 6/// Inscrição de Webhook para receber notificações sobre eventos acadêmicos.
 7/// </summary>
 8public class WebhookSubscription
 9{
 610    public Guid Id { get; set; }
 211    public Guid InstitutionId { get; set; }
 412    public string Name { get; set; }
 413    public string Url { get; set; }
 214    public DateTime CreatedAt { get; set; }
 15
 416    public List<WebhookEventType> Events { get; set; }
 617    public WebhookAuthentication Authentication { get; set; }
 18
 019    public List<WebhookCall> Calls { get; set; }
 20
 421    private WebhookSubscription() { }
 22
 223    public WebhookSubscription(Guid institutionId, string name, string url, List<WebhookEventType> events, string apiKey
 24    {
 225        Id = Guid.CreateVersion7();
 226        InstitutionId = institutionId;
 227        Name = name;
 228        Url = url;
 229        Events = events;
 230        CreatedAt = DateTime.UtcNow;
 231        Authentication = new WebhookAuthentication(Id, WebhookAuthenticationType.ApiKey, apiKey);
 232    }
 33
 34    public CreateWebhookSubscriptionOut ToOut()
 35    {
 236        return new()
 237        {
 238            Id = Id,
 239        };
 40    }
 41
 42    public GetWebhooksOut ToGetWebhooksOut()
 43    {
 044        return new()
 045        {
 046            Id = Id,
 047            Name = Name,
 048            Url = Url,
 049            CreatedAt = CreatedAt,
 050            CallsCount = Calls.Count,
 051        };
 52    }
 53
 54    public GetWebhookOut ToGetWebhookOut()
 55    {
 056        return new()
 057        {
 058            Id = Id,
 059            Url = Url,
 060            Name = Name,
 061            CreatedAt = CreatedAt,
 062            CallsCount = Calls.Count,
 063            EventsCount = Events.Count,
 064            AuthenticationType = Authentication.Type,
 065            Calls = Calls.ConvertAll(x => x.ToGetWebhookCallOut())
 066        };
 67    }
 68}