improved

Changes to Undelete API in Targetprocess 3.11.2

In the version 3.11.2 we introduced ability to restore deleted Projects and Users. It brought some changed to Undelete API.

Here is how it worked before the version 3.11.2:

GET /api/deletedprojects/v1

[
  {
    "id":2,
    "name":"Tau Product - Kanban #1",
    "abbreviation":"TPK",
    "program":
    {
      "id":1,
      "name":"tauLine #1"
    },
    "deleteDate":"2017-05-08T12:46:31",
    "lastEditor":
    {
      "id":1,
      "fullName":"Administrator Administrator"
    }
  }
]
GET /api/v1/users?where=(DeleteDate is not null)

<Users>
  <User ResourceType="User" Id="18">
    <Kind>User</Kind>
    <FirstName>Test</FirstName>
    <LastName>User</LastName>
    <Email>[email protected]</Email>
    <Login>test</Login>
    <CreateDate>2017-05-20T00:01:47</CreateDate>
    <ModifyDate>2017-05-20T00:01:53</ModifyDate>
    <DeleteDate>2017-05-20T00:01:53</DeleteDate>
    <IsActive>true</IsActive>
    <IsAdministrator>false</IsAdministrator>
    <GlobalId>9133db2e-898d-4f02-91b9-c9a784531584</GlobalId>
    <LastLoginDate nil="true"/>
    <WeeklyAvailableHours>40.0000</WeeklyAvailableHours>
    <CurrentAllocation>0</CurrentAllocation>
    <CurrentAvailableHours>40.0000</CurrentAvailableHours>
    <AvailableFrom>2017-05-20T00:00:00</AvailableFrom>
    <AvailableFutureAllocation>100</AvailableFutureAllocation>
    <AvailableFutureHours>40.0000</AvailableFutureHours>
    <IsObserver>false</IsObserver>
    <IsContributor>false</IsContributor>
    <Locale nil="true"/>
    <Skills nil="true"/>
    <ActiveDirectoryName nil="true"/>
    <Role ResourceType="Role" Id="1" Name="Developer"/>
    <CustomFields/>
  </User>
</Users>
POST to /api/v1/undelete
Payload {EntityType:"Project",Id:2}

<Project ResourceType="Project" Id="2" Name="Tau Product - Kanban #1" />
POST to /api/v1/undelete
Payload {EntityType:"User",Id:18}

<User ResourceType="User" Id="18">
  <Kind>User</Kind>
  <FirstName>Test</FirstName>
  <LastName>User</LastName>
  <Login>test</Login>
</User>

And here is it works now:

GET /api/deleteditems/v1/projects

[
  {
    "resourceType": "Project",
    "id": 230,
    "name": "Training",
    "deleteDate": "\/Date(1482609449000-0600)\/",
    "color": null,
    "process": 
    {
      "resourceType": "Process",
      "id": 3,
      "name": "Scrum"
    },
    "lastEditor": 
    {
      "resourceType": "GeneralUser",
      "id": 1,
      "firstName": "Main",
      "lastName": "Admin",
      "email": "[email protected]"
    }
  }
]
GET /api/deleteditems/v1/users

[
  {
    "resourceType": "User",
    "kind": "User",
    "id": 11,
    "firstName": "Sam",
    "lastName": "Yellow",
    "email": "[email protected]",
    "deleteDate": "\/Date(1482419934000-0600)\/",
    "modifyDate": "\/Date(1482419934000-0600)\/",
    "avatarUri": "https://restapi.tpondemand.com/avatar.ashx?UserId=11&modified=636179951340000000&size=",
    "role": 
    {
      "resourceType": "Role",
      "id": 8,
      "name": "Top Manager"
    }
  }
]
POST to /api/DeletedItems/v1/Projects/230/Restore
With no payload

{
  "resourceType": "Project",
  "id": 230,
  "name": "Training"
}
POST to /api/DeletedItems/v1/Users/11/Restore
With no payload

{
  "resourceType": "User",
  "kind": "User",
  "id": 11,
  "firstName": "Sam",
  "lastName": "Yellow",
  "email": "[email protected]"
}