/// <summary> /// Client for making requests to the API. /// </summary> /// <param name="authHandler">The authentication handler.</param> /// <param name="ctx">The HTTP context to use for this session.</param> private Client(Func <CancellationToken, Task <string> > authHandler, HttpContext ctx) { // Setup resources. Assets = new AssetsResource(authHandler, ctx); TimeSeries = new TimeSeriesResource(authHandler, ctx); DataPoints = new DataPointsResource(authHandler, ctx); Events = new EventsResource(authHandler, ctx); Sequences = new SequencesResource(authHandler, ctx); Raw = new RawResource(authHandler, ctx); Relationships = new RelationshipResource(authHandler, ctx); DataSets = new DataSetsResource(authHandler, ctx); ThreeDModels = new ThreeDModelsResource(authHandler, ctx); ThreeDRevisions = new ThreeDRevisionsResource(authHandler, ctx); ThreeDAssetMappings = new ThreeDAssetMappingsResource(authHandler, ctx); Files = new FilesResource(authHandler, ctx); Login = new LoginResource(authHandler, ctx); Token = new TokenResource(authHandler, ctx); ExtPipes = new ExtPipesResource(authHandler, ctx); Labels = new LabelsResource(authHandler, ctx); Groups = new GroupsResource(authHandler, ctx); // Playground features (experimental) Playground = new PlaygroundResource(authHandler, ctx); // Beta features (experimental) Beta = new BetaResource(authHandler, ctx); }
public async void GetAsync_Called_ReturnsResponse() { // Given var client = new Mock <IRestClient>(); var response = new GroupResponse { Item = new Group { Id = 1 } }; client.Setup(b => b.GetAsync <GroupResponse>( It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <string>() )) .Returns(TaskHelper.CreateTaskFromResult(response)); client.Setup(b => b.BuildUri(It.IsAny <string>(), It.Is <string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk")); var groupResource = new GroupsResource(client.Object); // When var result = await groupResource.GetAsync(321); // Then Assert.That(result, Is.EqualTo(response)); }
/// <summary> /// Returns true if the group was successfully deleted; otherwise, false. /// </summary> /// <param name="id">A System.Guid instance that contains the Id of a group.</param> /// <returns>true, if the group was successfully deleted; otherwise, false.</returns> /// <exception cref="System.Net.WebException"></exception> public bool DeleteGroup(Guid id) { RestResource resource = new GroupsResource(id); var response = MakeRequest(HttpMethod.DELETE, resource); return(response != null); }
/// <summary> /// Creates a com.esendex.sdk.groups.Group instance and returns the new com.esendex.sdk.groups.Group instance. /// </summary> /// <param name="group">A com.esendex.sdk.groups.Group instance that contains the group.</param> /// <returns>A com.esendex.sdk.groups.Group instance that contains the group with an Id assigned.</returns> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.Net.WebException"></exception> public Group CreateGroup(Group group) { var requestXml = Serialiser.Serialise(group); RestResource resource = new GroupsResource(requestXml); return(MakeRequest <GroupResponse>(HttpMethod.POST, resource) .Group); }
/// <summary> /// Returns true if the group was successfully updated; otherwise, false. /// </summary> /// <param name="group">A com.esendex.sdk.groups.Group instance that contains the group.</param> /// <returns>true, if the group was successfully updated; otherwise, false.</returns> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.Net.WebException"></exception> public bool UpdateGroup(Group group) { var requestXml = Serialiser.Serialise(group); RestResource resource = new GroupsResource(group.Id, requestXml); var response = MakeRequest(HttpMethod.PUT, resource); return(response != null); }
/// <summary> /// Posts a com.esendex.sdk.contacts.Contact to a com.esendex.sdk.groups.Group. /// </summary> /// <param name="accountReference">The number of the page.</param> /// <param name="groupId">The number of items in the page.</param> /// <param name="contact"></param> /// <returns>A com.esendex.sdk.groups.PagedGroupCollection instance that contains the groups.</returns> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.Net.WebException"></exception> public bool AddContactToGroup(string accountReference, string groupId, Contact contact) { var contactColletion = new ContactCollection(); contactColletion.ItemsId.Add(contact.Id.ToString()); RestResource resource = new GroupsResource(accountReference, groupId, Serialiser.Serialise(contactColletion)); var response = MakeRequest(HttpMethod.POST, resource); return(response != null); }
public void Get_Called_CallsBuildUriWithFieldId() { // Given _client.Setup(b => b.BuildUri(It.IsAny <string>(), It.Is <string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk")); var groupResource = new GroupsResource(_client.Object); // When groupResource.Get(321); // Then _client.Verify(c => c.BuildUri(It.Is <string>(s => s.Contains("/groups/321")), "")); }
public void Get_Called_CallsBuildUriWithFieldId() { // Given _client.Setup(b => b.BuildUri(It.IsAny<string>(), It.Is<string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk")); var groupResource = new GroupsResource(_client.Object); // When groupResource.Get(321); // Then _client.Verify(c => c.BuildUri(It.Is<string>(s => s.Contains("/groups/321")), "")); }
public ZendeskClient(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null) :base(baseUri, configuration, serializer, httpChannel, logger) { Tickets = new TicketResource(this); TicketComments = new TicketCommentResource(this); Organizations = new OrganizationResource(this); Search = new SearchResource(this); Groups = new GroupsResource(this); AssignableGroups = new AssignableGroupResource(this); Users = new UserResource(this); UserIdentities = new UserIdentityResource(this); OrganizationMemberships = new OrganizationMembershipResource(this); }
public ZendeskClient(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null) : base(baseUri, configuration, serializer, httpChannel, logger) { Tickets = new TicketResource(this); TicketComments = new TicketCommentResource(this); Organizations = new OrganizationResource(this); Search = new SearchResource(this); Groups = new GroupsResource(this); AssignableGroups = new AssignableGroupResource(this); Users = new UserResource(this); UserIdentities = new UserIdentityResource(this); OrganizationMemberships = new OrganizationMembershipResource(this); }
public void Get_Called_ReturnsResponse() { // Given var response = new GroupResponse { Item = new Group { Id = 1 }}; _client.Setup(b => b.Get<GroupResponse>(It.IsAny<Uri>())).Returns(response); _client.Setup(b => b.BuildUri(It.IsAny<string>(), It.Is<string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk")); var groupResource = new GroupsResource(_client.Object); // When var result = groupResource.Get(321); // Then Assert.That(result, Is.EqualTo(response)); }
public async void GetAsync_Called_CallsBuildUriWithFieldId() { // Given var client = new Mock <IRestClient>(); client.Setup(b => b.BuildUri(It.IsAny <string>(), It.Is <string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk")); var groupResource = new GroupsResource(client.Object); // When await groupResource.GetAsync(321); // Then client.Verify(c => c.BuildUri(It.Is <string>(s => s.Contains("/groups/321")), "")); }
public void Get_Called_ReturnsResponse() { // Given var response = new GroupResponse { Item = new Group { Id = 1 } }; _client.Setup(b => b.Get <GroupResponse>(It.IsAny <Uri>())).Returns(response); _client.Setup(b => b.BuildUri(It.IsAny <string>(), It.Is <string>(s => s.Contains("321")))).Returns(new Uri("http://zendesk")); var groupResource = new GroupsResource(_client.Object); // When var result = groupResource.Get(321); // Then Assert.That(result, Is.EqualTo(response)); }
/// <summary> /// Gets a com.esendex.sdk.group.PagedGroupCollection instance containing groups. /// </summary> /// <param name="accountReference">The number of the page.</param> /// <param name="pageNumber">The number of the page.</param> /// <param name="pageSize">The number of items in the page.</param> /// <param name="groupId">The number of items in the page.</param> /// <returns>A com.esendex.sdk.groups.PagedGroupCollection instance that contains the groups.</returns> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.Net.WebException"></exception> public PagedContactCollection GetContactsFromGroup(string accountReference, string groupId, int pageNumber, int pageSize) { RestResource resource = new GroupsResource(accountReference, groupId, pageNumber, pageSize); return(MakeRequest <PagedContactCollection>(HttpMethod.GET, resource)); }
/// <summary> /// Gets a com.esendex.sdk.group.Group instance containing a group. /// </summary> /// <param name="id">A System.Guid instance that contains the Id of a group.</param> /// <returns>A com.esendex.sdk.groups.Group instance that contains the group.</returns> /// <exception cref="System.Net.WebException"></exception> public Group GetGroup(Guid id) { RestResource resource = new GroupsResource(id); return(MakeRequest <Group>(HttpMethod.GET, resource)); }
public GroupsResourceTests() { _client = new DisposableZendeskApiClient <Group>((resource) => new GroupsResourceSampleSite(resource)); _resource = new GroupsResource(_client, NullLogger.Instance); }
/// <summary>Constructs a new service.</summary> /// <param name="initializer">The service initializer.</param> public GroupssettingsService(Google.Apis.Services.BaseClientService.Initializer initializer) : base(initializer) { groups = new GroupsResource(this); }
/// <summary> /// Gets a com.esendex.sdk.group.PagedGroupCollection instance containing groups. /// </summary> /// <param name="pageNumber">The number of the page.</param> /// <param name="pageSize">The number of items in the page.</param> /// <returns>A com.esendex.sdk.groups.PagedGroupCollection instance that contains the groups.</returns> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.Net.WebException"></exception> public PagedGroupCollection GetGroups(string accountReference, int pageNumber, int pageSize) { RestResource resource = new GroupsResource(accountReference, pageNumber, pageSize); return(MakeRequest <PagedGroupCollection>(HttpMethod.GET, resource)); }