/// <summary> /// Update a v1 notification /// </summary> /// <param name="notification">Entity containing the v1 data of the notification to update</param> public void UpdateNotification(UpdateNotificationV1 notification) { const string FunctionAdmin = "updateNotification"; const string Function = "notification"; if (notification.Published.HasValue && isAdminConnection) { throw new Exception("Published cannot be updated through admin connection. Use " + (notification.Published.Value ? "PublishNotification" : "DeleteNotification")); } notification.Check(isAdminConnection); // update with only ID and Puplished should be possible! UpdateNotificationRequest request = new UpdateNotificationRequest() { notificationId = notification.NotificationId, message = notification.Message, timespans = (notification.Timespans == null || notification.Timespans.Count() == 0) ? new UpdateNotificationRequest.Timespan[] { } : notification.Timespans.Select(t => new UpdateNotificationRequest.Timespan() { start = t.Start.AsString(), end = t.End.AsString() }).ToArray(), data = notification.Data, matchRange = notification.MatchRange, published = notification.Published }; HttpWebRequest webRequest = GetWebRequestAndSendRequest("PUT", isAdminConnection ? FunctionAdmin : Function, request, null, isAdminConnection ? null : notification.NotificationId); UpdateNotificationResponse response = GetJSONresponse <UpdateNotificationResponse>(webRequest); response.Check(); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateNotificationResponse response = new UpdateNotificationResponse(); return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateNotificationResponse response = new UpdateNotificationResponse(); return response; }
public UpdateNotificationResponse UpdateNotificationMessage(RepeatedField <string> Notification_Ids, RepeatedField <Int64> TimeStampsMS) { var request = new Request { RequestType = RequestType.UpdateNotificationStatus, RequestMessage = ((IMessage) new UpdateNotificationMessage { NotificationIds = { Notification_Ids }, CreateTimestampMs = { TimeStampsMS }, State = NotificationState.Viewed }).ToByteString() }; UpdateNotificationResponse response = PostProtoPayloadCommonR <Request, UpdateNotificationResponse>(request).Result; return(response); }
public static void ProcessGetInboxResponse(Client client, GetInboxResponse getInboxResponse) { var notification_count = getInboxResponse.Inbox.Notifications.Count(); switch (getInboxResponse.Result) { case GetInboxResponse.Types.Result.Unset: break; case GetInboxResponse.Types.Result.Failure: Logger.Error($"There was an error, viewing your notifications!"); break; case GetInboxResponse.Types.Result.Success: if (getInboxResponse.Inbox.Notifications.Count > 0) { Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"We got {notification_count} new notification(s):"); int i = 1; // We do not want to show then "Notification #0" RepeatedField <string> notificationIDs = new RepeatedField <string>(); RepeatedField <Int64> createTimestampMsIDs = new RepeatedField <Int64>(); foreach (var notification in getInboxResponse.Inbox.Notifications) { string created_time = Utils.TimeMStoString(notification.CreateTimestampMs, "0:MM/dd/yy H:mm:ss"); string expires_time = Utils.TimeMStoString(notification.ExpireTimeMs, "0:MM/dd/yy H:mm:ss"); string log_response = $"Notification: #{i} (Created on: {created_time} | Expires: {expires_time}) " + $"ID: {notification.NotificationId} | Title: {notification.TitleKey} | Category: {notification.Category} | " + $"Variables: {notification.Variables} | Labels: {notification.Labels}"; Logger.ColoredConsoleWrite(ConsoleColor.Cyan, log_response); notificationIDs.Add(notification.NotificationId); createTimestampMsIDs.Add(notification.CreateTimestampMs); i++; } client.LastTimePlayedTs = Utils.GetTime(); UpdateNotificationResponse updateNotificationResponse = client.Misc.UpdateNotificationMessage(notificationIDs, createTimestampMsIDs); Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"Info: Notifications {updateNotificationResponse.State}"); // For future use: GYM_REMOVAL_7140377d6634458eb73a6640f1c8de maybe check on what notification we recieved? Ex: Pokemon kicked out of gym } break; } }
public async static void ProcessGetInboxResponse(Client client, GetInboxResponse getInboxResponse) { var notifcation_count = getInboxResponse.Inbox.Notifications.Count(); switch (getInboxResponse.Result) { case GetInboxResponse.Types.Result.Unset: break; case GetInboxResponse.Types.Result.Failure: APIConfiguration.Logger.InboxStatusUpdate($"There was an error, viewing your notifications!", ConsoleColor.Red); break; case GetInboxResponse.Types.Result.Success: if (getInboxResponse.Inbox.Notifications.Count > 0) { APIConfiguration.Logger.InboxStatusUpdate($"We got {notifcation_count} new notification(s).", ConsoleColor.Magenta); RepeatedField <string> notificationIDs = new RepeatedField <string>(); RepeatedField <string> categorieIDs = new RepeatedField <string>(); RepeatedField <Int64> createTimestampMsIDs = new RepeatedField <Int64>(); foreach (var notification in getInboxResponse.Inbox.Notifications) { notificationIDs.Add(notification.NotificationId); createTimestampMsIDs.Add(notification.CreateTimestampMs); categorieIDs.Add(notification.Category); } NotificationState notificationState = NotificationState.Viewed; //await client.Misc.OptOutPushNotificationCategory(categorieIDs).ConfigureAwait(false); UpdateNotificationResponse updateNotificationResponse = await client.Misc.UpdateNotification(notificationIDs, createTimestampMsIDs, notificationState).ConfigureAwait(false); APIConfiguration.Logger.InboxStatusUpdate($"Notifications {updateNotificationResponse.State}.", ConsoleColor.Magenta); } break; } }