public void ZonesListOptions() { var filters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("name_like", "example.com") }; var sorting = new KeyValuePair <string, string>("sort", "id:asc,name:desc"); var pagination = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("per_page", "42"), new KeyValuePair <string, string>("page", "7") }; var options = new ZonesListOptions { Pagination = new Pagination { PerPage = 42, Page = 7 } }.FilterByName("example.com") .SortById(Order.asc) .SortByName(Order.desc); Assert.Multiple(() => { Assert.AreEqual(filters, options.UnpackFilters()); Assert.AreEqual(sorting, options.UnpackSorting()); Assert.AreEqual(pagination, options.UnpackPagination()); }); }
public void ListZonesWithOptions(long accountId, string expectedUrl) { var client = new MockDnsimpleClient(ListZonesFixture); var options = new ZonesListOptions { Pagination = new Pagination { PerPage = 42, Page = 7 } }.FilterByName("example.com") .SortById(Order.asc) .SortByName(Order.desc); var response = client.Zones.ListZones(accountId, options); Assert.Multiple(() => { Assert.AreEqual(2, response.Data.Count); Assert.AreEqual(1, response.PaginationData.CurrentPage); Assert.AreEqual(expectedUrl, client.RequestSentTo()); }); }
/// <summary> /// Lists the zones in the account. /// </summary> /// <param name="accountId">The account ID</param> /// <param name="options">Options passed to the list (sorting, /// filtering, pagination)</param> /// <returns>A <c>ZonesResponse</c> containing a list of zones for /// the account.</returns> /// <see>https://developer.dnsimple.com/v2/zones/#listZones</see> public PaginatedResponse <Zone> ListZones(long accountId, ZonesListOptions options = null) { var builder = BuildRequestForPath(ZonesPath(accountId)); AddListOptionsToRequest(options, ref builder); return(new PaginatedResponse <Zone>(Execute(builder.Request))); }
/// <summary> /// Lists the zones in the account. /// </summary> /// <param name="accountId">The account id</param> /// <param name="options">Options passed to the list (sorting, /// filtering, pagination)</param> /// <returns>A <c>ZonesResponse</c> containing a list of zones for /// the account.</returns> /// <see cref="ZonesResponse"/> /// <see>https://developer.dnsimple.com/v2/zones/#listZones</see> public ZonesResponse ListZones(long accountId, ZonesListOptions options) { var requestBuilder = Client.Http .RequestBuilder(ZonesPath(accountId)); requestBuilder.AddParameter(options.UnpackSorting()); requestBuilder.AddParameters(options.UnpackFilters()); if (!options.Pagination.IsDefault()) { requestBuilder.AddParameters(options.UnpackPagination()); } return(new ZonesResponse(Client.Http.Execute(requestBuilder.Request))); }