public void DomainEmailForwardsListOptions() { var sorting = new KeyValuePair <string, string>("sort", "id:asc,from:asc,to:desc"); var pagination = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("per_page", "42"), new KeyValuePair <string, string>("page", "7") }; var options = new DomainEmailForwardsListOptions { Pagination = new Pagination { Page = 7, PerPage = 42 } }; options.SortById(Order.asc).SortByFrom(Order.asc) .SortByTo(Order.desc); Assert.Multiple(() => { Assert.AreEqual(sorting, options.UnpackSorting()); Assert.AreEqual(pagination, options.UnpackPagination()); }); }
/// <summary> /// List email forwards for the domain in the account. /// </summary> /// <param name="accountId">The account id</param> /// <param name="domainIdentifier">The domain name or id</param> /// <param name="options">Options passed to the list (sorting, pagination)</param> /// <returns>A list of all email forwards for the domain</returns> /// <see>https://developer.dnsimple.com/v2/domains/email-forwards/#listEmailForwards</see> public EmailForwardsResponse ListEmailForwards(long accountId, string domainIdentifier, DomainEmailForwardsListOptions options) { var requestBuilder = Client.Http .RequestBuilder(EmailForwardsPath(accountId, domainIdentifier)); requestBuilder.AddParameter(options.UnpackSorting()); if (!options.Pagination.IsDefault()) { requestBuilder.AddParameters(options.UnpackPagination()); } return(new EmailForwardsResponse(Client.Http.Execute(requestBuilder .Request))); }
public void ListEmailForwardsWithOptions(long accountId, string domainIdentifier, string expectedUrl) { var client = new MockDnsimpleClient(ListEmailForwardsFixture); var options = new DomainEmailForwardsListOptions(); options.SortByFrom(Order.asc); var emailForwards = client.Domains.ListEmailForwards(accountId, domainIdentifier, options); Assert.Multiple(() => { Assert.AreEqual(2, emailForwards.Data.EmailForwards.Count); Assert.AreEqual(1, emailForwards.PaginationData.CurrentPage); Assert.AreEqual(expectedUrl, client.RequestSentTo()); }); }
/// <summary> /// Lists email forwards for the domain. /// </summary> /// <param name="accountId">The account ID</param> /// <param name="domainIdentifier">The domain name or ID</param> /// <param name="options">Options passed to the list (sorting, pagination)</param> /// <returns>A list of all email forwards for the domain</returns> /// <see>https://developer.dnsimple.com/v2/domains/email-forwards/#listEmailForwards</see> public PaginatedResponse <EmailForward> ListEmailForwards(long accountId, string domainIdentifier, DomainEmailForwardsListOptions options = null) { var builder = BuildRequestForPath(EmailForwardsPath(accountId, domainIdentifier)); AddListOptionsToRequest(options, ref builder); return(new PaginatedResponse <EmailForward>(Execute(builder.Request))); }