/// <summary>
 /// Decode tags and property into registration object
 /// </summary>
 /// <param name="model"></param>
 /// <param name="disabled"></param>
 /// <returns></returns>
 public static EndpointRegistration FromServiceModel(EndpointInfoModel model,
                                                     bool?disabled = null)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     return(new EndpointRegistration {
         IsDisabled = disabled,
         NotSeenSince = model.NotSeenSince,
         ApplicationId = model.ApplicationId,
         SiteId = model.Registration?.SiteId,
         SupervisorId = model.Registration?.SupervisorId,
         Certificate = model.Registration?.Certificate?.EncodeAsDictionary(),
         Thumbprint = model.Registration?.Certificate?.ToSha1Hash(),
         SecurityLevel = model.Registration?.SecurityLevel,
         EndpointRegistrationUrl = model.Registration?.EndpointUrl ??
                                   model.Registration?.Endpoint.Url,
         EndpointUrl = model.Registration?.Endpoint.Url,
         AlternativeUrls = model.Registration?.Endpoint.AlternativeUrls?.ToList()?
                           .EncodeAsDictionary(),
         AuthenticationMethods = model.Registration?.AuthenticationMethods?
                                 .EncodeAsDictionary(JToken.FromObject),
         Credential = model.Registration?.Endpoint.User?.Value,
         CredentialType = model.Registration?.Endpoint.User?.Type ??
                          Models.CredentialType.None,
         SecurityMode = model.Registration?.Endpoint.SecurityMode ??
                        Models.SecurityMode.Best,
         SecurityPolicy = model.Registration?.Endpoint.SecurityPolicy,
         ServerThumbprint = model.Registration?.Endpoint?
                            .ServerThumbprint.EncodeAsDictionary(),
         ClientCertificate = model.Registration?.Endpoint?
                             .ClientCertificate.EncodeAsDictionary(),
         ActivationState = model.ActivationState
     });
 }