public async Task <Crate> ProcessUserEvents(IContainer container, string curExternalEventPayload) { var media = JsonConvert.DeserializeObject <InstagramMedia>(curExternalEventPayload.Substring(1, curExternalEventPayload.Length - 2)); if (media.Object != "user") { throw new Exception("Unknown event source"); } var instagramEventCM = new InstagramUserEventCM { MediaId = media.MediaData.MediaId, UserId = media.ObjectId, Time = media.Time, SubscriptionId = media.SubscriptionId, ChangedAspect = media.ChangedAspect }; var eventReportContent = new EventReportCM { EventNames = string.Join(",", instagramEventCM.ChangedAspect), ExternalAccountId = instagramEventCM.UserId, EventPayload = new CrateStorage(Crate.FromContent("Instagram user event", instagramEventCM)), Manufacturer = "Instagram" }; ////prepare the event report var curEventReport = Crate.FromContent("Instagram user event", eventReportContent); return(curEventReport); }
public static ContainerExecutionContext FalseInstagramContainerExecutionContext() { var instagramEventCM = new InstagramUserEventCM { MediaId = "123", UserId = "123", ChangedAspect = "test", Time = "123", SubscriptionId = "123" }; var eventReportCrate = new EventReportCM { EventNames = "media", EventPayload = new CrateStorage(Crate.FromContent("Instagram user event", instagramEventCM)) }; var containerExecutionContext = new ContainerExecutionContext { PayloadStorage = new CrateStorage(Crate.FromContent(string.Empty, new OperationalStateCM()), Crate.FromContent("Instagram user event", eventReportCrate)) }; return(containerExecutionContext); }