/// <summary> /// Gets the count API URL. /// </summary> /// <returns></returns> public virtual Uri GetCountApiUrl(string predicateText = "") { var _version = ApiVersion == -1 ? "" : $"/v{ApiVersion}"; var _uri = new Uri(new Uri($"{BaseAPIUrl}{(BaseAPIUrl.EndsWith("/", StringComparison.OrdinalIgnoreCase) ? "" : "/")}api{_version}/{ApiName}/count").ToString()); return(_uri); }
/// <summary> /// Gets the API URL. /// </summary> /// <param name="httpMethod">The HTTP method.</param> /// <param name="id">The identifier.</param> /// <param name="page">The page.</param> /// <param name="count">The count.</param> /// <param name="apiParams">The API parameters.</param> /// <returns></returns> public virtual Uri GetApiUrl(HttpMethod httpMethod, TIdentifier?id = null, int page = 0, int count = 0, params Tuple <string, string>[] apiParams) { var _version = ApiVersion == -1 ? "" : $"/v{ApiVersion}"; var _id = id == null ? "/" : $"/{id}"; var _pageFilter = _id == "/" ? (page > 0 ? $"/{page}/{count}" : "") : _id; var _uri = new Uri(new Uri($"{BaseAPIUrl}{(BaseAPIUrl.EndsWith("/", StringComparison.OrdinalIgnoreCase) ? "" : "/")}api{_version}/{ApiName}{_pageFilter}").ToString()); return(_uri); }
public StackifyHttpClient(string apiKey, string apiUrl) { if (string.IsNullOrEmpty(apiKey)) { _APIKey = Config.Get("Stackify.ApiKey"); } else { _APIKey = apiKey; } if (string.IsNullOrEmpty(apiUrl)) { string customUrl = Config.Get("Stackify.ApiUrl"); if (!string.IsNullOrWhiteSpace(customUrl)) { BaseAPIUrl = customUrl; } if (BaseAPIUrl == null) { BaseAPIUrl = "https://api.stackify.com/"; } } else { BaseAPIUrl = apiUrl; } _LastIdentityAttempt = DateTime.UtcNow.AddMinutes(-15); if (!BaseAPIUrl.EndsWith("/")) { BaseAPIUrl += "/"; } }