Parse notifications
Some tooltip text!
• 1 minute to read
• 1 minute to read
The application must take advantage of these notifications to ensure their environments are kept up-to-date with the status of SuperOffice CRM Online tenants.
While there are several ways to accomplish processing tenant status changes notification, the following is a short example of what that might look like using .NET and C#.
CustomerStateChangeNotificationType Enumeration
public enum CustomerStateChangeNotificationType
{
Upgrade = 0,
BackupRestored = 1,
Suspend = 2,
Resume = 3,
Delete = 4
}
NotificationMessage
public class NotificationMessage
{
public CustomerStateChangeNotificationType ChangeType { get; set; }
public string ContextIdentifier { get; set; }
public string VersionName { get; set; }
public string FileVersion { get; set; }
public string Token { get; set; }
}
API Controller and JWT Validation
public class NotifyCustomerStateChangeController : ApiController
{
public void Post([FromBody]NotificationMessage message)
{
try
{
// SuperIdTokenHandler is available in NuGet package: SuperOffice.Crm.Online.Core
SuperIdToken validated = ValidateToken(message.Token);
// process accordingly...
}
catch (Exception ex)
{
// handle invalid token...
throw;
}
}
public static SuperIdToken ValidateToken(string token)
{
var path = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/") + "SOD_SuperOfficeFederatedLogin.crt";
var tokenHandler = new SuperIdTokenHandler();
tokenHandler.JwtIssuerSigningCertificate = new X509Certificate2(path);
tokenHandler.CertificateValidator = X509CertificateValidator.ChainTrust;
tokenHandler.ValidIssuer = "https://sod.superoffice.com";
return tokenHandler.ValidateToken(token, TokenType.Jwt);
}
}