new public static SwrveConversationCampaign LoadFromJSON(SwrveSDK sdk, Dictionary <string, object> campaignData, int campaignId, DateTime initialisedTime) { SwrveConversationCampaign campaign = new SwrveConversationCampaign(initialisedTime); campaign.Conversation = SwrveConversation.LoadFromJSON(sdk, campaign, (Dictionary <string, object>)campaignData ["conversation"]); return(campaign); }
/// <summary> /// Load a conversation from a JSON response. /// </summary> /// <param name="campaign"> /// Parent in-app campaign. /// </param> /// <param name="conversationData"> /// JSON object with the conversation data. /// </param> /// <returns> /// Parsed conversation wrapper for native layer. /// </returns> public static SwrveConversation LoadFromJSON(SwrveSDK sdk, SwrveConversationCampaign campaign, Dictionary <string, object> conversationData) { SwrveConversation conversation = new SwrveConversation(sdk, campaign); conversation.Id = MiniJsonHelper.GetInt(conversationData, "id"); List <object> pages = (List <object>)conversationData ["pages"]; for (int i = 0; i < pages.Count; i++) { Dictionary <string, object> page = (Dictionary <string, object>)pages [i]; List <object> contents = (List <object>)page ["content"]; for (int j = 0; j < contents.Count; j++) { Dictionary <string, object> content = (Dictionary <string, object>)contents[j]; if ("image" == (string)content ["type"]) { conversation.ConversationAssets.Add((string)content ["value"]); } } } conversation.Conversation = Json.Serialize(conversationData); if (conversationData.ContainsKey("priority")) { conversation.Priority = MiniJsonHelper.GetInt(conversationData, "priority"); } return(conversation); }