Exemplo n.º 1
0
        //Render an image
        public async Task <Stream> RenderAsync(string sceneId, string query, string options)
        {
            RenderQuery    renderQuery = JsonConvert.DeserializeObject <RenderQuery>(query);
            CommandOptions option      = JsonConvert.DeserializeObject <CommandOptions>(options);

            string requestUrl = sceneId + "/render";

            if (option.command == null)
            {
                renderQuery.setupCommand = "";
            }
            else
            {
                renderQuery.setupCommand = option.command;
            }

            renderQuery.data = option.data;

            var    jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json           = jsonSerializer.Serialize(renderQuery);

            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");

            Task <HttpResponseMessage> getResponse = method.RequestAsync("post", requestUrl, content, true);

            HttpResponseMessage resp = await getResponse;

            return(await resp.Content.ReadAsStreamAsync());
        }
Exemplo n.º 2
0
        public HttpResponseMessage Update(string username, string profile)
        {
            string requestUrl = username;

            Profile pro = JsonConvert.DeserializeObject<Profile>(profile);
            var jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json = jsonSerializer.Serialize(pro);
            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = method.Request("put", requestUrl, content);
            return response;
        }
Exemplo n.º 3
0
        public HttpResponseMessage Update(string username, string profile)
        {
            string requestUrl = username;

            Profile       pro            = JsonConvert.DeserializeObject <Profile>(profile);
            var           jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string        json           = jsonSerializer.Serialize(pro);
            StringContent content        = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = method.Request("put", requestUrl, content);

            return(response);
        }
Exemplo n.º 4
0
        public HttpResponseMessage ListJobs(string username, string query)
        {
            string requestUrl = username + "/jobs";

            JobQuery      qry            = JsonConvert.DeserializeObject <JobQuery>(query);
            var           jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string        json           = jsonSerializer.Serialize(qry);
            StringContent content        = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = method.Request("get", requestUrl, content);

            return(response);
        }
Exemplo n.º 5
0
        //List your scenes
        public async Task <HttpResponseMessage> ListScenesAsync(string username, string query)
        {
            string requestUrl = username + "/scenes";

            SceneQuery    queryObj       = JsonConvert.DeserializeObject <SceneQuery>(query);
            var           jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string        json           = jsonSerializer.Serialize(queryObj);
            StringContent content        = new StringContent(json, Encoding.UTF8, "application/json");

            Task <HttpResponseMessage> response = method.RequestAsync("get", requestUrl, content);

            return(await response);
        }
Exemplo n.º 6
0
        public HttpResponseMessage Library(string query)
        {
            string requestUrl = null;

            Query         queryObj       = JsonConvert.DeserializeObject <Query>(query);
            var           jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string        json           = jsonSerializer.Serialize(queryObj);
            StringContent content        = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = method.Request("get", requestUrl, content);

            return(response);
        }
Exemplo n.º 7
0
        //Render an image
        public async Task<Stream> RenderAsync(string sceneId, string query, string options)
        {
            RenderQuery renderQuery = JsonConvert.DeserializeObject<RenderQuery>(query);
            CommandOptions option = JsonConvert.DeserializeObject<CommandOptions>(options);

            string requestUrl = sceneId + "/render";
            if (option.command == null)
                renderQuery.setupCommand = "";
            else
                renderQuery.setupCommand = option.command;

            renderQuery.data = option.data;
            
            var jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json = jsonSerializer.Serialize(renderQuery);

            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");

            Task<HttpResponseMessage> getResponse = method.RequestAsync("post", requestUrl, content, true);

            HttpResponseMessage resp = await getResponse;

            return await resp.Content.ReadAsStreamAsync();
        }
Exemplo n.º 8
0
        public HttpResponseMessage Command(string sceneId, string commandOptions)
        {
            CommandOptions option     = JsonConvert.DeserializeObject <CommandOptions>(commandOptions);
            string         requestUrl = sceneId + "/command/" + option.command;

            var data = new { data = option.data };

            var    jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json;

            if (option.data == null)
            {
                json = "{}";
            }
            else
            {
                json = jsonSerializer.Serialize(data);
            }

            StringContent       content  = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = method.Request("post", requestUrl, content);

            return(response);
        }
Exemplo n.º 9
0
        public HttpResponseMessage Library(string query)
        {
            string requestUrl = null;

            Query queryObj = JsonConvert.DeserializeObject<Query>(query);
            var jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json = jsonSerializer.Serialize(queryObj);
            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = method.Request("get", requestUrl, content);
            return response;
        }
Exemplo n.º 10
0
        public HttpResponseMessage Command(string sceneId, string commandOptions)
        {
            CommandOptions option = JsonConvert.DeserializeObject<CommandOptions>(commandOptions);
            string requestUrl = sceneId + "/command/" + option.command;

            var data = new { data = option.data };

            var jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json;
            if (option.data == null)
                json = "{}";
            else
                json = jsonSerializer.Serialize(data);

            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = method.Request("post", requestUrl, content);

            return response;
        }
Exemplo n.º 11
0
        //List your scenes
        public async Task<HttpResponseMessage> ListScenesAsync(string username, string query)
        {            
            string requestUrl = username + "/scenes";

            SceneQuery queryObj = JsonConvert.DeserializeObject<SceneQuery>(query);
            var jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json = jsonSerializer.Serialize(queryObj);
            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");

            Task<HttpResponseMessage> response = method.RequestAsync("get", requestUrl, content);
            return await response;
        }
Exemplo n.º 12
0
        public HttpResponseMessage ListJobs(string username, string query)
        {
            string requestUrl = username + "/jobs";

            JobQuery qry = JsonConvert.DeserializeObject<JobQuery>(query);
            var jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json = jsonSerializer.Serialize(qry);
            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = method.Request("get", requestUrl, content);
            return response;
        }