public void NotificationRecipientsBuildsQuery3() { var query = new NotificationRecipients() .AddDeviceWithQuery("d") .AddGroupWithQuery("p") .AddUserWithQuery("u") .BuildQuery(); Assert.AreEqual("/groups;ql=p/users;ql=u/devices;ql=d/notifications", query); }
public void NotificationRecipientsBuildsQuery4() { var query = new NotificationRecipients() .AddDeviceWithQuery(string.Empty) .AddGroupWithQuery(string.Empty) .AddUserWithQuery(string.Empty) .BuildQuery(); Assert.AreEqual("/groups;ql=/users;ql=/devices;ql=/notifications", query); }
public void NotificationRecipientsBuildsQuery2() { var query = new NotificationRecipients() .AddDeviceWithName("d") .AddGroupWithPath("p") .AddUserWithUuid("u") .BuildQuery(); Assert.AreEqual("/groups/p/users/u/devices/d/notifications", query); }
public void PublishNotificationShouldDelegateToNotificationsManagerWithCorrectParameters() { var notifications = new Notification[] { new AppleNotification("notifierName", "message", "chime") }; INotificationRecipients recipients = new NotificationRecipients().AddUserWithName("username"); var schedulerSettings = new NotificationSchedulerSettings { DeliverAt = DateTime.Now.AddDays(1) }; _client.PublishNotification(notifications, recipients, schedulerSettings); _notificationsManager.Received(1).PublishNotification(notifications, recipients, schedulerSettings); }
const string aadTenantId = "8c8dbccd-c171-4937-a134-e3c5a5dd0470"; // customer's tenant id static async Task Main(string[] args) { // Get an access token that we can use for making calls to the Business Central Admin Center APIs string accessToken = await Authenticate.GetAccessTokenAsync(aadAppId, aadAppRedirectUri, aadTenantId); // Manage environments await Environments.ListEnvironmentsAsync(accessToken); await Environments.CreateNewEnvironmentAsync(accessToken, "MyNewSandbox2", "Sandbox", "DK"); await Environments.CopyProductionEnvironmentToSandboxEnvironmentAsync(accessToken, "MyProd", "MyNewSandboxAsACopy", "DK"); await Environments.SetAppInsightsKeyAsync(accessToken, "MyProd", new Guid("0da21b54-841e-4a64-a117-6092784245f9")); await Environments.GetDatabaseSizeAsync(accessToken, "MyProd"); await Environments.GetSupportSettingsAsync(accessToken, "MyProd"); // Manage support settings await NotificationRecipients.GetNotificationRecipientsAsync(accessToken); await NotificationRecipients.AddNotificationRecipientAsync(accessToken, "*****@*****.**", "Partner Notifications Mail Group"); // Manage apps await Apps.GetInstalledAppsAsync(accessToken, "MyProd"); await Apps.GetAvailableAppUpdatesAsync(accessToken, "MyProd"); await Apps.UpdateAppAsync(accessToken, "MyProd", "334ef79e-547e-4631-8ba1-7a7f18e14de6", "16.0.11240.12188"); await Apps.GetAppOperationsAsync(accessToken, "MyProd", "334ef79e-547e-4631-8ba1-7a7f18e14de6"); // Manage active sessions await Sessions.GetActiveSessionsAsync(accessToken, "MyProd"); await Sessions.CancelSessionAsync(accessToken, "MyProd", 12202); // Manage update settings await UpdateSettings.GetUpdateWindowAsync(accessToken, "MyProd"); await UpdateSettings.SetUpdateWindowAsync(accessToken, "MyProd", new DateTime(2020, 06, 01, 4, 0, 0), new DateTime(2020, 06, 01, 11, 0, 0)); await UpdateSettings.GetScheduledUpdatesAsync(accessToken, "MyProd"); }
static void Main() { // Create a token credential, which enables us to authenticate to the Business Central Admin Center APIs. // Note 1: This will open the AAD login page in a browser window. // Note 2: You can also skip passing in options altogether if you want to log into your own Business Central admin center, i.e., not a delegated admin scenario var interactiveBrowserCredentialOptions = new InteractiveBrowserCredentialOptions { ClientId = "a19cb26a-2e4c-408b-82e1-6311742ecc50", // partner's AAD app id RedirectUri = new Uri("http://localhost"), // partner's AAD app redirect URI TenantId = "f5b6b245-5dd2-4bf5-94d4-35ef04d73c6d", // customer's tenant id }; var tokenCredential = new InteractiveBrowserCredential(interactiveBrowserCredentialOptions); // Create the Admin Center client var adminCenterClient = new AdminCenterClient(tokenCredential); // Manage environments Environments.ListEnvironments(adminCenterClient); Environments.CreateNewEnvironment(adminCenterClient, "MySandbox", "Sandbox", "DK"); Environments.CopyProductionEnvironmentToSandboxEnvironment(adminCenterClient, "MyProd", "MySandboxAsACopy"); Environments.SetAppInsightsKey(adminCenterClient, "MyProd", new Guid("0da21b54-841e-4a64-a117-6092784245f9")); Environments.GetDatabaseSize(adminCenterClient, "MyProd"); Environments.GetSupportSettings(adminCenterClient, "MyProd"); // Manage support settings NotificationRecipients.GetNotificationRecipients(adminCenterClient); NotificationRecipients.AddNotificationRecipient(adminCenterClient, "*****@*****.**", "Partner Notifications Mail Group"); // Manage apps Apps.GetInstalledApps(adminCenterClient, "MyProd"); Apps.GetAvailableAppUpdates(adminCenterClient, "MyProd"); Apps.UpdateApp(adminCenterClient, "MyProd", new Guid("334ef79e-547e-4631-8ba1-7a7f18e14de6"), "16.0.11240.12188"); Apps.GetAppOperations(adminCenterClient, "MyProd", new Guid("334ef79e-547e-4631-8ba1-7a7f18e14de6")); // Manage active sessions Sessions.GetActiveSessions(adminCenterClient, "MyProd"); Sessions.CancelSession(adminCenterClient, "MyProd", 196719); // Manage update settings UpdateSettings.GetUpdateWindow(adminCenterClient, "MyProd"); UpdateSettings.SetUpdateWindow(adminCenterClient, "MyProd", new DateTime(2020, 06, 01, 4, 15, 0), new DateTime(2020, 06, 01, 11, 30, 0)); UpdateSettings.GetScheduledUpdates(adminCenterClient, "MyProd"); }
public void ShouldPublishNotifications() { //Set up const string appleNotifierName = "apple_notifier"; const string googleNotifierName = "google_notifier"; const string username = "******"; const string appleTestMessge = "test message for Apple"; const string androidTestMessage = "test message for Android"; var client = InitializeClientAndLogin(AuthType.Organization); CreateAppleNotifier(client, appleNotifierName); CreateAndroidNotifier(client, googleNotifierName); CreateUser(username, client); //Setup Notifications var appleNotification = new AppleNotification(appleNotifierName, appleTestMessge, "chime"); var googleNotification = new AndroidNotification(googleNotifierName, androidTestMessage); //Setup recipients and scheduling INotificationRecipients recipients = new NotificationRecipients().AddUserWithName(username); var schedulerSettings = new NotificationSchedulerSettings { DeliverAt = DateTime.Now.AddDays(1) }; client.PublishNotification(new Notification[] { appleNotification, googleNotification }, recipients, schedulerSettings); //Assert UsergridCollection <dynamic> entities = client.GetEntities <dynamic>("notifications", query: "order by created desc"); dynamic notification = entities.FirstOrDefault(); Assert.IsNotNull(notification); Assert.IsNotNull(notification.uuid); Assert.AreEqual(appleTestMessge, notification.payloads.apple_notifier.aps.alert.Value); Assert.AreEqual("chime", notification.payloads.apple_notifier.aps.sound.Value); Assert.AreEqual(androidTestMessage, notification.payloads.google_notifier.data.Value); //Cancel notification and assert it is canceled client.CancelNotification(notification.uuid.Value); dynamic entity = client.GetEntity <dynamic>("notifications", notification.uuid.Value); Assert.AreEqual(entity.state.Value, "CANCELED"); }