Register to get notifications when tenant status changes
When a tenant installation changes, SuperOffice sends a change notification to each approved application. The State change URL is set in the advanced application configuration of each application.
To receive notifications (onetime set-up)
Set up a web service listening for state changes. For example:
https://www.awesomeapp.com/NotifyCustomerStateChange
In the Developer Portal, go to your app page.
Select Configuration.
Turn on Advanced.
Select Notifications.
Enter the URL of your endpoint SuperOffice should push notifications to when a tenant changes status.
https://www.awesomeapp.com/NotifyCustomerStateChange
Optionally, turn on Configure per Environment to set different URLs for SOD, Stage, and Production.
-
Select Off/On to activate the endpoint (turn on data traffic).
Click Save Settings or OK.
You are now set to parse notifications when you get them.
Parse notifications
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 process 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);
}
}