HubspotAPIWrapper.BaseClass.Call C# (CSharp) Method

Call() protected method

protected Call ( string subpath, string method = "GET", string query = "", string contentType = "application/text", string data = "", string>.Dictionary optionalParams = null, string other = "" ) : System.Json.JsonObject
subpath string
method string
query string
contentType string
data string
optionalParams string>.Dictionary
other string
return System.Json.JsonObject
        protected JsonObject Call(string subpath, string method = "GET", string query = "", string contentType = "application/text",
                                  string data = "", Dictionary<string, string> optionalParams = null, string other = "")
        {
            string uri;

            if (_accessToken != null)
            {
                uri = String.Format("https://{0}/{1}?access_token={2}", _options["api_base"],
                                    GetPath(subpath), _accessToken);
            }
            else
            {
                uri = String.Format("https://{0}/{1}?hapikey={2}", _options["api_base"],
                                    GetPath(subpath), _apiKey);
            }

            if (query.Length > 0)
            {
                uri = string.Format("{0}&q={1}", uri, query);
            }

            if (other.Length > 0)
            {
                uri = string.Format("{0}&{1}", uri, other);
            }

            if (optionalParams != null)
            {
                uri = optionalParams.Aggregate(uri,
                                               (current, optionalParam) =>
                                               string.Format("{0}&{1}={2}", current, optionalParam.Key,
                                                             optionalParam.Value));
            }
            Debug.WriteLine(uri);
            var returnVal = UserWebClient.UploadString(uri, method: method, contentType: contentType, data: data);

            if (returnVal != null)
            {
                if (returnVal.Length > 0)
                {
                    return new JsonObject(JsonValue.Parse(returnVal));
                }
            }

            return new JsonObject();
        }