users

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package users supports queries for user lookup.

To look up one or more users by ID, use users.Lookup. Additional IDs can be given in the options:

single := users.Lookup("12", nil)
multi := users.Lookup("12", &users.LookupOpts{
   More: []string{"16431281", "2805856351"},
})

By default only the default fields are returned (see types.User). To request additional fields or expansions, include them in the options:

q := users.Lookup("12", &users.LookupOpts{
   Optional: []types.Fields{
      types.UserFields{Description: true, PublicMetrics: true},
   },
})

To look up users by username, use users.LookupByName. As above, additional usernames can be included in the option keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListOpts

type ListOpts struct {
	// A pagination token provided by the server.
	PageToken string

	// The maximum number of results to return; 0 means let the server choose.
	// The service will accept values up to 100.
	MaxResults int

	// Optional response fields and expansions.
	Optional []types.Fields
}

ListOpts provide parameters for listing user memberships. A nil *ListOpts provides empty values for all fields.

type LookupOpts

type LookupOpts struct {
	// Additional usernames or IDs to query
	More []string

	// Optional response fields and expansions.
	Optional []types.Fields
}

LookupOpts provide parameters for user lookup. A nil *LookupOpts provides empty values for all fields.

type Query

type Query struct {
	*jape.Request
}

A Query performs a lookup query for one or more users.

func BlockedBy

func BlockedBy(userID string, opts *ListOpts) Query

BlockedBy returns a query for those the specified user ID is blocking.

API: 2/users/:id/blocking

func FollowedBy

func FollowedBy(userID string, opts *ListOpts) Query

FollowedBy returns a query for those the specified user ID is following.

API: 2/users/:id/following

func FollowersOf

func FollowersOf(userID string, opts *ListOpts) Query

FollowersOf returns a query for the followers of the specified user ID.

API: 2/users/:id/followers

func LikersOf

func LikersOf(id string, opts *ListOpts) Query

LikersOf constructs a query for the users who like a given tweet ID.

API: 2/tweets/:id/liking_users

BUG: The service does not understand pagination for this endpoint. It appears to return a fixed number of responses regardless how many there actually are. If you set MaxResults or PageToken in the options, the request will report an error.

func Lookup

func Lookup(id string, opts *LookupOpts) Query

Lookup constructs a lookup query for one or more users by ID. To look up multiple IDs, add subsequent values to the opts.More field.

API: 2/users

func LookupByName

func LookupByName(name string, opts *LookupOpts) Query

LookupByName constructs a lookup query for one or more users by username. To look up multiple usernames, add subsequent values to the opts.More field.

API: 2/users/by

func Me

func Me(opts *LookupOpts) Query

func MutedBy

func MutedBy(userID string, opts *ListOpts) Query

MutedBy returns a query for those the specified user ID is muting.

API: 2/users/:id/muting

func RetweetersOf

func RetweetersOf(tweetID string, opts *ListOpts) Query

RetweetersOf returns a query for users who retweeted the specified tweet ID.

API: 2/tweets/:id/retweeted_by

func (Query) HasMorePages

func (q Query) HasMorePages() bool

HasMorePages reports whether the query has more pages to fetch. This is true for a freshly-constructed query, and for an invoked query where the server has not reported a next-page token.

func (Query) Invoke

func (q Query) Invoke(ctx context.Context, cli *twitter.Client) (*Reply, error)

Invoke executes the query on the given context and client.

func (Query) ResetPageToken

func (q Query) ResetPageToken()

ResetPageToken clears (resets) the query's current page token. Subsequently invoking the query will then fetch the first page of results.

type Reply

type Reply struct {
	*twitter.Reply
	Users types.Users
	Meta  *twitter.Pagination
}

A Reply is the response from a Query.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL