Example #1
0
        private static RestAPIResponse Core(DataSiftClient client, string command)
        {
            RestAPIResponse response = null;

            switch (command)
            {
            case "validate":
                response = client.Validate(_argsParser.GetParameter <string>("csdl"));
                break;

            case "compile":
                response = client.Compile(_argsParser.GetParameter <string>("csdl"));
                break;

            case "usage":
                UsagePeriod period;

                if (Enum.TryParse(_argsParser.GetParameter <string>("period"), out period))
                {
                    client.Usage(period);
                }
                else
                {
                    client.Usage();
                }

                break;

            case "balance":
                response = client.Balance();
                break;

            case "dpu":
                response = client.Compile(_argsParser.GetParameter <string>("hash"));
                break;

            default:
                throw new ApplicationException("Unrecognised command: " + command);
            }

            return(response);
        }
Example #2
0
        internal static void Run(string username, string apikey)
        {
            var client = new DataSiftClient(username, apikey);

            Console.WriteLine("Running 'Core' example...");

            var compiled = client.Compile("interaction.content contains \"music\"");

            Console.WriteLine("\nCompiled to {0}, DPU = {1}", compiled.Data.hash, compiled.Data.dpu);

            var usage = client.Usage();

            Console.WriteLine("\nUsage report: " + usage.ToJson());

            var dpu = client.DPU(hash: compiled.Data.hash);

            Console.WriteLine("\nDPU report: " + dpu.ToJson());

            var balance = client.Balance();

            Console.WriteLine("\nBalance report: " + balance.ToJson());
        }