public JArray GetNewItems()

in certified-connectors/SurveyMonkey/script.csx [73:98]


    public JArray GetNewItems(JArray items)
    {
        var originalQuery = HttpUtility.ParseQueryString(this.Context.Request.RequestUri.Query);
        var triggerState = originalQuery.Get("triggerstate");
        if (items != null && triggerState != null)
        {
            var listOfOperations = new List<string>() { "OnNewResponseAddedCollector", "OnNewResponseAddedSurvey" };

            if (listOfOperations.Contains(this.Context.OperationId, StringComparer.OrdinalIgnoreCase))
            {
                string serializedExcludeIds = string.Empty;
                var triggerStateExcludes = originalQuery.Get("triggerstate_exclude_ids");
                if (triggerStateExcludes != null)
                {
                    serializedExcludeIds = triggerStateExcludes;
                }
                if (serializedExcludeIds != string.Empty)
                {
                    var excludeIds = new HashSet<string>(serializedExcludeIds.Split(new char[] { ',' }));
                    items = new JArray(items.Where(x => !excludeIds.Contains(x["id"].ToString())));
                }
                items = (items?.Count > 0 ? items : new JArray());
            }
        }
        return items;
    }