Skip to content

Commit

Permalink
fixes #237
Browse files Browse the repository at this point in the history
made a few changes to SearchForOrganizationsAsync
  • Loading branch information
mozts2005 committed Sep 16, 2016
1 parent 3efd572 commit 69056df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
9 changes: 9 additions & 0 deletions src/Tests/OrganizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using ZendeskApi_v2.Models.Organizations;
using ZendeskApi_v2.Models.Tags;
using ZendeskApi_v2.Models.Users;
using System.Threading.Tasks;

namespace Tests
{
Expand Down Expand Up @@ -167,5 +168,13 @@ public void CanCreateManyAndDeleteOrganizationMemberships()
Assert.True(api.Organizations.DeleteOrganization(org.Organization.Id.Value));
Assert.True(api.Organizations.DeleteOrganization(org2.Organization.Id.Value));
}


[Test]
public async Task CanSearchForOrganizationsAsync()
{
var search = await api.Organizations.SearchForOrganizationsAsync(Settings.DefaultExternalId);
Assert.Greater(search.Count, 0);
}
}
}
12 changes: 0 additions & 12 deletions src/Tests/TicketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,6 @@ public async Task CanGetMultipleTicketsAsyncSingleTicket()
Assert.AreEqual(tickets.Count, ids.Count);
}

[Test]
public void CorrectErrorMessagesAreThrown()
{
//var t = api.Tickets.GetTicket(921);
//var res = api.Tickets.UpdateTicket(t.Ticket,
// new Comment()
// {
// Body = "trying to cause an error by updating a closed ticket. Let's see how it responds :)"
// });

}

[Test]
public void BooleanCustomFieldValuesArePreservedOnUpdate()
{
Expand Down
11 changes: 6 additions & 5 deletions src/ZendeskApi_v2/Requests/Organizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public interface IOrganizations : ICore
/// <returns></returns>
Task<GroupOrganizationResponse> GetOrganizationsStartingWithAsync(string name);

// TODO: Rename SearchForOrganizationsByExternalIdAsync(string externalId);
Task<GroupOrganizationResponse> SearchForOrganizationsAsync(string searchTerm);
Task<IndividualOrganizationResponse> GetOrganizationAsync(long id);
Task<IndividualOrganizationResponse> CreateOrganizationAsync(Organization organization);
Expand Down Expand Up @@ -106,7 +107,7 @@ public IndividualOrganizationResponse GetOrganization(long id)

public IndividualOrganizationResponse CreateOrganization(Organization organization)
{
var body = new {organization};
var body = new { organization };
return GenericPost<IndividualOrganizationResponse>("organizations.json", body);
}

Expand All @@ -117,7 +118,7 @@ public IndividualOrganizationResponse UpdateOrganization(Organization organizati
}

public bool DeleteOrganization(long id)
{
{
return GenericDelete(string.Format("organizations/{0}.json", id));
}

Expand Down Expand Up @@ -205,7 +206,7 @@ public async Task<GroupOrganizationResponse> GetOrganizationsStartingWithAsync(s

public async Task<GroupOrganizationResponse> SearchForOrganizationsAsync(string searchTerm)
{
return await GenericPostAsync<GroupOrganizationResponse>(string.Format("organizations/autocomplete.json?external_id={0}", searchTerm));
return await GenericGetAsync<GroupOrganizationResponse>(string.Format("organizations/search.json?external_id={0}", searchTerm));
}

public async Task<IndividualOrganizationResponse> GetOrganizationAsync(long id)
Expand All @@ -215,7 +216,7 @@ public async Task<IndividualOrganizationResponse> GetOrganizationAsync(long id)

public async Task<IndividualOrganizationResponse> CreateOrganizationAsync(Organization organization)
{
var body = new {organization};
var body = new { organization };
return await GenericPostAsync<IndividualOrganizationResponse>("organizations.json", body);
}

Expand All @@ -226,7 +227,7 @@ public async Task<IndividualOrganizationResponse> UpdateOrganizationAsync(Organi
}

public async Task<bool> DeleteOrganizationAsync(long id)
{
{
return await GenericDeleteAsync(string.Format("organizations/{0}.json", id));
}

Expand Down

0 comments on commit 69056df

Please sign in to comment.