ListUserSocialAccountsIter returns an iterator that paginates through all results of ListUserSocialAccounts.
(ctx context.Context, username string, opts *ListOptions)
| 7601 | |
| 7602 | // ListUserSocialAccountsIter returns an iterator that paginates through all results of ListUserSocialAccounts. |
| 7603 | func (s *UsersService) ListUserSocialAccountsIter(ctx context.Context, username string, opts *ListOptions) iter.Seq2[*SocialAccount, error] { |
| 7604 | return func(yield func(*SocialAccount, error) bool) { |
| 7605 | // Create a copy of opts to avoid mutating the caller's struct |
| 7606 | if opts == nil { |
| 7607 | opts = &ListOptions{} |
| 7608 | } else { |
| 7609 | opts = Ptr(*opts) |
| 7610 | } |
| 7611 | |
| 7612 | for { |
| 7613 | results, resp, err := s.ListUserSocialAccounts(ctx, username, opts) |
| 7614 | if err != nil { |
| 7615 | yield(nil, err) |
| 7616 | return |
| 7617 | } |
| 7618 | |
| 7619 | for _, item := range results { |
| 7620 | if !yield(item, nil) { |
| 7621 | return |
| 7622 | } |
| 7623 | } |
| 7624 | |
| 7625 | if resp.NextPage == 0 { |
| 7626 | break |
| 7627 | } |
| 7628 | opts.Page = resp.NextPage |
| 7629 | } |
| 7630 | } |
| 7631 | } |