Skip to content

Commit 94aa227

Browse files
committed
Make format for API URL more generic (rather than to a single endpoint) to be consistent with other plugins and to allow more easily to use more endpoints in the future (closes #21)
1 parent 1e4d91d commit 94aa227

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

CodeStats/CodeStatsPackage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,15 @@ private static Task ProcessPulses(CancellationTokenSource tokenSource)
438438
bool usesCustomEndpoint = false;
439439
if (String.IsNullOrWhiteSpace(ApiUrl))
440440
{
441-
URL = Constants.ApiMyPulsesEndpoint;
441+
URL = Constants.ApiEndpoint;
442442
}
443443
else
444444
{
445445
URL = ApiUrl;
446446
usesCustomEndpoint = true;
447447
}
448+
if (!URL.EndsWith("my/pulses"))
449+
URL += "my/pulses";
448450
/*client.Headers["User-Agent"] = Constants.PluginUserAgent;
449451
client.Headers["Content-Type"] = "application/json";
450452
client.Headers["Accept"] = "* /*";

CodeStats/ConfigFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ internal void Save()
141141
if (!string.IsNullOrWhiteSpace(ApiKey))
142142
NativeMethods.WritePrivateProfileString("settings", "api_key", ApiKey.Trim(), _configFilepath);
143143

144-
if (ApiUrl == Constants.ApiMyPulsesEndpoint || string.IsNullOrWhiteSpace(ApiUrl))
144+
if (ApiUrl == Constants.ApiEndpoint || string.IsNullOrWhiteSpace(ApiUrl))
145145
{
146146
NativeMethods.WritePrivateProfileString("settings", "api_url", string.Empty, _configFilepath);
147147
}

CodeStats/Constants.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ internal static string EditorVersion {
2121
}
2222
}
2323

24-
internal static string ApiMyPulsesEndpoint = "https://codestats.net/api/my/pulses";
24+
internal static string ApiEndpoint = "https://codestats.net/api/";
2525

2626
internal static string OSVersionString = System.Environment.OSVersion.VersionString;
2727
internal static int OSVersionBuild = System.Environment.OSVersion.Version.Build;
2828

29-
internal enum DetectionType {
29+
internal enum DetectionType
30+
{
3031
EXTENSION_MAPPING,
3132
LEXER_LANGUAGE,
3233
CUSTOM_MAPPING

CodeStats/Forms/SettingsForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private void SettingsForm_Load(object sender, EventArgs e)
2929
chkStats.Checked = _CodeStatsConfigFile.Stats;
3030
if (String.IsNullOrWhiteSpace(_CodeStatsConfigFile.ApiUrl))
3131
{
32-
txtAPIURL.Text = Constants.ApiMyPulsesEndpoint;
32+
txtAPIURL.Text = Constants.ApiEndpoint;
3333
}
3434
else
3535
{
@@ -60,7 +60,7 @@ private void btnOk_Click(object sender, EventArgs e)
6060

6161
//if (true)
6262
//{
63-
if (String.IsNullOrWhiteSpace(txtAPIURL.Text) || txtAPIURL.Text == Constants.ApiMyPulsesEndpoint)
63+
if (String.IsNullOrWhiteSpace(txtAPIURL.Text) || txtAPIURL.Text == Constants.ApiEndpoint)
6464
{
6565
//_CodeStatsConfigFile.ApiUrl = Constants.ApiMyPulsesEndpoint;
6666
_CodeStatsConfigFile.ApiUrl = string.Empty;

0 commit comments

Comments
 (0)