Browse files

minor tweaks

  • Loading branch information...
1 parent 402c5fd commit 8e49297c755f6fd8e3bb81235c1017ddb1b6cc31 Daniel Lewis committed Sep 14, 2012
View
8 Apigee.Net.Tests/ApigeeClientTests/ClientTests.cs
@@ -23,7 +23,7 @@ public void GetUsersTest()
public void CreateAccountTest()
{
string un = "apigee_" + Guid.NewGuid();
- var result = aClient.CreateAccount(new UserModel {
+ var result = aClient.CreateAccount(new ApigeeUserModel {
Username = un,
Password = "abc123",
Email = un + "@sympletech.com"
@@ -36,7 +36,7 @@ public void CreateAccountTest()
public void UpdateAccountTest()
{
string un = "bobby";
- var result = aClient.UpdateAccount(new UserModel
+ var result = aClient.UpdateAccount(new ApigeeUserModel
{
Username = un,
Password = "abc123",
@@ -71,15 +71,15 @@ public static void temp()
string un = "apigee_" + Guid.NewGuid();
//Create a new Account
- apiClient.CreateAccount(new UserModel
+ apiClient.CreateAccount(new ApigeeUserModel
{
Username = un,
Password = "abc123",
Email = un + "@sympletech.com"
});
//Update an Existing Account
- apiClient.UpdateAccount(new UserModel
+ apiClient.UpdateAccount(new ApigeeUserModel
{
Username = un,
Password = "abc123456",
View
BIN Apigee.Net.Tests/bin/Debug/Apigee.Net.Tests.dll
Binary file not shown.
View
BIN Apigee.Net.Tests/bin/Debug/Apigee.Net.Tests.pdb
Binary file not shown.
View
BIN Apigee.Net.Tests/bin/Debug/Apigee.Net.dll
Binary file not shown.
View
BIN Apigee.Net.Tests/bin/Debug/Apigee.Net.pdb
Binary file not shown.
View
BIN Apigee.Net.Tests/obj/Debug/Apigee.Net.Tests.csprojResolveAssemblyReference.cache
Binary file not shown.
View
BIN Apigee.Net.Tests/obj/Debug/Apigee.Net.Tests.dll
Binary file not shown.
View
BIN Apigee.Net.Tests/obj/Debug/Apigee.Net.Tests.pdb
Binary file not shown.
View
BIN Apigee.Net.v11.suo
Binary file not shown.
View
2 Apigee.Net/Apigee.Net.csproj
@@ -50,7 +50,7 @@
<ItemGroup>
<Compile Include="ApigeeClient.cs" />
<Compile Include="Models\ApiResponse\CreateApigeeAccountResponse.cs" />
- <Compile Include="Models\UserModel.cs" />
+ <Compile Include="Models\ApigeeUserModel.cs" />
<Compile Include="Networking\HttpTools.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
View
32 Apigee.Net/ApigeeClient.cs
@@ -52,8 +52,12 @@ private string BuildPath(string path)
private JToken GetEntitiesFromJson(string rawJson)
{
- var objResult = JObject.Parse(rawJson);
- return objResult.SelectToken("entities");
+ if (string.IsNullOrEmpty(rawJson) != true)
+ {
+ var objResult = JObject.Parse(rawJson);
+ return objResult.SelectToken("entities");
+ }
+ return null;
}
/// <summary>
@@ -85,15 +89,15 @@ public retrunT PerformRequest<retrunT>(string path, HttpTools.RequestTypes metho
#region Account Management
- public List<UserModel> GetUsers()
+ public List<ApigeeUserModel> GetUsers()
{
var rawResults = PerformRequest<string>("/users");
var users = GetEntitiesFromJson(rawResults);
- List<UserModel> results = new List<UserModel>();
+ List<ApigeeUserModel> results = new List<ApigeeUserModel>();
foreach (var usr in users)
{
- results.Add(new UserModel {
+ results.Add(new ApigeeUserModel {
Uuid = (usr["uuid"] ?? "").ToString(),
Username = (usr["username"] ?? "").ToString(),
Password = (usr["password"] ?? "").ToString(),
@@ -112,17 +116,21 @@ public List<UserModel> GetUsers()
return results;
}
- public CreateApigeeAccountResponse CreateAccount(UserModel accountModel)
+ public string CreateAccount(ApigeeUserModel accountModel)
{
var rawResults = PerformRequest<string>("/users", HttpTools.RequestTypes.Post, accountModel);
var entitiesResult = GetEntitiesFromJson(rawResults);
-
- return new CreateApigeeAccountResponse {
- Uuid = entitiesResult[0]["uuid"].ToString()
- };
+ if (entitiesResult != null)
+ {
+ return entitiesResult[0]["uuid"].ToString();
+ }
+ else
+ {
+ return UpdateAccount(accountModel);
+ }
}
- public string UpdateAccount(UserModel accountModel)
+ public string UpdateAccount(ApigeeUserModel accountModel)
{
var rawResults = PerformRequest<string>("/users/" + accountModel.Username, HttpTools.RequestTypes.Put, accountModel);
@@ -148,7 +156,7 @@ public string LookUpToken(string token)
var rawResults = PerformRequest<string>(reqString);
var entitiesResult = GetEntitiesFromJson(rawResults);
- return entitiesResult["username"].ToString();
+ return entitiesResult[0]["username"].ToString();
}
#endregion
View
2 Apigee.Net/Models/UserModel.cs → Apigee.Net/Models/ApigeeUserModel.cs
@@ -1,6 +1,6 @@
namespace Apigee.Net.Models
{
- public class UserModel
+ public class ApigeeUserModel
{
public string Uuid { get; set; }
public string Username { get; set; }
View
BIN Apigee.Net/bin/Debug/Apigee.Net.dll
Binary file not shown.
View
BIN Apigee.Net/bin/Debug/Apigee.Net.pdb
Binary file not shown.
View
BIN Apigee.Net/obj/Debug/Apigee.Net.dll
Binary file not shown.
View
BIN Apigee.Net/obj/Debug/Apigee.Net.pdb
Binary file not shown.

0 comments on commit 8e49297

Please sign in to comment.