コード例 #1
0
ファイル: helpers.cs プロジェクト: groupvine/gv-api
    static public GvApiRequest makeRequest(string rqstType, string rqstId,
                                           string context, string contextKey,
                                           object rqstData)
    {
        string date = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
        string hash = GvApiHelpers.generateHash(context, contextKey, date);

        GvApiAuth auth = new GvApiAuth(date, hash);

        return(new GvApiRequest(rqstType, rqstId, auth, rqstData));
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: groupvine/gv-api
        //////////////////////////////////////////////////////////////////////////
        //
        // API Request convenience functions
        //
        //////////////////////////////////////////////////////////////////////////

        public async Task <string> apiRequest(string rqstType, string rqstId, object data,
                                              string accountKey = GvAccountConsts.accountApiKey)
        {
            GvApiRequest rqst = GvApiHelpers.makeRequest(rqstType, rqstId,
                                                         GvAccountConsts.accountAbbrev,
                                                         accountKey,
                                                         data);

            HttpResponseMessage respMsg = await httpClient.PostAsJsonAsync(GvAccountConsts.hostUrl, rqst);

            string respStr = await respMsg.Content.ReadAsStringAsync();

            // Uncomment for debugging with raw response
            // Console.WriteLine("Response str: " + respStr);

            return(respStr);
        }