func yieldCampaignStats(csc chan CampaignStatStruct, resp *CampaignStatsResponse, cs *CampaignStats, campaignID string) {
	for {
		for _, item := range resp.Items {
			csc <- item
		}
		if !resp.HasMore {
			close(csc)
			return
		}
		params := map[string]string{
			"since": strconv.FormatInt(resp.LastTimestamp, 10),
		}

		resp, err := cs.Get(campaignID, params)

		if err != nil {
			panic(err)
		}

		yieldCampaignStats(csc, resp, cs, campaignID)

		return
	}
}
// campagnStats feeds a campaign statistics channel with items
//
// while hasMore is true and all items have been consumed in the channel
// a new request is fired using the since parameter of the response, to
// retrieve new items
//
// when HasMore is false, we close the channel
campagnStats feeds a campaign statistics channel with items

while hasMore is true and all items have been consumed in the channel
a new request is fired using the since parameter of the response, to
retrieve new items

when HasMore is false, we close the channel
// campagnStats feeds a campaign statistics channel with items // // while hasMore is true and all items have been consumed in the channel // a new request is fired using the since parameter of the response to // retrieve new items // // when HasMore is false we close the channel
func yieldCampaignStats(csc chan CampaignStatStruct, resp *CampaignStatsResponse, cs *CampaignStats, campaignID string) {
	for {
		for _, item := range resp.Items {
			csc <- item
		}
		if !resp.HasMore {
			close(csc)
			return
		}
		params := map[string]string{
			"since": strconv.FormatInt(resp.LastTimestamp, 10),
		}
		resp, err := cs.Get(campaignID, params)
		if err != nil {
			panic(err)
		}
		yieldCampaignStats(csc, resp, cs, campaignID)
		return
	}
}
func yieldCampaignStats ( csc chan CampaignStatStruct , resp * CampaignStatsResponse , cs * CampaignStats , campaignID string ) { for { for _ , item := range resp . Items { csc <- item } if ! resp . HasMore { close ( csc ) return } params := map [ string ] string { " " : strconv . FormatInt ( resp . LastTimestamp , 10 ) , } resp , err := cs . Get ( campaignID , params ) if err != nil { panic ( err ) } yieldCampaignStats ( csc , resp , cs , campaignID ) return } }
campagnStats feeds a campaign statistics channel with items
campagnStats feeds a campaign statistics channel with items