Skip to content

Commit

Permalink
Release 119 - Enable custom HTTP client (#42)
Browse files Browse the repository at this point in the history
* Enable custom HTTP client

* Update for release 119

* Added documentation
  • Loading branch information
tspence authored Sep 30, 2024
1 parent bbe7387 commit 1ccf8c9
Show file tree
Hide file tree
Showing 23 changed files with 429 additions and 36 deletions.
22 changes: 15 additions & 7 deletions ProjectManagerClient.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>ProjectManager.SDK</id>
<version>117.0.4438</version>
<version>119.0.4625</version>
<title>ProjectManager.SDK</title>
<authors>ProjectManager.com</authors>
<owners>ProjectManager.com, Inc.</owners>
Expand All @@ -14,15 +14,23 @@
<readme>docs/README.md</readme>
<summary>ProjectManager API for DotNet</summary>
<releaseNotes>
# Patch notes for 117.0.4438
# Patch notes for 119.0.4625

These patch notes summarize the changes from version 116.0.4391.
These patch notes summarize the changes from version 117.0.4438.

Added 5 new APIs:
* ProjectVersion.RetrieveProjectVersions (GET /api/data/projects/{projectId}/versions)
* ProjectVersion.DownloadMSProjectXml (GET /api/data/projects/{projectChangeId}/version/download)
* ProjectVersion.RestoreProjectVersion (POST /api/data/projects/{projectId}/version/{version}/restore)
* ProjectVersion.CopyProjectVersion (POST /api/data/projects/{projectId}/version/{version}/copy)
* Risk.CreateRiskExport (POST /api/data/projects/{projectId}/risks/export)

Renamed 1 old APIs:
* Renamed 'TaskMetadata.GetTasksByProjectIDAndForeignKeyID' to 'TaskMetadata.TaskMetadataSearch'

Changes to data models:
* ResourceCreateDto: Added new field `colorName`
* ResourceDto: Added new field `colorName`
* ResourceDto: Added new field `color`
* ResourceUpdateDto: Added new field `colorName`
* TaskDto: Added new field `isLocked`
* TaskDto: Added new field `isMilestone`


</releaseNotes>
Expand Down
6 changes: 3 additions & 3 deletions src/Clients/NotificationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task<AstroResult<string>> DeleteAllNotifications()
/// workspace. Notifications are ephemeral and may be deleted when they are no longer needed. When a user has more
/// than 1,000 pending notifications some old notifications will be deleted automatically.
/// </summary>
/// <param name="id"></param>
/// <param name="id">The unique identifier of the notification to mark read</param>
public async Task<AstroResult<NotificationTimestampDto>> MarkNotificationRead(Guid id)
{
var url = $"/api/data/notifications/{id}/markread";
Expand All @@ -130,7 +130,7 @@ public async Task<AstroResult<NotificationTimestampDto>> ReadAllNotifications()
/// workspace. Notifications are ephemeral and may be deleted when they are no longer needed. When a user has more
/// than 1,000 pending notifications some old notifications will be deleted automatically.
/// </summary>
/// <param name="id"></param>
/// <param name="id">The unique identifier of the notification to mark read</param>
public async Task<AstroResult<string>> DeleteNotification(Guid id)
{
var url = $"/api/data/notifications/delete/{id}";
Expand All @@ -144,7 +144,7 @@ public async Task<AstroResult<string>> DeleteNotification(Guid id)
/// workspace. Notifications are ephemeral and may be deleted when they are no longer needed. When a user has more
/// than 1,000 pending notifications some old notifications will be deleted automatically.
/// </summary>
/// <param name="id"></param>
/// <param name="id">The unique identifier of the notification to mark read</param>
public async Task<AstroResult<string>> MarkNotificationUnread(Guid id)
{
var url = $"/api/data/notifications/{id}/markunread";
Expand Down
89 changes: 89 additions & 0 deletions src/Clients/ProjectVersionClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/***
* 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
*/



using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using ProjectManager.SDK.Interfaces;
using ProjectManager.SDK.Models;


namespace ProjectManager.SDK.Clients
{
/// <summary>
/// API methods related to ProjectVersion
/// </summary>
public class ProjectVersionClient : IProjectVersionClient
{
private readonly ProjectManagerClient _client;

/// <summary>
/// Constructor
/// </summary>
public ProjectVersionClient(ProjectManagerClient client)
{
_client = client;
}

/// <summary>
/// Returns projects versions including version, user who made changes
/// </summary>
/// <param name="projectId">The unique identifier of the Project</param>
public async Task<AstroResult<ProjectVersionDto[]>> RetrieveProjectVersions(Guid projectId)
{
var url = $"/api/data/projects/{projectId}/versions";
return await _client.Request<ProjectVersionDto[]>(HttpMethod.Get, url, null);
}

/// <summary>
/// Exports and returns project version as an MS Project XML attachment
/// </summary>
/// <param name="projectChangeId">Project change Guid</param>
public async Task<AstroResult<byte[]>> DownloadMSProjectXml(Guid projectChangeId)
{
var url = $"/api/data/projects/{projectChangeId}/version/download";
return await _client.Request<byte[]>(HttpMethod.Get, url, null);
}

/// <summary>
/// Restores a Project to the state it was in at a specific Version in time.
///
/// If successful, all changes made to the Project since this Version will be undone and the Project will
/// return to its former state.
/// </summary>
/// <param name="projectId">The unique identifier of the Project to restore</param>
/// <param name="version">The version number to restore to</param>
public async Task<AstroResult<string>> RestoreProjectVersion(Guid projectId, int version)
{
var url = $"/api/data/projects/{projectId}/version/{version}/restore";
return await _client.Request<string>(HttpMethod.Post, url, null);
}

/// <summary>
/// Create a Copy of a Project as of a specific Version, optionally moving it to a new Timezone.
/// </summary>
/// <param name="projectId">The unique identifier of the Project to copy</param>
/// <param name="version">The version number of the Project to copy</param>
/// <param name="timezoneOffset">If specified, sets the default timezone of the newly copied Project to this specified timezone</param>
public async Task<AstroResult<string>> CopyProjectVersion(Guid projectId, int version, int? timezoneOffset = null)
{
var url = $"/api/data/projects/{projectId}/version/{version}/copy";
var options = new Dictionary<string, object>();
if (timezoneOffset != null) { options["timezoneOffset"] = timezoneOffset; }
return await _client.Request<string>(HttpMethod.Post, url, options);
}
}
}
54 changes: 54 additions & 0 deletions src/Clients/RiskClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/***
* 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
*/



using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using ProjectManager.SDK.Interfaces;
using ProjectManager.SDK.Models;


namespace ProjectManager.SDK.Clients
{
/// <summary>
/// API methods related to Risk
/// </summary>
public class RiskClient : IRiskClient
{
private readonly ProjectManagerClient _client;

/// <summary>
/// Constructor
/// </summary>
public RiskClient(ProjectManagerClient client)
{
_client = client;
}

/// <summary>
/// Initiates a new Export action for Risks.
///
/// Returns the identifier of this Risk Export.
/// </summary>
/// <param name="projectId">The unique identifier of the Project for which to export Risks</param>
/// <param name="body">The settings to use for this export action</param>
public async Task<AstroResult<ExportDto>> CreateRiskExport(Guid projectId, RiskExportSettingsDto body)
{
var url = $"/api/data/projects/{projectId}/risks/export";
return await _client.RequestWithBody<ExportDto>(HttpMethod.Post, url, null, body);
}
}
}
8 changes: 7 additions & 1 deletion src/Clients/TaskMetadataClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ public async Task<AstroResult<string>> AddMetadata(Guid taskId, TaskMetadataUpda
return await _client.RequestWithBody<string>(HttpMethod.Put, url, options, body);
}

public async Task<AstroResult<TaskMetadataSearchDto[]>> GetTasksByProjectIDAndForeignKeyID(Guid projectId, string foreignKey = null, bool? isSystem = null)
/// <summary>
/// Get tasks by project ID and foreign key ID
/// </summary>
/// <param name="foreignKey">Foreign Key ID</param>
/// <param name="projectId">Project ID</param>
/// <param name="isSystem">If metadata is for system or customer, isSystem = true is only of ProjectManager</param>
public async Task<AstroResult<TaskMetadataSearchDto[]>> TaskMetadataSearch(Guid projectId, string foreignKey = null, bool? isSystem = null)
{
var url = $"/api/data/projects/{projectId}/tasks/metadata";
var options = new Dictionary<string, object>();
Expand Down
10 changes: 9 additions & 1 deletion src/IProjectManagerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author ProjectManager.com <[email protected]>
*
* @copyright 2023-2024 ProjectManager.com, Inc.
* @version 117.0.4438
* @version 119.0.4625
* @link https://github.com/projectmgr/projectmanager-sdk-csharp
*/

Expand Down Expand Up @@ -120,6 +120,10 @@ public interface IProjectManagerClient
/// </summary>
IProjectTemplateClient ProjectTemplate { get; }
/// <summary>
/// API methods related to ProjectVersion
/// </summary>
IProjectVersionClient ProjectVersion { get; }
/// <summary>
/// API methods related to Resource
/// </summary>
IResourceClient Resource { get; }
Expand All @@ -132,6 +136,10 @@ public interface IProjectManagerClient
/// </summary>
IResourceTeamClient ResourceTeam { get; }
/// <summary>
/// API methods related to Risk
/// </summary>
IRiskClient Risk { get; }
/// <summary>
/// API methods related to Tag
/// </summary>
ITagClient Tag { get; }
Expand Down
6 changes: 3 additions & 3 deletions src/Interfaces/INotificationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public interface INotificationClient
/// workspace. Notifications are ephemeral and may be deleted when they are no longer needed. When a user has more
/// than 1,000 pending notifications some old notifications will be deleted automatically.
/// </summary>
/// <param name="id"></param>
/// <param name="id">The unique identifier of the notification to mark read</param>
Task<AstroResult<NotificationTimestampDto>> MarkNotificationRead(Guid id);

/// <summary>
Expand All @@ -93,7 +93,7 @@ public interface INotificationClient
/// workspace. Notifications are ephemeral and may be deleted when they are no longer needed. When a user has more
/// than 1,000 pending notifications some old notifications will be deleted automatically.
/// </summary>
/// <param name="id"></param>
/// <param name="id">The unique identifier of the notification to mark read</param>
Task<AstroResult<string>> DeleteNotification(Guid id);

/// <summary>
Expand All @@ -103,7 +103,7 @@ public interface INotificationClient
/// workspace. Notifications are ephemeral and may be deleted when they are no longer needed. When a user has more
/// than 1,000 pending notifications some old notifications will be deleted automatically.
/// </summary>
/// <param name="id"></param>
/// <param name="id">The unique identifier of the notification to mark read</param>
Task<AstroResult<string>> MarkNotificationUnread(Guid id);
}
}
60 changes: 60 additions & 0 deletions src/Interfaces/IProjectVersionClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/***
* 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
*/



using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ProjectManager.SDK.Models;


namespace ProjectManager.SDK.Interfaces
{
/// <summary>
/// API methods related to ProjectVersion
/// </summary>
public interface IProjectVersionClient
{

/// <summary>
/// Returns projects versions including version, user who made changes
/// </summary>
/// <param name="projectId">The unique identifier of the Project</param>
Task<AstroResult<ProjectVersionDto[]>> RetrieveProjectVersions(Guid projectId);

/// <summary>
/// Exports and returns project version as an MS Project XML attachment
/// </summary>
/// <param name="projectChangeId">Project change Guid</param>
Task<AstroResult<byte[]>> DownloadMSProjectXml(Guid projectChangeId);

/// <summary>
/// Restores a Project to the state it was in at a specific Version in time.
///
/// If successful, all changes made to the Project since this Version will be undone and the Project will
/// return to its former state.
/// </summary>
/// <param name="projectId">The unique identifier of the Project to restore</param>
/// <param name="version">The version number to restore to</param>
Task<AstroResult<string>> RestoreProjectVersion(Guid projectId, int version);

/// <summary>
/// Create a Copy of a Project as of a specific Version, optionally moving it to a new Timezone.
/// </summary>
/// <param name="projectId">The unique identifier of the Project to copy</param>
/// <param name="version">The version number of the Project to copy</param>
/// <param name="timezoneOffset">If specified, sets the default timezone of the newly copied Project to this specified timezone</param>
Task<AstroResult<string>> CopyProjectVersion(Guid projectId, int version, int? timezoneOffset = null);
}
}
39 changes: 39 additions & 0 deletions src/Interfaces/IRiskClient.cs
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
*/



using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ProjectManager.SDK.Models;


namespace ProjectManager.SDK.Interfaces
{
/// <summary>
/// API methods related to Risk
/// </summary>
public interface IRiskClient
{

/// <summary>
/// Initiates a new Export action for Risks.
///
/// Returns the identifier of this Risk Export.
/// </summary>
/// <param name="projectId">The unique identifier of the Project for which to export Risks</param>
/// <param name="body">The settings to use for this export action</param>
Task<AstroResult<ExportDto>> CreateRiskExport(Guid projectId, RiskExportSettingsDto body);
}
}
8 changes: 7 additions & 1 deletion src/Interfaces/ITaskMetadataClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public interface ITaskMetadataClient
/// <param name="body">The metadata</param>
Task<AstroResult<string>> AddMetadata(Guid taskId, TaskMetadataUpdateDto body, bool? isSystem = null, bool? isOverride = null);

Task<AstroResult<TaskMetadataSearchDto[]>> GetTasksByProjectIDAndForeignKeyID(Guid projectId, string foreignKey = null, bool? isSystem = null);
/// <summary>
/// Get tasks by project ID and foreign key ID
/// </summary>
/// <param name="foreignKey">Foreign Key ID</param>
/// <param name="projectId">Project ID</param>
/// <param name="isSystem">If metadata is for system or customer, isSystem = true is only of ProjectManager</param>
Task<AstroResult<TaskMetadataSearchDto[]>> TaskMetadataSearch(Guid projectId, string foreignKey = null, bool? isSystem = null);
}
}
Loading

0 comments on commit 1ccf8c9

Please sign in to comment.