Пример #1
0
        // TODO : add parameters
        public static async Task <Entries> Read(string sectionID)
        {
            /*
             * {
             * "code" : 200,
             * "message" : "",
             * "error_parameters" : {},
             * "rest_of_api" : 4988,
             * "results" : {
             *  "reports" : [],
             *  "rows" : [
             *          {
             *                  "entry_id" : 1352827,
             *                  "entry_date" : 20110817.0001,
             *                  "l_account" : "expenses",
             *                  "l_account_id" : "x20",
             *                  "r_account" : "assets",
             *                  "r_account_id" : "x4",
             *                  "item" : "후원(과장학금)",
             *                  "money" : 10000,
             *                  "total" : 840721.99
             *                  "memo" : "",
             *                  "app_id" : 0
             *          },
             *          {
             *                  "entry_id" : 1352823,
             *                  "entry_date" : 20110813.0001,
             *                  "l_account" : "assets",
             *                  "l_account_id" : "x3",
             *                  "r_account" : "assets",
             *                  "r_account_id" : "x4",
             *                  "item" : "계좌이체",
             *                  "money" : 10000,
             *                  "total" : 840721.99
             *                  "memo" : "",
             *                  "app_id" : 0
             *          }
             *  ]
             * }
             * }            */

            DateTime endDate   = DateTime.Today;
            DateTime startDate = endDate.AddDays(-20);

            var uri = $"{urlReadEntries}?section_id={sectionID}&start_date={startDate.ToString("yyyyMMdd")}&end_date={endDate.ToString("yyyyMMdd")}";

            var result = await RESTInvoker.Invoke <Entries>(RestMethod.GET, uri, string.Empty);

            if (result == null ||
                result.Results == null)
            {
                return(new Entries());
            }

            return(result.Results);
        }
Пример #2
0
        public async Task <Accounts> ReadAll(string sectionID)
        {
            var uri    = urlAccounts + "?section_id=" + sectionID;
            var result = await RESTInvoker.Invoke <Accounts>(RestMethod.GET, uri, string.Empty);

            if (result == null ||
                result.Results == null)
            {
                return(null);
            }

            AllAccounts = result.Results;
            return(result.Results);
        }
Пример #3
0
        public async Task <string> GetToken()
        {
            Status = AuthStatus.Authenticating;

            var uri    = urlReqeustToken + "?app_id=" + appID + "&app_secret=" + alkjdflkasdf;
            var result = await RESTInvoker.Invoke(RestMethod.GET, uri);

            if (result["token"] == null)
            {
                SubsystemUtils.Instance.Err("GetToken is failed!!!");
                Status = AuthStatus.AuthFailed;
            }

            tmpToken = result["token"]?.ToString();
            return(tmpToken);
        }
Пример #4
0
        public async Task <string> GetAccessToken(string pin)
        {
            Status = AuthStatus.Authenticating;

            var uri    = urlGetAccessToken + "?app_id=" + appID + "&app_secret=" + alkjdflkasdf + "&token=" + tmpToken + "&pin=" + pin;
            var result = await RESTInvoker.Invoke(RestMethod.GET, uri);

            if (result["token"] == null)
            {
                Status = AuthStatus.AuthFailed;
                SubsystemUtils.Instance.Err("GetAccessToken is failed!!!");
            }
            else
            {
                Status = AuthStatus.AuthSuccess;
                //SubsystemUtils.Instance.Err("GetAccessToken is succeed!!!");
                tmpToken = null;
            }

            accessToken  = result["token"]?.ToString();
            accessTokenS = result["token_secret"]?.ToString();
            return(result["user_id"].ToString());
        }
        public async Task <UserData> Read()
        {
            /*
             * {
             *          "code" : 200,
             *          "message" : "",
             *          "error_parameters" : {},
             *          "rest_of_api" : 4988,
             *          "results" : {
             *                  "user_id" : 27,
             *                  "username" : "Helloman",
             *                  "last_ip" : "192.168.0.1",
             *                  "last_login_timestamp" : 1322448931,
             *                  "created_timestamp" : 1321448931,
             *                  "modified_timestamp" : 1321448931,
             *                  "language" : "ko",
             *                  "level" : "1",
             *                  "expire" : 1321448931,
             *                  "timezone" : "Asia/Seoul",
             *                  "currency" : "KRW",
             *                  "country" : "KR",
             *                  "image_url" : "https://s3-ap-northeast-1.amazonaws.com/whooingprofile/p27.jpg",
             *                  "mileage" : 230
             *          }
             *  }    */

            var result = await RESTInvoker.Invoke <UserData>(RestMethod.GET, urlReadUser, string.Empty);

            if (result == null ||
                result.Results == null)
            {
                return(null);
            }

            return(result.Results);
        }