public void RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllForRepository("banana", "split", notificationsRequest, options); connection.Received().Get <List <Notification> >(endpoint, Arg.Is <Dictionary <string, string> >( d => d.Count == 4 && d["all"] == "true" && d["participating"] == "false" && d["page"] == "1" && d["per_page"] == "1"), null); }
protected override void OnHandleIntent(Intent intent) { var client = new GitHubClient(new ProductHeaderValue("gitit")); if (CrossSecureStorage.Current.HasKey("OAuthToken")) { _passwordCredential = new Credentials(CrossSecureStorage.Current.GetValue("OAuthToken")); client.Credentials = new Credentials(_passwordCredential.Password); var notificationRequest = new NotificationsRequest { Since = DateTimeOffset.Now.Subtract(new TimeSpan(0, 15, 0)) }; var notifications = client.Activity.Notifications.GetAllForCurrent(notificationRequest).Result; foreach (var notification in notifications) { _title = $"{notification.Subject.Title}"; _text = $"in {notification.Repository.FullName} ({Convert.ToDateTime(notification.UpdatedAt).Humanize()})"; var builder = new NotificationCompat.Builder(this) .SetSmallIcon(Resource.Drawable.ic_stat_newstorelogo_scale_400) .SetContentTitle(_title) .SetContentText(_text); var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); notificationManager.Notify(1, builder.Build()); } } }
protected override void OnHandleIntent(Intent intent) { if (!CrossConnectivity.Current.IsConnected) { return; } try { var client = new GitHubClient(new ProductHeaderValue("gitit")); if (CrossSecureStorage.Current.HasKey("OAuthToken")) { _passwordCredential = new Credentials(CrossSecureStorage.Current.GetValue("OAuthToken")); client.Credentials = new Credentials(_passwordCredential.Password); var notificationRequest = new NotificationsRequest { Since = DateTimeOffset.Now.Subtract(new TimeSpan(1, 0, 0, 0)) }; var serverNotifications = client.Activity.Notifications.GetAllForCurrent(notificationRequest).Result; if (serverNotifications.Count <= 0) { return; } var latestUpdatedAt = DateTime.Parse(serverNotifications[0].UpdatedAt); IEnumerable <Octokit.Notification> notifications = new List <Notification>(0); var prefs = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); var prefsEditor = prefs.Edit(); if (prefs.Contains(_lastShowedNotificationKey)) { var localUpdatedAt = DateTime.Parse(prefs.GetString(_lastShowedNotificationKey, "null")); notifications = from notification in serverNotifications where latestUpdatedAt > localUpdatedAt select notification; } prefsEditor.PutString(_lastShowedNotificationKey, latestUpdatedAt.ToString()); prefsEditor.Apply(); foreach (var notification in notifications) { _title = $"{notification.Subject.Title}"; _text = $"in {notification.Repository.FullName} ({Convert.ToDateTime(notification.UpdatedAt).Humanize()})"; var builder = new NotificationCompat.Builder(this) .SetSmallIcon(Resource.Drawable.ic_stat_newstorelogo_scale_400) .SetContentTitle(_title) .SetContentText(_text); var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); notificationManager.Notify(1, builder.Build()); } } } catch (Exception e) { } }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user. /// </summary> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <param name="options">Options for changing the API response</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns> public IObservable <Notification> GetAllForCurrent(NotificationsRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); return(_connection.GetAndFlattenAllPages <Notification>(ApiUrls.Notifications(), request.ToParametersDictionary(), options)); }
public Task <Result <NotificationsResponse[]> > GetNotificationEventsAsync(NotificationsRequest request, CancellationToken token) { // Since 6.6; internal return(InvokeSonarQubeApi("api/developers/search_events", request, token, stringResponse => JObject.Parse(stringResponse)["events"].ToObject <NotificationsResponse[]>())); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository. /// </summary> /// <param name="repositoryId">The Id of the repository.</param> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <param name="options">Options for changing the API response</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> public IObservable <Notification> GetAllForRepository(long repositoryId, NotificationsRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); return(_connection.GetAndFlattenAllPages <Notification>(ApiUrls.Notifications(repositoryId), request.ToParametersDictionary(), options)); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository. /// </summary> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns> public IObservable<Notification> GetAllForRepository(string owner, string name, NotificationsRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); return _connection.GetAndFlattenAllPages<Notification>(ApiUrls.Notifications(owner, name), request.ToParametersDictionary()); }
public async Task <IActionResult> Index(NotificationsRequest model) { var result = await _notificationService.GetNotificationsAsync(model.Page, model.MaxPerPage); var notifications = new PaginatedList <Notification>(result.Data, result.Pagination.Total, result.Pagination.Page, result.Pagination.MaxPerPage); return(View(new NotificationsResponse { Notifications = notifications })); }
public HttpResponseMessage Post([FromBody] NotificationsRequest request) { HttpResponseMessage response; try { NotificationsResponse notificationsResponse = new NotificationsResponse(); notificationsResponse.UserNotifications = new ObservableCollection <TechReady.Common.Models.Notification>(); using (DbModel.TechReadyDbContext ctx = new DbModel.TechReadyDbContext()) { var appUserId = Convert.ToInt32(request.AppUserId); var appUser = (from c in ctx.AppUsers where c.AppUserID == appUserId select c).FirstOrDefault(); if (appUser != null) { foreach (var not in appUser.NotificationsRecieved) { Notification n = new Notification() { NotificationID = not.NotificationID, Read = not.Read, Removed = not.Removed }; if (not.Notification != null) { n.Title = not.Notification.NotificationTitle; n.Message = not.Notification.NotificationMessage; n.PushDateTime = not.Notification.PushDateTime; n.ActionLink = not.Notification.ActionLink; n.NotificationType = (int)not.Notification.TypeOfNotification; n.ResourceId = not.Notification.ResourceId; } notificationsResponse.UserNotifications.Add(n); } } } response = this.Request.CreateResponse(HttpStatusCode.OK, notificationsResponse); response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now.AddSeconds(300)); } catch (Exception ex) { HttpError myCustomError = new HttpError(ex.Message) { { "IsSuccess", false } }; return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, myCustomError)); } return(response); }
public async Task GetNotificationEventsAsync_CallsExpectedUrl() { var testDate = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.FromHours(1)); var request = new NotificationsRequest { ProjectKey = "project", EventsSince = testDate }; var expectedUri = new Uri("api/developers/search_events?projects=project&from=2000-01-01T00:00:00%2b0100", UriKind.RelativeOrAbsolute); await Method_CallsTheExpectedUri(expectedUri, @"{""events"": [] }", (c, t) => c.GetNotificationEventsAsync(request, t)); }
public object Get(NotificationsRequest request) { // Get notifications. var notifications = ResourceManager.NotificationManager.Notifications; // Make as seen. notifications.ToList().ForEach(notification => notification.Seen()); // Return notifications. return notifications; }
public async Task RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; await client.GetAllForCurrent(notificationsRequest); connection.Received().GetAll<Notification>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), Args.ApiOptions); }
public void RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); var notificationsRequest = new NotificationsRequest { All = true }; client.GetAllForCurrent(notificationsRequest); connection.Received().Get<List<Notification>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), null); }
public async Task RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; await client.GetAllForCurrent(notificationsRequest); connection.Received().GetAll <Notification>(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), Args.ApiOptions); }
private static async Task <Result <NotificationsResponse[]> > GetNotificationEventsAsync_WithHttpStatusCode( HttpStatusCode returnedStatusCode) { // Arrange var responseContent = returnedStatusCode == HttpStatusCode.OK ? "{\"events\":[]}" : null; var client = SetupClientWithHttpResponse(returnedStatusCode, responseContent); var request = new NotificationsRequest { ProjectKey = "project", EventsSince = DateTimeOffset.Now }; // Act return(await client.GetNotificationEventsAsync(request, CancellationToken.None)); }
public void RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; client.GetAllForRepository("banana", "split", notificationsRequest); connection.Received().GetAll <Notification>(endpoint, Arg.Is <Dictionary <string, string> >( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), Args.ApiOptions); }
public void RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); var notificationsRequest = new NotificationsRequest { All = true }; client.GetAllForCurrent(notificationsRequest); connection.Received().Get <List <Notification> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), null); }
/// <summary> /// Gets all Notifications for the current user /// </summary> /// <param name="all"></param> /// <param name="participating"></param> /// <returns></returns> public static async Task <ObservableCollection <Notification> > GetAllNotificationsForCurrentUser(bool all, bool participating) { try { var req = new NotificationsRequest { All = all, Participating = participating }; var options = new ApiOptions { PageSize = 100, PageCount = 1 }; return(new ObservableCollection <Notification>(await GlobalHelper.GithubClient.Activity.Notifications.GetAllForCurrent(req, options))); } catch { return(null); } }
public async Task <IList <SonarQubeNotification> > GetNotificationEventsAsync(string projectKey, DateTimeOffset eventsSince, CancellationToken token) { EnsureIsConnected(); var request = new NotificationsRequest { ProjectKey = projectKey, EventsSince = eventsSince }; var eventsResult = await this.sonarqubeClient.GetNotificationEventsAsync(request, token); if (!eventsResult.IsSuccess) { return(eventsResult.StatusCode == HttpStatusCode.NotFound ? null : new List <SonarQubeNotification>()); } return(eventsResult.Value.Select(SonarQubeNotification.FromResponse).ToList()); }
public Task <Result <NotificationsResponse[]> > GetNotificationEventsAsync(NotificationsRequest request, CancellationToken token) { // Since 6.6; internal return(InvokeSonarQubeApi("api/developers/search_events", request, token, async(HttpResponseMessage httpResponse) => { if (httpResponse.StatusCode != HttpStatusCode.OK) { return new NotificationsResponse[0]; } var stringResponse = await GetStringResultAsync(httpResponse, token); return JObject.Parse(stringResponse)["events"].ToObject <NotificationsResponse[]>() ?? new NotificationsResponse[0]; } )); }
/// <summary> /// Gets all Notifications for the current user /// </summary> /// <param name="all"></param> /// <param name="participating"></param> /// <returns></returns> public static async Task <ObservableCollection <Notification> > GetAllNotificationsForCurrentUser(bool all, bool participating) { try { var client = await UserUtility.GetAuthenticatedClient(); NotificationsRequest req = new NotificationsRequest { All = all, Participating = participating }; ApiOptions options = new ApiOptions { PageSize = 100, PageCount = 1 }; return(new ObservableCollection <Notification>(await client.Activity.Notifications.GetAllForCurrent(req, options))); } catch { return(null); } }
public void RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllForCurrent(notificationsRequest, options); connection.Received().GetAll<Notification>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), options); }
public void RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllForCurrent(notificationsRequest, options); connection.Received().GetAll <Notification>(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), options); }
public async Task RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForRepository("banana", "split", notificationsRequest, options); connection.Received().GetAll <Notification>(endpoint, Arg.Is <Dictionary <string, string> >( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), options); }
public NotificationsResponse Get(NotificationsRequest request) { var notifications = ViewContext.Notifications .AsQueryable() .Where(x => x.TargetUserId == TypedSession.UserId) .OrderByDescending(x => x.CreatedAt) .Skip(request.Skip) .Take(request.Take) .ToList() .Distinct(new NotificationTypeComparer()); //Update NotificationsCheckedAt UserCache user = UserCacheService.Get(TypedSession.UserId); user.NotificationsCheckedAt = DateTime.UtcNow; UserCacheService.Set(user.UserId, user); return new NotificationsResponse { Notifications = notifications.Select(x => x.AsNotification()).ToList(), LatestNotificationChecking = user.NotificationsCheckedAt }; }
public async Task GetNotificationEventsAsync_GetEventsFromTheServer() { // Arrange var client = SetupClientWithHttpResponse(HttpStatusCode.OK, @"{""events"": [{""category"":""QUALITY_GATE"", ""message"":""Quality Gate of project 'test' is now Red (was Green)"", ""link"":""http://localhost:9000/dashboard?id=test"", ""project"":""test"", ""date"":""2017-09-14T10:55:19+0200""}]}"); var request = new NotificationsRequest { ProjectKey = "test", EventsSince = DateTimeOffset.Parse("2017-09-14T10:00:00+0200", CultureInfo.InvariantCulture) }; var expected = new NotificationsResponse[] { new NotificationsResponse { Category = "QUALITY_GATE", Message = "Quality Gate of project 'test' is now Red (was Green)", Link = new Uri("http://localhost:9000/dashboard?id=test"), Date = new DateTimeOffset(2017, 9, 14, 10, 55, 19, 0, TimeSpan.FromHours(2)), Project = "test" } }; // Act var result = await client .GetNotificationEventsAsync(request, CancellationToken.None); // Assert result.IsSuccess.Should().BeTrue(); AssertEqual(expected, result.Value); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user. /// </summary> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> public IObservable<Notification> GetAllForCurrent(NotificationsRequest request) { Ensure.ArgumentNotNull(request, "request"); return GetAllForCurrent(request, ApiOptions.None); }
public async void Run(IBackgroundTaskInstance taskInstance) { _deferral = taskInstance.GetDeferral(); var localSettingsValues = ApplicationData.Current.LocalSettings.Values; WinSecureStorageBase.StoragePassword = "******"; //Octokit var client = new GitHubClient(new ProductHeaderValue("gitit")); if (CrossSecureStorage.Current.HasKey("OAuthToken")) { client.Credentials = new Credentials(CrossSecureStorage.Current.GetValue("OAuthToken")); var notificationRequest = new NotificationsRequest { Since = DateTimeOffset.Now.Subtract(new TimeSpan(0, int.Parse(localSettingsValues["BackgroundTaskTime"].ToString()), 0)) }; var notifications = await client.Activity.Notifications.GetAllForCurrent(notificationRequest); foreach (var notification in notifications) { _toastTitle = $"{notification.Subject.Title}"; _toastContent = $"in {notification.Repository.FullName} ({Convert.ToDateTime(notification.UpdatedAt).Humanize()})"; #region Toast-Notification Payload //Reference: https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/07/08/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10/ //Body of toast var toastVisual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = _toastTitle }, new AdaptiveText() { Text = _toastContent }, } } }; //Interactive buttons to Toast var toastActions = new ToastActionsCustom() { Buttons = { new ToastButton("Mark As Read", new QueryString() { { "action", "markAsRead" }, { "notificationId", notification.Id } }.ToString()) { ActivationType = ToastActivationType.Background } } }; var toastContent = new ToastContent() { Visual = toastVisual, Actions = toastActions, Launch = new QueryString() { { "notificationId", notification.Id } }.ToString() }; #endregion #region Tile Payload // https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/06/30/adaptive-tile-templates-schema-and-documentation/ var tileContent = new TileContent() { Visual = new TileVisual() { Branding = TileBranding.NameAndLogo, TileMedium = new TileBinding() { Content = new TileBindingContentAdaptive() { Children = { new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { Children = { new AdaptiveText() { Text = _toastTitle, HintWrap = true, HintStyle = AdaptiveTextStyle.Body }, new AdaptiveText() { Text = _toastContent, HintWrap = true, HintStyle = AdaptiveTextStyle.CaptionSubtle } } } } } } } }, TileWide = new TileBinding() { Content = new TileBindingContentAdaptive() { Children = { CreateGroup(_toastTitle, _toastContent) } } }, TileLarge = new TileBinding() { Content = new TileBindingContentAdaptive() { Children = { CreateGroup(_toastTitle, _toastContent) } } } } }; #endregion var toast = new ToastNotification(toastContent.GetXml()) { Tag = "1" }; ToastNotificationManager.CreateToastNotifier().Show(toast); // Update tile var tileNotification = new TileNotification(tileContent.GetXml()); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); } } _deferral.Complete(); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository. /// </summary> /// <param name="repositoryId">The Id of the repository.</param> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <param name="options">Options for changing the API response</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> public IObservable<Notification> GetAllForRepository(int repositoryId, NotificationsRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages<Notification>(ApiUrls.Notifications(repositoryId), request.ToParametersDictionary(), options); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository. /// </summary> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns> public IObservable <Notification> GetAllForRepository(string owner, string name, NotificationsRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); return(_connection.GetAndFlattenAllPages <Notification>(ApiUrls.Notifications(owner, name), request.ToParametersDictionary())); }
/// <summary> /// 通知を取得しバルーンチップを表示 /// </summary> private async void GetNotifications(object state) { GitHubClient client = (GitHubClient)state; NotificationsRequest request = new NotificationsRequest(); if (Properties.Settings.Default.LastCheckedTime == new DateTime(1753, 1, 1)) { request.Since = new DateTimeOffset(DateTime.Now); } else { request.Since = new DateTimeOffset(Properties.Settings.Default.LastCheckedTime); } DateTime requestDateTime = DateTime.Now; IReadOnlyList <Notification> notifications; try { notifications = await client.Activity.Notifications.GetAllForCurrent(request); } catch { hasError = true; string errorTitle = Properties.Resources.NotificationErrorTitle; string errorText = Properties.Resources.NotificationErrorText; ((App)App.Current).notifyIcon.ShowBalloonTip(balloonTimeout, errorTitle, errorText, ToolTipIcon.Error); Stop(); return; } hasError = false; // 問い合わせ時刻を保存 Properties.Settings.Default.LastCheckedTime = requestDateTime; Properties.Settings.Default.Save(); foreach (Notification notification in notifications) { string strTitle = $"{notification.Repository.FullName} {notification.Subject.Title}"; string strText; switch (notification.Reason) { case "assign": strText = Properties.Resources.AssignText; break; case "author": strText = Properties.Resources.AuthorText; break; case "comment": strText = Properties.Resources.CommentText; break; case "invitation": strText = Properties.Resources.CommentText; break; case "manual": strText = Properties.Resources.ManualText; break; case "mention": strText = Properties.Resources.MentionText; break; case "review_requested": strText = Properties.Resources.ReviewRequestedText; break; case "security_alert": strText = Properties.Resources.SecurityAlertText; break; case "state_change": strText = Properties.Resources.StateChangeText; break; case "subscribed": strText = Properties.Resources.SubscribedText; break; case "team_mention": strText = Properties.Resources.TeamMentionText; break; default: continue; } linkUrl = notification.Subject.Url; ((App)App.Current).notifyIcon.ShowBalloonTip(balloonTimeout, strTitle, strText, ToolTipIcon.Info); } }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository. /// </summary> /// <param name="repositoryId">The Id of the repository.</param> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> public IObservable<Notification> GetAllForRepository(int repositoryId, NotificationsRequest request) { Ensure.ArgumentNotNull(request, "request"); return GetAllForRepository(repositoryId, request, ApiOptions.None); }
public async Task RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForRepository("banana", "split", notificationsRequest, options); connection.Received().GetAll<Notification>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), options); }
public void RequestsCorrectUrlNotificationRequestWithApiOptionsWithRepositoryId() { var endpoint = new Uri("repositories/1/notifications", UriKind.Relative); var connection = Substitute.For<IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableNotificationsClient(gitHubClient); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllForRepository(1, notificationsRequest, options); connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 4 && d["all"] == "true" && d["participating"] == "false" && d["page"] == "1" && d["per_page"] == "1"), null); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user. /// </summary> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns> public IObservable <Notification> GetAllForCurrent(NotificationsRequest request) { Ensure.ArgumentNotNull(request, "request"); return(GetAllForCurrent(request, ApiOptions.None)); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository. /// </summary> /// <param name="owner">The owner of the repository.</param> /// <param name="name">The name of the repository.</param> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns> public IObservable <Notification> GetAllForRepository(string owner, string name, NotificationsRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); return(GetAllForRepository(owner, name, request, ApiOptions.None)); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository. /// </summary> /// <param name="owner">The owner of the repository.</param> /// <param name="name">The name of the repository.</param> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> public IObservable<Notification> GetAllForRepository(string owner, string name, NotificationsRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); return GetAllForRepository(owner, name, request, ApiOptions.None); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository. /// </summary> /// <param name="repositoryId">The Id of the repository.</param> /// <param name="request">Specifies the parameters to filter notifications by</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> public IObservable <Notification> GetAllForRepository(long repositoryId, NotificationsRequest request) { Ensure.ArgumentNotNull(request, "request"); return(GetAllForRepository(repositoryId, request, ApiOptions.None)); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user. /// </summary> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns> public IObservable<Notification> GetAllForCurrent(NotificationsRequest request) { Ensure.ArgumentNotNull(request, "request"); return _connection.GetAndFlattenAllPages<Notification>(ApiUrls.Notifications(), request.ToParametersDictionary()); }
public void RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; client.GetAllForRepository("banana", "split", notificationsRequest); connection.Received().GetAll<Notification>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), Args.ApiOptions); }