-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Address confusion in client setup We have two methods, WithBearerToken and WithApiKey. The WithApiKey function doesn't work, so remove it. Also, it's easy to mess up the custom environment string. Let's replace with an URI object. # Patch notes for 103.0.3003 These patch notes summarize the changes from version 102.0.2886. Added 2 new APIs: * Changeset.RetrieveChangesetsByProjectID (GET /api/data/projects/{projectId}/changesets) * Project.DeleteProject (DELETE /api/data/projects/{projectId}) Deprecated 1 old APIs: * TaskMetadata.GetTaskMetadata
- Loading branch information
Showing
7 changed files
with
77 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* @author ProjectManager.com <[email protected]> | ||
* | ||
* @copyright 2023-2024 ProjectManager.com, Inc. | ||
* @version 102.0.2949 | ||
* @version 103.0.3003 | ||
* @link https://github.com/projectmgr/projectmanager-sdk-csharp | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*** | ||
* ProjectManager API for C# | ||
* | ||
* (c) 2023-2024 ProjectManager.com, Inc. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author ProjectManager.com <[email protected]> | ||
* @copyright 2023-2024 ProjectManager.com, Inc. | ||
* @link https://github.com/projectmgr/projectmanager-sdk-csharp | ||
*/ | ||
|
||
|
||
|
||
#pragma warning disable CS8618 | ||
|
||
using System; | ||
|
||
namespace ProjectManager.SDK.Models | ||
{ | ||
|
||
/// <summary> | ||
/// A Folder is a named storage location that can contain Files. | ||
/// </summary> | ||
public class ProjectFileFolderDto : ApiModel | ||
{ | ||
|
||
/// <summary> | ||
/// The unique identifier of this Folder. | ||
/// </summary> | ||
public Guid? Id { get; set; } | ||
|
||
/// <summary> | ||
/// The name of this Folder. | ||
/// </summary> | ||
public string Name { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* @author ProjectManager.com <[email protected]> | ||
* | ||
* @copyright 2023-2024 ProjectManager.com, Inc. | ||
* @version 102.0.2949 | ||
* @version 103.0.3003 | ||
* @link https://github.com/projectmgr/projectmanager-sdk-csharp | ||
*/ | ||
|
||
|
@@ -39,15 +39,14 @@ public class ProjectManagerClient : IProjectManagerClient | |
/// <summary> | ||
/// The version of the SDK | ||
/// </summary> | ||
public const string SdkVersion = "102.0.2949"; | ||
public const string SdkVersion = "103.0.3003"; | ||
|
||
private readonly string _apiUrl; | ||
private readonly HttpClient _client; | ||
internal readonly JsonSerializerOptions _options; | ||
|
||
private string _appName; | ||
private string _bearerToken; | ||
private string _apiKey; | ||
|
||
/// <summary> | ||
/// API methods related to ApiKey | ||
|
@@ -243,19 +242,24 @@ public class ProjectManagerClient : IProjectManagerClient | |
/// <summary> | ||
/// Internal constructor for the client. You should always begin with `WithEnvironment()` or `WithCustomEnvironment`. | ||
/// </summary> | ||
/// <param name="url"></param> | ||
/// <param name="baseEndpoint">The API endpoint to contact</param> | ||
/// <param name="clientHandler">Handler for the HTTP client, when null the default handler will be used</param> | ||
private ProjectManagerClient(string url, HttpClientHandler clientHandler) | ||
private ProjectManagerClient(Uri baseEndpoint, HttpClientHandler clientHandler) | ||
{ | ||
// Throw error if not HTTPS | ||
if (baseEndpoint.Scheme != "https") | ||
{ | ||
throw new InvalidOperationException("Invalid environment url. Please ensure the environment url starts with 'https://'"); | ||
} | ||
|
||
// Add support for HTTP compression | ||
var handler = clientHandler ?? new HttpClientHandler(); | ||
handler.AutomaticDecompression = DecompressionMethods.GZip; | ||
|
||
// We intentionally use a single HttpClient object for the lifetime of this API connection. | ||
// Best practices: https://bytedev.medium.com/net-core-httpclient-best-practices-4c1b20e32c6 | ||
_client = new HttpClient(handler); | ||
|
||
_apiUrl = url; | ||
_apiUrl = baseEndpoint.ToString(); | ||
ApiKey = new ApiKeyClient(this); | ||
Changeset = new ChangesetClient(this); | ||
Dashboard = new DashboardClient(this); | ||
|
@@ -311,10 +315,10 @@ private ProjectManagerClient(string url, HttpClientHandler clientHandler) | |
/// <returns>The API client to use</returns> | ||
public static ProjectManagerClient WithEnvironment(string env, HttpClientHandler clientHandler = null) | ||
{ | ||
switch (env) | ||
switch (env) | ||
{ | ||
case "production": | ||
return new ProjectManagerClient("https://api.projectmanager.com", clientHandler); | ||
return new ProjectManagerClient(new Uri("https://api.projectmanager.com"), clientHandler); | ||
} | ||
|
||
throw new InvalidOperationException($"Unknown environment: {env}"); | ||
|
@@ -325,17 +329,12 @@ public static ProjectManagerClient WithEnvironment(string env, HttpClientHandler | |
/// an API gateway. Please be careful when using this mode. | ||
/// You should prefer to use `WithEnvironment()` instead wherever possible. | ||
/// </summary> | ||
/// <param name="url">The custom URL to use for this client</param> | ||
/// <param name="customEndpoint">The custom endpoint to use for this client</param> | ||
/// <param name="clientHandler">Optional handler to set specific settings for the HTTP client</param> | ||
/// <returns>The API client to use</returns> | ||
public static ProjectManagerClient WithCustomEnvironment(string url, HttpClientHandler clientHandler = null) | ||
public static ProjectManagerClient WithCustomEnvironment(Uri customEndpoint, HttpClientHandler clientHandler = null) | ||
{ | ||
if (!url.StartsWith("https://")) | ||
{ | ||
throw new InvalidOperationException("Invalid custom environment url. Please ensure the environment url starts with 'https://'"); | ||
} | ||
|
||
return new ProjectManagerClient(url, clientHandler); | ||
return new ProjectManagerClient(customEndpoint, clientHandler); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -359,21 +358,6 @@ public ProjectManagerClient WithAppName(string name) | |
public ProjectManagerClient WithBearerToken(string token) | ||
{ | ||
_bearerToken = token; | ||
_apiKey = null; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Configures this API client to use an API Key. | ||
/// | ||
/// | ||
/// </summary> | ||
/// <param name="apiKey">The API key to use for this API session</param> | ||
/// <returns></returns> | ||
public ProjectManagerClient WithApiKey(string apiKey) | ||
{ | ||
_apiKey = apiKey; | ||
_bearerToken = null; | ||
return this; | ||
} | ||
|
||
|
@@ -408,10 +392,6 @@ public async Task<AstroResult<T>> Request<T>(HttpMethod method, string path, | |
{ | ||
request.Headers.Add("Authorization", "Bearer " + _bearerToken); | ||
} | ||
else if (!string.IsNullOrWhiteSpace(_apiKey)) | ||
{ | ||
request.Headers.Add("Api-Key", _apiKey); | ||
} | ||
|
||
// Construct the request URI and query string | ||
var uriBuilder = new UriBuilder(_apiUrl) | ||
|