func (a *alertPageIterator) Next(ctx context.Context) (*AlertPage, error) {
	ap := new(AlertPage)
	err := a.p.Next(ctx, ap)
	if err != nil {
		return nil, err
	}
	a.p.SetNextPageURI(ap.Meta.NextPageURL)
	return ap, nil
}
Next returns the next page of resources. If there are no more resources,
NoMoreResults is returned.
package twilio
import (
	"context"
	"encoding/json"
	"fmt"
	"net/url"
	"strconv"
	"strings"
	"time"
	types "github.com/kevinburke/go-types"
)
const alertPathPart = "Alerts"
type AlertService struct {
	client *Client
}
type Alert struct {
	Sid        string `json:"sid"`
	AccountSid string `json:"account_sid"`
	AlertText        string          `json:"alert_text"`
	APIVersion       string          `json:"api_version"`
	DateCreated      TwilioTime      `json:"date_created"`
	DateGenerated    TwilioTime      `json:"date_generated"`
	DateUpdated      TwilioTime      `json:"date_updated"`
	ErrorCode        Code            `json:"error_code"`
	LogLevel         LogLevel        `json:"log_level"`
	MoreInfo         string          `json:"more_info"`
	RequestMethod    string          `json:"request_method"`
	RequestURL       string          `json:"request_url"`
	RequestVariables Values          `json:"request_variables"`
	ResponseBody     string          `json:"response_body"`
	ResponseHeaders  Values          `json:"response_headers"`
	ResourceSid      string          `json:"resource_sid"`
	ServiceSid       json.RawMessage `json:"service_sid"`
	URL              string          `json:"url"`
}
type AlertPage struct {
	Meta   Meta     `json:"meta"`
	Alerts []*Alert `json:"alerts"`
}
func (a *AlertService) Get(ctx context.Context, sid string) (*Alert, error) {
	alert := new(Alert)
	err := a.client.GetResource(ctx, alertPathPart, sid, alert)
	return alert, err
}
func (a *AlertService) GetPage(ctx context.Context, data url.Values) (*AlertPage, error) {
	return a.GetPageIterator(data).Next(ctx)
}
type AlertPageIterator interface {
	Next(context.Context) (*AlertPage, error)
}
type alertPageIterator struct {
	p *PageIterator
}
func (a *AlertService) GetAlertsInRange(start time.Time, end time.Time, data url.Values) AlertPageIterator {
	if start.After(end) {
		panic("start date is after end date")
	}
	d := url.Values{}
	if data != nil {
		for k, v := range data {
			d[k] = v
		}
	}
	d.Del("Page")  
	if start != Epoch {
		startFormat := start.UTC().Format(time.RFC3339)
		d.Set("StartDate", startFormat)
	}
	if end != HeatDeath {
		endFormat := end.UTC().Format(time.RFC3339)
		d.Set("EndDate", endFormat)
	}
	iter := NewPageIterator(a.client, d, alertPathPart)
	return &alertDateIterator{
		start: start,
		end:   end,
		p:     iter,
	}
}
func (a *AlertService) GetNextAlertsInRange(start time.Time, end time.Time, nextPageURI string) AlertPageIterator {
	if nextPageURI == "" {
		panic("nextpageuri is empty")
	}
	iter := NewNextPageIterator(a.client, callsPathPart)
	iter.SetNextPageURI(types.NullString{Valid: true, String: nextPageURI})
	return &alertDateIterator{
		start: start,
		end:   end,
		p:     iter,
	}
}
type alertDateIterator struct {
	p     *PageIterator
	start time.Time
	end   time.Time
}
func (a *alertDateIterator) Next(ctx context.Context) (*AlertPage, error) {
	var page *AlertPage
	for {
		page = new(AlertPage)
		if err := a.p.Next(ctx, page); err != nil {
			return nil, err
		}
		if len(page.Alerts) == 0 {
			return nil, NoMoreResults
		}
		times := make([]time.Time, len(page.Alerts))
		for i, alert := range page.Alerts {
			if !alert.DateCreated.Valid {
				return nil, fmt.Errorf("Couldn't verify the date of alert: %#v", alert)
			}
			times[i] = alert.DateCreated.Time
		}
		if containsResultsInRange(a.start, a.end, times) {
			indexesToDelete := indexesOutsideRange(a.start, a.end, times)
			for i := len(indexesToDelete) - 1; i >= 0; i-- {
				index := indexesToDelete[i]
				page.Alerts = append(page.Alerts[:index], page.Alerts[index+1:]...)
			}
			a.p.SetNextPageURI(page.Meta.NextPageURL)
			return page, nil
		}
		if shouldContinuePaging(a.start, times) {
			a.p.SetNextPageURI(page.Meta.NextPageURL)
			continue
		} else {
			return nil, NoMoreResults
		}
	}
}
func (a *AlertService) GetPageIterator(data url.Values) AlertPageIterator {
	iter := NewPageIterator(a.client, data, alertPathPart)
	return &alertPageIterator{
		p: iter,
	}
}