func (ei *EventIterator) Previous(ctx context.Context, events *[]Event) bool {
	if ei.err != nil {
		return false
	}
	if ei.Paging.Previous == "" {
		return false
	}
	ei.err = ei.fetch(ctx, ei.Paging.Previous)
	if ei.err != nil {
		return false
	}
	*events, ei.err = ParseEvents(ei.Items)
	if len(ei.Items) == 0 {
		return false
	}
	return true
}
Previous retrieves the previous page of events from the api. Returns false when there
no more pages to retrieve or if there was an error. Use `.Err()` to retrieve
the error if any
package mailgun
import (
	"context"
	"fmt"
	"time"
	jsoniter "github.com/json-iterator/go"
	"github.com/mailgun/mailgun-go/v4/events"
)
type ListEventOptions struct {
	Begin, End time.Time
	ForceAscending, ForceDescending bool
	Compact bool
	Limit int
	Filter       map[string]string
	PollInterval time.Duration
}
type EventIterator struct {
	events.Response
	mg  Mailgun
	err error
}
func (mg *MailgunImpl) ListEventsWithDomain(opts *ListEventOptions, domain string) *EventIterator {
	url := generateApiUrlWithDomain(mg, eventsEndpoint, domain)
	return mg.listEvents(url, opts)
}
func (mg *MailgunImpl) ListEvents(opts *ListEventOptions) *EventIterator {
	url := generateApiUrl(mg, eventsEndpoint)
	return mg.listEvents(url, opts)
}
func (mg *MailgunImpl) listEvents(url string, opts *ListEventOptions) *EventIterator {
	req := newHTTPRequest(url)
	if opts != nil {
		if opts.Limit > 0 {
			req.addParameter("limit", fmt.Sprintf("%d", opts.Limit))
		}
		if opts.Compact {
			req.addParameter("pretty", "no")
		}
		if opts.ForceAscending {
			req.addParameter("ascending", "yes")
		} else if opts.ForceDescending {
			req.addParameter("ascending", "no")
		}
		if !opts.Begin.IsZero() {
			req.addParameter("begin", formatMailgunTime(opts.Begin))
		}
		if !opts.End.IsZero() {
			req.addParameter("end", formatMailgunTime(opts.End))
		}
		if opts.Filter != nil {
			for k, v := range opts.Filter {
				req.addParameter(k, v)
			}
		}
	}
	url, err := req.generateUrlWithParameters()
	return &EventIterator{
		mg:       mg,
		Response: events.Response{Paging: events.Paging{Next: url, First: url}},
		err:      err,
	}
}
func (ei *EventIterator) Err() error {
	return ei.err
}
func (ei *EventIterator) Next(ctx context.Context, events *[]Event) bool {
	if ei.err != nil {
		return false
	}
	ei.err = ei.fetch(ctx, ei.Paging.Next)
	if ei.err != nil {
		return false
	}
	*events, ei.err = ParseEvents(ei.Items)
	if ei.err != nil {
		return false
	}
	if len(ei.Items) == 0 {
		return false
	}
	return true
}
func (ei *EventIterator) First(ctx context.Context, events *[]Event) bool {
	if ei.err != nil {
		return false
	}
	ei.err = ei.fetch(ctx, ei.Paging.First)
	if ei.err != nil {
		return false
	}
	*events, ei.err = ParseEvents(ei.Items)
	return true
}
func (ei *EventIterator) Last(ctx context.Context, events *[]Event) bool {
	if ei.err != nil {
		return false
	}
	ei.err = ei.fetch(ctx, ei.Paging.Last)
	if ei.err != nil {
		return false
	}
	*events, ei.err = ParseEvents(ei.Items)
	return true
}