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()); }); }
/// <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))); }