Beispiel #1
0
        public string CreateRule(RulesToAddDTO rulesToAdd)
        {
            SocialOpinionAPI.Core.OAuthInfo oAuth = new Core.OAuthInfo {
                ConsumerKey = _ConsumerKey, ConsumerSecret = _ConsumerSecret
            };
            string json = JsonConvert.SerializeObject(rulesToAdd);
            BearerTokenRequestBuilder rb = new BearerTokenRequestBuilder(oAuth, "POST", _addRuleEndpoint);

            return(rb.Execute(json));
        }
Beispiel #2
0
        public List <FilteredStreamRule> CreateRule(Models.FilteredStream.MatchingRule rule)
        {
            FilteredStreamClient streamClient = new FilteredStreamClient(_oAuthInfo.ConsumerKey, _oAuthInfo.ConsumerSecret);

            RulesToAddDTO addRulesDTO = new RulesToAddDTO();

            addRulesDTO.add.Add(new Add {
                value = rule.Value, tag = rule.tag
            });
            string response = streamClient.CreateRule(addRulesDTO);

            CreateRulesResponseDTO responseDTO = JsonConvert.DeserializeObject <CreateRulesResponseDTO>(response);

            List <FilteredStreamRule> streamRules = new List <FilteredStreamRule>();

            foreach (RuleDTO dto in responseDTO.data)
            {
                streamRules.Add(new FilteredStreamRule {
                    id = dto.id, tag = dto.tag, value = dto.value
                });
            }

            return(streamRules);
        }