using Apewer;
using System;
using System.Collections.Generic;
using System.Reflection;

namespace Apewer.Run
{

    class ApiClient
    {

        static void Write(params object[] objects) => Console.WriteLine(TextUtility.Join(",", objects));
        static void Succeed(Json json) => Console.WriteLine(json.ToString(true));
        static void Failed(string message) => Console.WriteLine(message);

        public ApiClient()
        {
            var client = new Apewer.Web.ApiClient();
            client.ApiUrl = "http://agent.niutax.com/";
            client.UserAgent = Assembly.GetExecutingAssembly().FullName;

            var args = new TextSet();
            args["ext"] = "zip";

            var data = StorageUtility.ReadFile(@"D:\temp\aria2.su.tozip.zip");

            client.Post("AppUpdater", "UploadFile", args, data, Succeed, Failed);
            // client.Get("Common", "GetRequest", dict, (r) => { Write("Succeed", r.ToString(true)); }, (msg) => { Write("Failed", msg); });
            // var result = client.Post("Common", "GetRequest", data, (r) => { Write("Succeed", r.ToString(true)); }, (msg) => { Write("Failed", msg); });
        }

    }

}