Skip to content

Commit ab80e0d

Browse files
committed
Removed TeamMembership code
Added general purpose post() method Changed version to 1.0.19.0
1 parent 2ef54e4 commit ab80e0d

3 files changed

Lines changed: 16 additions & 31 deletions

File tree

Rally.RestApi.Test/RallyRestApiTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public void TestAttribute()
273273
public void FormatCreateString()
274274
{
275275
RallyRestApi restApi = GetRallyRestApi();
276-
Uri result = restApi.FormatCreateString(null,"defect");
276+
Uri result = restApi.FormatCreateUri(null,"defect");
277277
var expected = new Uri(IntegrationTestInfo.SERVER + "/slm/webservice/" + RallyRestApi.DEFAULT_WSAPI_VERSION + "/defect/create.js");
278278
Assert.AreEqual(expected, result);
279279
}
@@ -282,7 +282,7 @@ public void FormatCreateString()
282282
public void FormatUpdateString()
283283
{
284284
RallyRestApi restApi = GetRallyRestApi();
285-
Uri result = restApi.FormatUpdateString("defect", 2121901027);
285+
Uri result = restApi.FormatUpdateUri("defect", 2121901027);
286286
var expected = new Uri(IntegrationTestInfo.SERVER + "/slm/webservice/" + RallyRestApi.DEFAULT_WSAPI_VERSION + "/defect/2121901027.js");
287287
Assert.AreEqual(expected, result);
288288
}

Rally.RestApi/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.18.0")]
35-
[assembly: AssemblyFileVersion("1.0.18.0")]
34+
[assembly: AssemblyVersion("1.0.19.0")]
35+
[assembly: AssemblyFileVersion("1.0.19.0")]
3636

3737
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Rally.RestApi.Test")]

Rally.RestApi/RallyRestApi.cs

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ protected Uri GetFullyQualifiedUri(string aRef)
201201
return new Uri(GetFullyQualifiedRef(aRef));
202202
}
203203

204-
internal Uri FormatCreateString(string workspaceRef, string typePath)
204+
internal Uri FormatCreateUri(string workspaceRef, string typePath)
205205
{
206206
String workspaceClause = workspaceRef == null ? "" : "?workspace=" + workspaceRef;
207207
return new Uri(Service.Server.AbsoluteUri + "slm/webservice/" + wsapiVersion + "/" + typePath + "/create.js" + workspaceClause);
208208
}
209209

210-
internal Uri FormatUpdateString(string typePath, long objectId)
210+
internal Uri FormatUpdateUri(string typePath, long objectId)
211211
{
212212
return
213213
new Uri(Service.Server.AbsoluteUri + "slm/webservice/" + wsapiVersion + "/" + typePath + "/" + objectId +
@@ -464,7 +464,11 @@ public OperationResult Delete(string workspaceRef, string aRef)
464464
/// <returns></returns>
465465
public CreateResult Create(string workspaceRef, string typePath, DynamicJsonObject obj)
466466
{
467-
DynamicJsonObject response = CreateWithUri(FormatCreateString(workspaceRef, typePath), typePath, obj);
467+
var data = new DynamicJsonObject();
468+
data[typePath] = obj;
469+
string postData = serializer.Serialize(data);
470+
DynamicJsonObject response =
471+
serializer.Deserialize(Service.Post(FormatCreateUri(workspaceRef, typePath), postData, GetProcessedHeaders()));
468472
DynamicJsonObject createResult = response["CreateResult"];
469473
var createResponse = new CreateResult();
470474
if (createResult.HasMember("Object"))
@@ -477,14 +481,6 @@ public CreateResult Create(string workspaceRef, string typePath, DynamicJsonObje
477481
return createResponse;
478482
}
479483

480-
public DynamicJsonObject CreateWithUri(Uri uri, string typePath, DynamicJsonObject obj)
481-
{
482-
var data = new DynamicJsonObject();
483-
data[typePath] = obj;
484-
string postData = serializer.Serialize(data);
485-
return serializer.Deserialize(Service.Post(uri, postData, GetProcessedHeaders()));
486-
}
487-
488484
/// <summary>
489485
/// Update the item described by the specified reference with
490486
/// the fields of the specified object
@@ -497,22 +493,11 @@ public OperationResult Update(string reference, DynamicJsonObject obj)
497493
return Update(Ref.GetTypeFromRef(reference), Ref.GetOidFromRef(reference), obj);
498494
}
499495

500-
public CreateResult CreateProjectTeamMembership(String projectOid, String userOid)
496+
public DynamicJsonObject post(String relativeUri, DynamicJsonObject data)
501497
{
502-
Uri uri = new Uri(String.Format("{0}slm/webservice/{1}/project/{2}/projectuser/{3}.js", Service.Server.AbsoluteUri, wsapiVersion, projectOid, userOid));
503-
DynamicJsonObject data = new DynamicJsonObject();
504-
data["TeamMember"] = true;
505-
DynamicJsonObject response = CreateWithUri(uri, "projectuser", data);
506-
DynamicJsonObject operationResult = response["OperationResult"];
507-
var createResponse = new CreateResult();
508-
if (operationResult.HasMember("Object"))
509-
{
510-
createResponse.Object = operationResult["Object"];
511-
createResponse.Reference = createResponse.Object["_ref"] as string;
512-
}
513-
createResponse.Errors.AddRange(DecodeArrayList(operationResult["Errors"]));
514-
createResponse.Warnings.AddRange(DecodeArrayList(operationResult["Warnings"]));
515-
return createResponse;
498+
Uri uri = new Uri(String.Format("{0}slm/webservice/{1}/{2}", Service.Server.AbsoluteUri, wsapiVersion, relativeUri));
499+
string postData = serializer.Serialize(data);
500+
return serializer.Deserialize(Service.Post(uri, postData, GetProcessedHeaders()));
516501
}
517502

518503
/// <summary>
@@ -530,7 +515,7 @@ public OperationResult Update(string typePath, long oid, DynamicJsonObject obj)
530515
data[typePath] = obj;
531516
string postData = serializer.Serialize(data);
532517
dynamic response =
533-
serializer.Deserialize(Service.Post(FormatUpdateString(typePath, oid), postData, GetProcessedHeaders()));
518+
serializer.Deserialize(Service.Post(FormatUpdateUri(typePath, oid), postData, GetProcessedHeaders()));
534519
result.Errors.AddRange(DecodeArrayList(response.OperationResult.Errors));
535520
result.Warnings.AddRange(DecodeArrayList(response.OperationResult.Warnings));
536521
return result;

0 commit comments

Comments
 (0)