func (c *ApiService) StreamChallenge(ServiceSid string, Identity string, params *ListChallengeParams) (chan VerifyV2Challenge, error) {
	if params == nil {
		params = &ListChallengeParams{}
	}
	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
	response, err := c.PageChallenge(ServiceSid, Identity, params, "", "")
	if err != nil {
		return nil, err
	}
	curRecord := 0
	channel := make(chan VerifyV2Challenge, 1)
	go func() {
		for response != nil {
			for item := range response.Challenges {
				channel <- response.Challenges[item]
			}
			var record interface{}
			if record, err = client.GetNext(c.baseURL, response, &curRecord, params.Limit, c.getNextListChallengeResponse); record == nil || err != nil {
				close(channel)
				return
			}
			response = record.(*ListChallengeResponse)
		}
		close(channel)
	}()
	return channel, err
}
Streams Challenge records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached.
package openapi
import (
	"encoding/json"
	"fmt"
	"net/url"
	"strings"
	"time"
	"github.com/twilio/twilio-go/client"
)
type CreateChallengeParams struct {
	AuthPayload *string `json:"AuthPayload,omitempty"`
	DetailsFields *[]map[string]interface{} `json:"Details.Fields,omitempty"`
	DetailsMessage *string `json:"Details.Message,omitempty"`
	ExpirationDate *time.Time `json:"ExpirationDate,omitempty"`
	FactorSid *string `json:"FactorSid,omitempty"`
	HiddenDetails *map[string]interface{} `json:"HiddenDetails,omitempty"`
}
func (params *CreateChallengeParams) SetAuthPayload(AuthPayload string) *CreateChallengeParams {
	params.AuthPayload = &AuthPayload
	return params
}
func (params *CreateChallengeParams) SetDetailsFields(DetailsFields []map[string]interface{}) *CreateChallengeParams {
	params.DetailsFields = &DetailsFields
	return params
}
func (params *CreateChallengeParams) SetDetailsMessage(DetailsMessage string) *CreateChallengeParams {
	params.DetailsMessage = &DetailsMessage
	return params
}
func (params *CreateChallengeParams) SetExpirationDate(ExpirationDate time.Time) *CreateChallengeParams {
	params.ExpirationDate = &ExpirationDate
	return params
}
func (params *CreateChallengeParams) SetFactorSid(FactorSid string) *CreateChallengeParams {
	params.FactorSid = &FactorSid
	return params
}
func (params *CreateChallengeParams) SetHiddenDetails(HiddenDetails map[string]interface{}) *CreateChallengeParams {
	params.HiddenDetails = &HiddenDetails
	return params
}
func (c *ApiService) CreateChallenge(ServiceSid string, Identity string, params *CreateChallengeParams) (*VerifyV2Challenge, error) {
	path := "/v2/Services/{ServiceSid}/Entities/{Identity}/Challenges"
	path = strings.Replace(path, "{"+"ServiceSid"+"}", ServiceSid, -1)
	path = strings.Replace(path, "{"+"Identity"+"}", Identity, -1)
	data := url.Values{}
	headers := make(map[string]interface{})
	if params != nil && params.AuthPayload != nil {
		data.Set("AuthPayload", *params.AuthPayload)
	}
	if params != nil && params.DetailsFields != nil {
		for _, item := range *params.DetailsFields {
			v, err := json.Marshal(item)
			if err != nil {
				return nil, err
			}
			data.Add("Details.Fields", string(v))
		}
	}
	if params != nil && params.DetailsMessage != nil {
		data.Set("Details.Message", *params.DetailsMessage)
	}
	if params != nil && params.ExpirationDate != nil {
		data.Set("ExpirationDate", fmt.Sprint((*params.ExpirationDate).Format(time.RFC3339)))
	}
	if params != nil && params.FactorSid != nil {
		data.Set("FactorSid", *params.FactorSid)
	}
	if params != nil && params.HiddenDetails != nil {
		v, err := json.Marshal(params.HiddenDetails)
		if err != nil {
			return nil, err
		}
		data.Set("HiddenDetails", string(v))
	}
	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	ps := &VerifyV2Challenge{}
	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
		return nil, err
	}
	return ps, err
}
func (c *ApiService) FetchChallenge(ServiceSid string, Identity string, Sid string) (*VerifyV2Challenge, error) {
	path := "/v2/Services/{ServiceSid}/Entities/{Identity}/Challenges/{Sid}"
	path = strings.Replace(path, "{"+"ServiceSid"+"}", ServiceSid, -1)
	path = strings.Replace(path, "{"+"Identity"+"}", Identity, -1)
	path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1)
	data := url.Values{}
	headers := make(map[string]interface{})
	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	ps := &VerifyV2Challenge{}
	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
		return nil, err
	}
	return ps, err
}
type ListChallengeParams struct {
	FactorSid *string `json:"FactorSid,omitempty"`
	Status *string `json:"Status,omitempty"`
	Order *string `json:"Order,omitempty"`
	PageSize *int `json:"PageSize,omitempty"`
	Limit *int `json:"limit,omitempty"`
}
func (params *ListChallengeParams) SetFactorSid(FactorSid string) *ListChallengeParams {
	params.FactorSid = &FactorSid
	return params
}
func (params *ListChallengeParams) SetStatus(Status string) *ListChallengeParams {
	params.Status = &Status
	return params
}
func (params *ListChallengeParams) SetOrder(Order string) *ListChallengeParams {
	params.Order = &Order
	return params
}
func (params *ListChallengeParams) SetPageSize(PageSize int) *ListChallengeParams {
	params.PageSize = &PageSize
	return params
}
func (params *ListChallengeParams) SetLimit(Limit int) *ListChallengeParams {
	params.Limit = &Limit
	return params
}
func (c *ApiService) PageChallenge(ServiceSid string, Identity string, params *ListChallengeParams, pageToken, pageNumber string) (*ListChallengeResponse, error) {
	path := "/v2/Services/{ServiceSid}/Entities/{Identity}/Challenges"
	path = strings.Replace(path, "{"+"ServiceSid"+"}", ServiceSid, -1)
	path = strings.Replace(path, "{"+"Identity"+"}", Identity, -1)
	data := url.Values{}
	headers := make(map[string]interface{})
	if params != nil && params.FactorSid != nil {
		data.Set("FactorSid", *params.FactorSid)
	}
	if params != nil && params.Status != nil {
		data.Set("Status", *params.Status)
	}
	if params != nil && params.Order != nil {
		data.Set("Order", *params.Order)
	}
	if params != nil && params.PageSize != nil {
		data.Set("PageSize", fmt.Sprint(*params.PageSize))
	}
	if pageToken != "" {
		data.Set("PageToken", pageToken)
	}
	if pageNumber != "" {
		data.Set("Page", pageNumber)
	}
	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	ps := &ListChallengeResponse{}
	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
		return nil, err
	}
	return ps, err
}
func (c *ApiService) ListChallenge(ServiceSid string, Identity string, params *ListChallengeParams) ([]VerifyV2Challenge, error) {
	if params == nil {
		params = &ListChallengeParams{}
	}
	params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit))
	response, err := c.PageChallenge(ServiceSid, Identity, params, "", "")
	if err != nil {
		return nil, err
	}
	curRecord := 0
	var records []VerifyV2Challenge
	for response != nil {
		records = append(records, response.Challenges...)
		var record interface{}
		if record, err = client.GetNext(c.baseURL, response, &curRecord, params.Limit, c.getNextListChallengeResponse); record == nil || err != nil {
			return records, err
		}
		response = record.(*ListChallengeResponse)
	}
	return records, err
}