summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-06-02 18:22:04 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-06-02 18:22:04 -0400
commitde74b038e4c15d393de8828c89814ef7eaefe507 (patch)
tree811f095ed6d95a0d08da8511b6ccc0b5e9dc7825 /src
parentb6cda8f0d32898f34b5c7dc703a85aa823c317ce (diff)
downloadSMAPI-de74b038e4c15d393de8828c89814ef7eaefe507.tar.gz
SMAPI-de74b038e4c15d393de8828c89814ef7eaefe507.tar.bz2
SMAPI-de74b038e4c15d393de8828c89814ef7eaefe507.zip
move web API client into toolkit (#532)
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Internal/SMAPI.Internal.projitems2
-rw-r--r--src/SMAPI.Web/Controllers/ModsApiController.cs2
-rw-r--r--src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs2
-rw-r--r--src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs2
-rw-r--r--src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs2
-rw-r--r--src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs2
-rw-r--r--src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs2
-rw-r--r--src/SMAPI/Constants.cs16
-rw-r--r--src/SMAPI/Program.cs4
-rw-r--r--src/SMAPI/SemanticVersion.cs19
-rw-r--r--src/SMAPI/StardewModdingAPI.csproj1
-rw-r--r--src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModInfoModel.cs (renamed from src/SMAPI.Internal/Models/ModInfoModel.cs)4
-rw-r--r--src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModSeachModel.cs (renamed from src/SMAPI.Internal/Models/ModSeachModel.cs)4
-rw-r--r--src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/WebApiClient.cs (renamed from src/SMAPI/Framework/WebApiClient.cs)7
14 files changed, 35 insertions, 34 deletions
diff --git a/src/SMAPI.Internal/SMAPI.Internal.projitems b/src/SMAPI.Internal/SMAPI.Internal.projitems
index 33b8cbfa..54b12003 100644
--- a/src/SMAPI.Internal/SMAPI.Internal.projitems
+++ b/src/SMAPI.Internal/SMAPI.Internal.projitems
@@ -12,8 +12,6 @@
<Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\ColorfulConsoleWriter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EnvironmentUtility.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\LogLevel.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)Models\ModInfoModel.cs" />
- <Compile Include="$(MSBuildThisFileDirectory)Models\ModSeachModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\MonitorColorScheme.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Platform.cs" />
</ItemGroup>
diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs
index fc90d067..1ec855d5 100644
--- a/src/SMAPI.Web/Controllers/ModsApiController.cs
+++ b/src/SMAPI.Web/Controllers/ModsApiController.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
-using StardewModdingAPI.Internal.Models;
+using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
using StardewModdingAPI.Web.Framework.Clients.Chucklefish;
using StardewModdingAPI.Web.Framework.Clients.GitHub;
using StardewModdingAPI.Web.Framework.Clients.Nexus;
diff --git a/src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs
index bd27d624..4a4a40cd 100644
--- a/src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs
+++ b/src/SMAPI.Web/Framework/ModRepositories/BaseRepository.cs
@@ -1,6 +1,6 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-using StardewModdingAPI.Internal.Models;
+using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
namespace StardewModdingAPI.Web.Framework.ModRepositories
{
diff --git a/src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs
index 2782e2b9..e6074a60 100644
--- a/src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs
+++ b/src/SMAPI.Web/Framework/ModRepositories/ChucklefishRepository.cs
@@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
-using StardewModdingAPI.Internal.Models;
+using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
using StardewModdingAPI.Web.Framework.Clients.Chucklefish;
namespace StardewModdingAPI.Web.Framework.ModRepositories
diff --git a/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs
index f4abd379..1d7e4fff 100644
--- a/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs
+++ b/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs
@@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
-using StardewModdingAPI.Internal.Models;
+using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
using StardewModdingAPI.Web.Framework.Clients.GitHub;
namespace StardewModdingAPI.Web.Framework.ModRepositories
diff --git a/src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs
index 79fe8f87..4c879c8d 100644
--- a/src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs
+++ b/src/SMAPI.Web/Framework/ModRepositories/IModRepository.cs
@@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
-using StardewModdingAPI.Internal.Models;
+using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
namespace StardewModdingAPI.Web.Framework.ModRepositories
{
diff --git a/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs
index 87a87ab7..6cac6b8f 100644
--- a/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs
+++ b/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs
@@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
-using StardewModdingAPI.Internal.Models;
+using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
using StardewModdingAPI.Web.Framework.Clients.Nexus;
namespace StardewModdingAPI.Web.Framework.ModRepositories
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index bdbd5fbb..786c1a39 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -38,10 +38,10 @@ namespace StardewModdingAPI
** Public
****/
/// <summary>SMAPI's current semantic version.</summary>
- public static ISemanticVersion ApiVersion { get; } = new SemanticVersion("2.6-beta.15");
+ public static ISemanticVersion ApiVersion { get; }
/// <summary>The minimum supported version of Stardew Valley.</summary>
- public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.3.13");
+ public static ISemanticVersion MinimumGameVersion { get; }
/// <summary>The maximum supported version of Stardew Valley.</summary>
public static ISemanticVersion MaximumGameVersion { get; } = null;
@@ -70,6 +70,9 @@ namespace StardewModdingAPI
/****
** Internal
****/
+ /// <summary>SMAPI's current semantic version as a mod toolkit version.</summary>
+ internal static Toolkit.ISemanticVersion ApiVersionForToolkit { get; }
+
/// <summary>The URL of the SMAPI home page.</summary>
internal const string HomePageUrl = "https://smapi.io";
@@ -104,6 +107,15 @@ namespace StardewModdingAPI
/*********
** Internal methods
*********/
+ /// <summary>Initialise the static values.</summary>
+ static Constants()
+ {
+ Constants.ApiVersionForToolkit = new Toolkit.SemanticVersion("2.6-beta.15");
+ Constants.MinimumGameVersion = new GameVersion("1.3.13");
+
+ Constants.ApiVersion = new SemanticVersion(Constants.ApiVersionForToolkit);
+ }
+
/// <summary>Get metadata for mapping assemblies to the current platform.</summary>
/// <param name="targetPlatform">The target game platform.</param>
internal static PlatformAssemblyMap GetAssemblyMap(Platform targetPlatform)
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index d5f5fdcd..b7b4dfc7 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -26,7 +26,7 @@ using StardewModdingAPI.Framework.ModLoading;
using StardewModdingAPI.Framework.Reflection;
using StardewModdingAPI.Framework.Serialisation;
using StardewModdingAPI.Internal;
-using StardewModdingAPI.Internal.Models;
+using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
using StardewModdingAPI.Toolkit.Utilities;
using StardewValley;
using Monitor = StardewModdingAPI.Framework.Monitor;
@@ -561,7 +561,7 @@ namespace StardewModdingAPI
new Thread(() =>
{
// create client
- WebApiClient client = new WebApiClient(this.Settings.WebApiBaseUrl, Constants.ApiVersion);
+ WebApiClient client = new WebApiClient(this.Settings.WebApiBaseUrl, Constants.ApiVersionForToolkit);
this.Monitor.Log("Checking for updates...", LogLevel.Trace);
// check SMAPI version
diff --git a/src/SMAPI/SemanticVersion.cs b/src/SMAPI/SemanticVersion.cs
index 3ee3ccf3..c4dd1912 100644
--- a/src/SMAPI/SemanticVersion.cs
+++ b/src/SMAPI/SemanticVersion.cs
@@ -54,6 +54,13 @@ namespace StardewModdingAPI
public SemanticVersion(Version version)
: this(new Toolkit.SemanticVersion(version)) { }
+ /// <summary>Construct an instance.</summary>
+ /// <param name="version">The underlying semantic version implementation.</param>
+ internal SemanticVersion(Toolkit.ISemanticVersion version)
+ {
+ this.Version = version;
+ }
+
/// <summary>Whether this is a pre-release version.</summary>
public bool IsPrerelease()
{
@@ -146,17 +153,5 @@ namespace StardewModdingAPI
parsed = null;
return false;
}
-
-
- /*********
- ** Private methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="version">The underlying semantic version implementation.</param>
- private SemanticVersion(Toolkit.ISemanticVersion version)
- {
- this.Version = version;
- }
-
}
}
diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj
index 96b3aa5b..a5ccc62d 100644
--- a/src/SMAPI/StardewModdingAPI.csproj
+++ b/src/SMAPI/StardewModdingAPI.csproj
@@ -279,7 +279,6 @@
<Compile Include="ITranslationHelper.cs" />
<Compile Include="LogLevel.cs" />
<Compile Include="Framework\ModRegistry.cs" />
- <Compile Include="Framework\WebApiClient.cs" />
<Compile Include="IMonitor.cs" />
<Compile Include="Events\ChangeType.cs" />
<Compile Include="Events\ItemStackChange.cs" />
diff --git a/src/SMAPI.Internal/Models/ModInfoModel.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModInfoModel.cs
index 725c88bb..e1a204c6 100644
--- a/src/SMAPI.Internal/Models/ModInfoModel.cs
+++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModInfoModel.cs
@@ -1,7 +1,7 @@
-namespace StardewModdingAPI.Internal.Models
+namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
{
/// <summary>Generic metadata about a mod.</summary>
- internal class ModInfoModel
+ public class ModInfoModel
{
/*********
** Accessors
diff --git a/src/SMAPI.Internal/Models/ModSeachModel.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModSeachModel.cs
index fac72135..c0ee34ea 100644
--- a/src/SMAPI.Internal/Models/ModSeachModel.cs
+++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModSeachModel.cs
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Linq;
-namespace StardewModdingAPI.Internal.Models
+namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
{
/// <summary>Specifies mods whose update-check info to fetch.</summary>
- internal class ModSearchModel
+ public class ModSearchModel
{
/*********
** Accessors
diff --git a/src/SMAPI/Framework/WebApiClient.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/WebApiClient.cs
index e33b2681..277fbeeb 100644
--- a/src/SMAPI/Framework/WebApiClient.cs
+++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/WebApiClient.cs
@@ -2,9 +2,8 @@ using System;
using System.Collections.Generic;
using System.Net;
using Newtonsoft.Json;
-using StardewModdingAPI.Internal.Models;
-namespace StardewModdingAPI.Framework
+namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
{
/// <summary>Provides methods for interacting with the SMAPI web API.</summary>
internal class WebApiClient
@@ -55,9 +54,7 @@ namespace StardewModdingAPI.Framework
/// <param name="content">The body content to post.</param>
private TResult Post<TBody, TResult>(string url, TBody content)
{
- /***
- ** Note: avoid HttpClient for Mac compatibility.
- ***/
+ // note: avoid HttpClient for Mac compatibility
using (WebClient client = new WebClient())
{
Uri fullUrl = new Uri(this.BaseUrl, url);