twitter

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 11 Imported by: 0

README

docs

Twitter API Wrapper

This package wraps the references defined by the Twitter API, and can be installed using

go get github.com/alpine-hodler/web/pkg/twitter

Creating a Client

The twitter.Client type is a wrapper for the Go net/http standard library package. An http.RoundTripper is required to authenticate for Twitter requests. All Twitter authentication methods are supported. See the documentation for examples.

Note that basic authentication is restricted to enterprise accounts

The email and password combination are the same ones that you will use to access the enterprise API console

Development

Notes on developing in this package.

Testing

You will need to Sign up for access to the Twitter API and generate the APP keys. Then populate the following data in pkg/twitter/.simple-test.env:

TWITTER_URL=https://api.twitter.com
TWITTER_CLIENT_ID=
TWITTER_CLIENT_SECRET=

# Basic
TWITTER_ENTERPRISE_EMAIL=
TWITTER_ENTERPRISE_PASSWORD=

# OAuth2
TWITTER_BEARER_TOKEN=

# OAuth 1
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_SECRET=
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=

Note that pkg/twitter/.simple-test.env is an ignored file and should not be commitable to the repository.

Priming a Refresh Token

To run the integration tests, you will need to prime a refresh token to make HTTP requests that require OAuth 2.0 User Context. Just follow the guide here to get a refresh token. If this is your first time, you'll need to run the below curl command to generate the refresh_token.json template used for testing. Then copy and paste the output of that file into refresh_token.json.

curl -u $CLIENT_ID:$CLIENT_SECRET \
-X POST 'https://api.twitter.com/2/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "refresh_token=$REFRESH_TOKEN" \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode "client_id=$CLIENT_ID" \
| jq
OAuth 2.0 User Context

Some of the requests requires OAuth 2.0 User Context, which requires a refresh token to use programatically. To get an access token through postman, follow the guide here. In general, the following should suffice:

  • Grant Type: Authorization Code (With PKCE)
  • Callback URL: https://oauth.pstmn.io/v1/callback
  • Auth URL: https://twitter.com/i/oauth2/authorize
  • Access Token URL: https://api.twitter.com/2/oauth2/token
  • Client ID: see developer portal
  • Client Secret: see developer portal
  • Code Challenge Method: SHA-256
  • State: state
  • Client Authentication: Send as Basic Auth header

To get a refresh token add offline.access to the scope.

Documentation

Index

Examples

Constants

View Source
const (
	AllTweetsPath rawPath
	BookmarksPath
	ComplianceJobsPath
	CreateBookmarkPath
	DeleteBookmarkPath
	MePath
	TweetsPath
)
View Source
const (
	AllTweetsRatelimiter ratelimiter
	BookmarksRatelimiter
	ComplianceJobsRatelimiter
	CreateBookmarkRatelimiter
	DeleteBookmarkRatelimiter
	MeRatelimiter
	TweetsRatelimiter
)
View Source
const (
	TwitterISO8601 = "2006-01-02T15:04:05.000Z"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllTweetsOptions

type AllTweetsOptions struct {
	// MaxResults are the maximum number of search results to be returned by a request. A number between 10 and the system
	// limit (currently 500). By default, a request response will return 10 results.
	MaxResults *int `bson:"max_results" json:"max_results" sql:"max_results"`
}

AllTweetsOptions are options for API requests.

func (*AllTweetsOptions) EncodeBody

func (opts *AllTweetsOptions) EncodeBody() (buf io.Reader, err error)

func (*AllTweetsOptions) EncodeQuery

func (opts *AllTweetsOptions) EncodeQuery(req *http.Request)

func (*AllTweetsOptions) SetMaxResults

func (opts *AllTweetsOptions) SetMaxResults(MaxResults int) *AllTweetsOptions

SetMaxResults sets the MaxResults field on AllTweetsOptions. MaxResults are the maximum number of search results to be returned by a request. A number between 10 and the system limit (currently 500). By default, a request response will return 10 results.

type Annotation

type Annotation struct {
	// End is the end position (zero based) of the text used to annotate the Tweet. While all other end indices are
	// exclusive, this one is inclusive.
	End int `bson:"end" json:"end" sql:"end"`

	// NormalizedText is the text used to determine the annotation type.
	NormalizedText string `bson:"normalized_text" json:"normalized_text" sql:"normalized_text"`

	// Probability is the confidence score for the annotation as it correlates to the Tweet text.
	Probability float64 `bson:"probability" json:"probability" sql:"probability"`

	// Start is the start position (zero-based) of the text used to annotate the Tweet. All start indices are inclusive.
	Start int `bson:"start" json:"start" sql:"start"`

	// Type is the description of the type of entity identified when the Tweet text was interpreted.
	Type string `bson:"type" json:"type" sql:"type"`
}

Annotations are details about annotations relative to the text within a Tweet.

type Attachments

type Attachments struct {
	// MediaKeys is a list of unique identifiers of media attached to this Tweet. These identifiers use the same media key
	// format as those returned by the Media Library. You can obtain the expanded object in includes.media by adding
	// expansions=attachments.media_keys in the request's query parameter.
	MediaKeys []string `bson:"media_keys" json:"media_keys" sql:"media_keys"`

	// PollIds list of unique identifiers of polls present in the Tweets returned. These are returned as a string in order
	// to avoid complications with languages and tools that cannot handle large integers.
	PollIds []string `bson:"poll_ids" json:"poll_ids" sql:"poll_ids"`
}

TODO

type Bookmark

type Bookmark struct {
	// Attachments specifies the type of attachments (if any) present in this Tweet. To return this field, add
	// tweet.fields=attachments in the request's query parameter.
	Attachments *Attachments `bson:"attachments" json:"attachments" sql:"attachments"`

	// Authur is the inique identifier of this user. This is returned as a string in order to avoid complications with
	// languages and tools that cannot handle large integers. You can obtain the expanded object in includes.users by adding
	// expansions=author_id in the request's query parameter.
	AuthorID string `bson:"author_id" json:"author_id" sql:"author_id"`

	// Bookmarked indicates whether the user has removed the Bookmark of the specified Tweet. specified Tweet as a result of
	// this request. The returned value is false for a successful request. If the data has been created through a POST
	// method, Bookmarked indicates whether the user bookmarks the specified Tweet as a result of this request.
	Bookmarked bool `bson:"bookmarked" json:"bookmarked" sql:"bookmarked"`

	// ContextAnnotations are context annotations for the Tweet. To return this field, add tweet.fields=context_annotations
	// in the request's query parameter.
	ContextAnnotations []*ContextAnnotation `bson:"context_annotations" json:"context_annotations" sql:"context_annotations"`

	// ConversationID is the Tweet ID of the original Tweet of the conversation (which includes direct replies, replies of
	// replies). To return this field, add tweet.fields=conversation_id in the request's query parameter.
	ConversationID string `bson:"conversation_id" json:"conversation_id" sql:"conversation_id"`

	// CreatedAt is the creation time of the Tweet.
	CreatedAt time.Time `bson:"created_at" json:"created_at" sql:"created_at"`

	// Entities contain details about text that has a special meaning in a Tweet. To return this field, add
	// tweet.fields=entities in the request's query parameter.
	Entities *Entities `bson:"entities" json:"entities" sql:"entities"`

	// Geo contains details about the location tagged by the user in this Tweet, if they specified one. To return this
	// field, add tweet.fields=geo in the request's query parameter.
	Geo *Geo `bson:"geo" json:"geo" sql:"geo"`

	// ID is a unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages
	// and tools that cannot handle large integers.
	ID string `bson:"id" json:"id" sql:"id"`

	// InReplyToUserID indicates the user ID of the parent Tweet's author. This is returned as a string in order to avoid
	// complications with languages and tools that cannot handle large integers. You can obtain the expanded object in
	// includes.users by adding expansions=in_reply_to_user_id in the request's query parameter.
	InReplyToUserID string `bson:"in_reply_to_user_id" json:"in_reply_to_user_id" sql:"in_reply_to_user_id"`

	// NonPublicMetrics are non-public engagement metrics for the Tweet at the time of the request. This is a private
	// metric, and requires the use of OAuth 2.0 User Context authentication. To return this field, add
	// tweet.fields=non_public_metrics in the request's query parameter.
	NonPublicMetrics *NonPublicMetrics `bson:"non_public_metrics" json:"non_public_metrics" sql:"non_public_metrics"`

	// OrganicMetrics are organic engagement metrics for the Tweet at the time of the request. Requires user context
	// authentication.
	OrganicMetrics *OrganicMetrics `bson:"organic_metrics" json:"organic_metrics" sql:"organic_metrics"`

	// PromotedMetrics are engagement metrics for the Tweet at the time of the request in a promoted context. Requires user
	// context authentication.
	PromotedMetrics *PromotedMetrics `bson:"promoted_metrics" json:"promoted_metrics" sql:"promoted_metrics"`

	// PublicMetrics are the engagement metrics for the Tweet at the time of the request. To return this field, add
	// tweet.fields=public_metrics in the request's query parameter.
	PublicMetrics *PublicMetrics `bson:"public_metrics" json:"public_metrics" sql:"public_metrics"`

	// ReferencedTweets is a list of Tweets this Tweet refers to. For example, if the parent Tweet is a Retweet, a Retweet
	// with comment (also known as Quoted Tweet) or a Reply, it will include the related Tweet referenced to by its parent.
	// To return this field, add tweet.fields=referenced_tweets in the request's query parameter.
	ReferencedTweets []*ReferencedTweet `bson:"referenced_tweets" json:"referenced_tweets" sql:"referenced_tweets"`

	// Text is the content of the Tweet.
	Text string `bson:"text" json:"text" sql:"text"`

	// Withheld contains withholding details for withheld content. To return this field, add tweet.fields=withheld in the
	// request's query parameter.
	Withheld          *Withheld              `bson:"withheld" json:"withheld" sql:"withheld"`
	Errors            map[string]interface{} `bson:"errors" json:"errors" sql:"errors"`
	Includes          map[string]interface{} `bson:"includes" json:"includes" sql:"includes"`
	Lang              string                 `bson:"lang" json:"lang" sql:"lang"`
	PossiblySensitive bool                   `bson:"possibly_sensitive" json:"possibly_sensitive" sql:"possibly_sensitive"`
	ReplySettings     string                 `bson:"reply_settings" json:"reply_settings" sql:"reply_settings"`
	Source            string                 `bson:"source" json:"source" sql:"source"`
}

TODO

type BookmarkWrite

type BookmarkWrite struct {
	Data Bookmarked `bson:"data" json:"data" sql:"data"`
	Meta Meta       `bson:"meta" json:"meta" sql:"meta"`
}

BookmarkWrite details the results from a bookmark write operation.

type Bookmarked

type Bookmarked struct {
	Bookmarked bool `bson:"Bookmarked" json:"Bookmarked" sql:"Bookmarked"`
}

Bookmarked holds details about the status of a bookmark write.

type Bookmarks

type Bookmarks struct {
	Data []*Bookmark `bson:"data" json:"data" sql:"data"`
	Meta Meta        `bson:"meta" json:"meta" sql:"meta"`
}

TODO

type BookmarksOptions

type BookmarksOptions struct {
	// Expansions enable you to request additional data objects that relate to the originally returned Tweets. Submit a list
	// of desired expansions in a comma-separated list without spaces. The ID that represents the expanded data object will
	// be included directly in the Tweet data object, but the expanded object metadata will be returned within the includes
	// response object, and will also include the ID so that you can match this data object to the original Tweet object.
	Expansions *Expansions `bson:"expansions" json:"expansions" sql:"expansions"`

	// MaxResults are the maximum number of results to be returned per page. This can be a number between 1 and 100. By
	// default, each page will return 100 results.
	MaxResults *uint8 `bson:"max_results" json:"max_results" sql:"max_results"`

	// MediaField enables you to select which specific media fields will deliver in each returned Tweet. Specify the desired
	// fields in a comma-separated list without spaces between commas and fields. The Tweet will only return media fields if
	// the Tweet contains media and if you've also included the expansions=attachments.media_keys query parameter in your
	// request. While the media ID will be located in the Tweet object, you will find this ID and all additional media
	// fields in the includes data object.
	MediaFields *MediaFields `bson:"media.fields" json:"media.fields" sql:"media.fields"`

	// Pagination token is used to request the next page of results if all results weren't returned with the latest request,
	// or to go back to the previous page of results. To return the next page, pass the next_token returned in your previous
	// response. To go back one page, pass the previous_token returned in your previous response.
	PaginationToken *string `bson:"pagination_token" json:"pagination_token" sql:"pagination_token"`

	// PlaceFields enables you to select which specific place fields will deliver in each returned Tweet. Specify the
	// desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return place
	// fields if the Tweet contains a place and if you've also included the expansions=geo.place_id query parameter in your
	// request. While the place ID will be located in the Tweet object, you will find this ID and all additional place
	// fields in the includes data object.
	PlaceFields *PlaceFields `bson:"place.fields" json:"place.fields" sql:"place.fields"`

	// PollFields enables you to select which specific poll fields will deliver in each returned Tweet. Specify the desired
	// fields in a comma-separated list without spaces between commas and fields. The Tweet will only return poll fields if
	// the Tweet contains a poll and if you've also included the expansions=attachments.poll_ids query parameter in your
	// request. While the poll ID will be located in the Tweet object, you will find this ID and all additional poll fields
	// in the includes data object.
	PollFields *PollFields `bson:"poll.fields" json:"poll.fields" sql:"poll.fields"`

	// TweetFields enables you to select which specific Tweet fields will deliver in each returned Tweet object. Specify the
	// desired fields in a comma-separated list without spaces between commas and fields. You can also pass the
	// expansions=referenced_tweets.id expansion to return the specified fields for both the original Tweet and any included
	// referenced Tweets. The requested Tweet fields will display in both the original Tweet data object, as well as in the
	// referenced Tweet expanded data object that will be located in the includes data object.
	TweetFields *TweetFields `bson:"tweet.fields" json:"tweet.fields" sql:"tweet.fields"`

	// TweetFields enables you to select which specific user fields will deliver in each returned Tweet. Specify the desired
	// fields in a comma-separated list without spaces between commas and fields. While the user ID will be located in the
	// original Tweet object, you will find this ID and all additional user fields in the includes data object.
	UserFields *UserFields `bson:"user.fields" json:"user.fields" sql:"user.fields"`
}

BookmarksOptions are options for API requests.

func (*BookmarksOptions) EncodeBody

func (opts *BookmarksOptions) EncodeBody() (buf io.Reader, err error)

func (*BookmarksOptions) EncodeQuery

func (opts *BookmarksOptions) EncodeQuery(req *http.Request)

func (*BookmarksOptions) SetExpansions

func (opts *BookmarksOptions) SetExpansions(Expansions Expansions) *BookmarksOptions

SetExpansions sets the Expansions field on BookmarksOptions. Expansions enable you to request additional data objects that relate to the originally returned Tweets. Submit a list of desired expansions in a comma-separated list without spaces. The ID that represents the expanded data object will be included directly in the Tweet data object, but the expanded object metadata will be returned within the includes response object, and will also include the ID so that you can match this data object to the original Tweet object.

func (*BookmarksOptions) SetMaxResults

func (opts *BookmarksOptions) SetMaxResults(MaxResults uint8) *BookmarksOptions

SetMaxResults sets the MaxResults field on BookmarksOptions. MaxResults are the maximum number of results to be returned per page. This can be a number between 1 and 100. By default, each page will return 100 results.

func (*BookmarksOptions) SetMediaFields

func (opts *BookmarksOptions) SetMediaFields(MediaFields MediaFields) *BookmarksOptions

SetMediaFields sets the MediaFields field on BookmarksOptions. MediaField enables you to select which specific media fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return media fields if the Tweet contains media and if you've also included the expansions=attachments.media_keys query parameter in your request. While the media ID will be located in the Tweet object, you will find this ID and all additional media fields in the includes data object.

func (*BookmarksOptions) SetPaginationToken

func (opts *BookmarksOptions) SetPaginationToken(PaginationToken string) *BookmarksOptions

SetPaginationToken sets the PaginationToken field on BookmarksOptions. Pagination token is used to request the next page of results if all results weren't returned with the latest request, or to go back to the previous page of results. To return the next page, pass the next_token returned in your previous response. To go back one page, pass the previous_token returned in your previous response.

func (*BookmarksOptions) SetPlaceFields

func (opts *BookmarksOptions) SetPlaceFields(PlaceFields PlaceFields) *BookmarksOptions

SetPlaceFields sets the PlaceFields field on BookmarksOptions. PlaceFields enables you to select which specific place fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return place fields if the Tweet contains a place and if you've also included the expansions=geo.place_id query parameter in your request. While the place ID will be located in the Tweet object, you will find this ID and all additional place fields in the includes data object.

func (*BookmarksOptions) SetPollFields

func (opts *BookmarksOptions) SetPollFields(PollFields PollFields) *BookmarksOptions

SetPollFields sets the PollFields field on BookmarksOptions. PollFields enables you to select which specific poll fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return poll fields if the Tweet contains a poll and if you've also included the expansions=attachments.poll_ids query parameter in your request. While the poll ID will be located in the Tweet object, you will find this ID and all additional poll fields in the includes data object.

func (*BookmarksOptions) SetTweetFields

func (opts *BookmarksOptions) SetTweetFields(TweetFields TweetFields) *BookmarksOptions

SetTweetFields sets the TweetFields field on BookmarksOptions. TweetFields enables you to select which specific Tweet fields will deliver in each returned Tweet object. Specify the desired fields in a comma-separated list without spaces between commas and fields. You can also pass the expansions=referenced_tweets.id expansion to return the specified fields for both the original Tweet and any included referenced Tweets. The requested Tweet fields will display in both the original Tweet data object, as well as in the referenced Tweet expanded data object that will be located in the includes data object.

func (*BookmarksOptions) SetUserFields

func (opts *BookmarksOptions) SetUserFields(UserFields UserFields) *BookmarksOptions

SetUserFields sets the UserFields field on BookmarksOptions. TweetFields enables you to select which specific user fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. While the user ID will be located in the original Tweet object, you will find this ID and all additional user fields in the includes data object.

type Cashtag

type Cashtag struct {
	// End is the end position (zero-based) of the recognized Cashtag within the Tweet. This end index is exclusive.
	End int `bson:"end" json:"end" sql:"end"`

	// Start is the start position (zero-based) of the recognized Cashtag within the Tweet. All start indices are inclusive.
	Start int `bson:"start" json:"start" sql:"start"`

	// Tag is the text of the Cashtag.
	Tag string `bson:"tag" json:"tag" sql:"tag"`
}

Cashtag contains details about text recognized as a Cashtag.

type Client

type Client struct{ http.Client }

Client is a wrapper for http.Client.

func NewClient

func NewClient(_ context.Context, transport transport.T) (*Client, error)

NewClient will return an HTTP client to interface with the Twitter API.

Example (Basic)
package main

import (
	"context"
	"os"

	"fmt"

	"github.com/alpine-hodler/web/pkg/transport"
	"github.com/alpine-hodler/web/pkg/twitter"
)

func main() {
	// Read credentials from environment variables.
	email := os.Getenv("TWITTER_ENTERPRISE_EMAIL")
	password := os.Getenv("TWITTER_ENTERPRISE_PASSWORD")
	url := os.Getenv("TWITTER_URL")

	// Initialize an Basic client transport
	basic := transport.NewBasic().SetEmail(email).SetPassword(password).SetURL(url)

	// Initialize client using the Auth2 client transport.
	client, _ := twitter.NewClient(context.TODO(), basic)
	fmt.Printf("Twitter client: %+v\n", client)
}
Output:

Example (Oauth1)
package main

import (
	"context"
	"log"
	"os"

	"fmt"

	"github.com/alpine-hodler/web/pkg/transport"
	"github.com/alpine-hodler/web/pkg/twitter"
)

func main() {
	// Read credentials from environment variables.
	consumerKey := os.Getenv("TWITTER_CONSUMER_KEY")
	consumerSecret := os.Getenv("TWITTER_CONSUMER_SECRET")
	accessToken := os.Getenv("TWITTER_ACCESS_TOKEN")
	accessSecret := os.Getenv("TWITTER_ACCESS_SECRET")
	url := os.Getenv("TWITTER_URL")

	// Initialize an Auth1 client transport.
	oauth1 := transport.NewAuth1().
		SetAccessToken(accessToken).
		SetAccessTokenSecret(accessSecret).
		SetConsumerKey(consumerKey).
		SetConsumerSecret(consumerSecret).
		SetURL(url)

	// Initialize client using the Auth1 client transport.
	client, err := twitter.NewClient(context.TODO(), oauth1)
	if err != nil {
		log.Fatalf("Error creating new client: %v", err)
	}

	// Fetch some tweets to test the connection.
	tweet, err := client.Tweets(new(twitter.TweetsOptions).SetIds([]string{"1261326399320715264"}))
	if err != nil {
		log.Fatalf("Error fetching MongoDB tweet: %v", err)
	}

	fmt.Printf("A tweet about MongoDB: %+v\n", tweet.Data[0])
}
Output:

Example (Oauth2)
package main

import (
	"context"
	"log"
	"os"

	"fmt"

	"github.com/alpine-hodler/web/pkg/transport"
	"github.com/alpine-hodler/web/pkg/twitter"
)

func main() {
	// Read credentials from environment variables.
	bearerToken := os.Getenv("TWITTER_BEARER_TOKEN")
	url := os.Getenv("TWITTER_URL")

	// Initialize an Auth2 client transport
	oauth2 := transport.NewAuth2().SetBearer(bearerToken).SetURL(url)

	// Initialize client using the Auth2 client transport.
	client, err := twitter.NewClient(context.TODO(), oauth2)
	if err != nil {
		log.Fatalf("Error creating new client: %v", err)
	}

	// Fetch some tweets to test the connection.
	tweet, err := client.Tweets(new(twitter.TweetsOptions).SetIds([]string{"1261326399320715264"}))
	if err != nil {
		log.Fatalf("Error fetching MongoDB tweet: %v", err)
	}

	fmt.Printf("A tweet about MongoDB: %+v\n", tweet.Data[0])
}
Output:

func (*Client) Bookmarks

func (c *Client) Bookmarks(userId string, opts *BookmarksOptions) (m *Bookmarks, _ error)

Bookmarks allows you to get information about a authenticated user’s 800 most recent bookmarked Tweets. This request requires OAuth 2.0 Authorization Code with PKCE.

source: https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/get-users-id-bookmarks

Example
package main

import (
	"context"
	"log"
	"os"

	"fmt"

	"github.com/alpine-hodler/web/pkg/transport"
	"github.com/alpine-hodler/web/pkg/twitter"
)

func main() {
	// Read credentials from environment variables.
	bearerToken := os.Getenv("TWITTER_OAUTH2_USER_CONTEXT")
	url := os.Getenv("TWITTER_URL")
	userID := os.Getenv("TWITER_USER_ID")

	// Initialize an Auth1 client transport.
	oauth2 := transport.NewAuth2().SetBearer(bearerToken).SetURL(url)

	// Initialize client using the Auth1 client transport.
	client, err := twitter.NewClient(context.TODO(), oauth2)
	if err != nil {
		log.Fatalf("Error creating new client: %v", err)
	}

	options := new(twitter.BookmarksOptions).
		SetMaxResults(uint8(5)).
		SetTweetFields(twitter.TweetFields{
			twitter.TweetFieldCreatedAt,
			twitter.TweetFieldInReplyToUserID,
			twitter.TweetFieldReferencedTweets,
			twitter.TweetFieldAttachments,
			twitter.TweetFieldAuthorID,
			twitter.TweetFieldEntities}).
		SetExpansions(twitter.Expansions{
			twitter.ExpansionAttachmentsMediaKeys})

	// Fetch some tweets to test the connection.
	bookmarks, err := client.Bookmarks(userID, options)
	if err != nil {
		log.Fatalf("Error fetching MongoDB tweet: %v", err)
	}
	fmt.Printf("Bookmarks: %+v\n", bookmarks.Data[0])
}
Output:

func (*Client) ComplianceJobs

func (c *Client) ComplianceJobs(opts *ComplianceJobsOptions) (m []*Compliance, _ error)

ComplianceJobs will return a list of recent compliance jobs.

source: https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/introduction

func (*Client) CreateBookmark

func (c *Client) CreateBookmark(userId string, opts *CreateBookmarkOptions) (m BookmarkWrite, _ error)

CreateBookmarks causes the user ID of an authenticated user identified in the path parameter to Bookmark the target Tweet provided in the request body. This request requires OAuth 2.0 Authorization Code with PKCE.

source: https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/post-users-id-bookmarks

Example
package main

import (
	"context"
	"log"
	"os"

	"fmt"

	"github.com/alpine-hodler/web/pkg/transport"
	"github.com/alpine-hodler/web/pkg/twitter"
)

func main() {
	// Read credentials from environment variables.
	bearerToken := os.Getenv("TWITTER_OAUTH2_USER_CONTEXT")
	url := os.Getenv("TWITTER_URL")
	userID := os.Getenv("TWITER_USER_ID")

	// Initialize an Auth1 client transport.
	oauth2 := transport.NewAuth2().SetBearer(bearerToken).SetURL(url)

	// Initialize client using the Auth1 client transport.
	client, err := twitter.NewClient(context.TODO(), oauth2)
	if err != nil {
		log.Fatalf("Error creating new client: %v", err)
	}

	options := new(twitter.CreateBookmarkOptions).SetTweetID("1529619581140099072")

	// Fetch some tweets to test the connection.
	bookmarkWrite, err := client.CreateBookmark(userID, options)
	if err != nil {
		log.Fatalf("Error fetching MongoDB tweet: %v", err)
	}
	fmt.Printf("Bookmark created: %+v\n", bookmarkWrite)
}
Output:

func (*Client) DeleteBookmark

func (c *Client) DeleteBookmark(userId string, tweetId string) (m BookmarkWrite, _ error)

DeleteBookmarks are a core feature of the Twitter app that allows you to “save” Tweets and easily access them later. With these endpoints, you can retrieve, create, delete or build solutions to manage your Bookmarks via the API. This request requires OAuth 2.0 Authorization Code with PKCE

source: https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/delete-users-id-bookmarks-tweet_id

Example
package main

import (
	"context"
	"log"
	"os"

	"fmt"

	"github.com/alpine-hodler/web/pkg/transport"
	"github.com/alpine-hodler/web/pkg/twitter"
)

func main() {
	// Read credentials from environment variables.
	bearerToken := os.Getenv("TWITTER_OAUTH2_USER_CONTEXT")
	url := os.Getenv("TWITTER_URL")
	userID := os.Getenv("TWITER_USER_ID")

	// Initialize an Auth1 client transport.
	oauth2 := transport.NewAuth2().SetBearer(bearerToken).SetURL(url)

	// Initialize client using the Auth1 client transport.
	client, err := twitter.NewClient(context.TODO(), oauth2)
	if err != nil {
		log.Fatalf("Error creating new client: %v", err)
	}

	// Fetch some tweets to test the connection.
	bookmarkWrite, err := client.DeleteBookmark(userID, "1529619581140099072")
	if err != nil {
		log.Fatalf("Error fetching MongoDB tweet: %v", err)
	}
	fmt.Printf("Bookmark deleted: %+v\n", bookmarkWrite)
}
Output:

type Compliance

type Compliance struct {
	// CreatedAt is the date and time when the job was created.
	CreatedAt time.Time `bson:"created_at" json:"created_at" sql:"created_at"`

	// DownloadExpiresAt the date and time until which the download URL will be available (usually 7 days from the request
	// time).
	DownloadExpiresAt time.Time `bson:"download_expires_at" json:"download_expires_at" sql:"download_expires_at"`

	// DownloadURL is the predefined location where to download the results from the compliance job. This URL is already
	// signed with an authentication key, so you will not need to pass any additional credential or header to authenticate
	// the request.
	DownloadURL string `bson:"download_url" json:"download_url" sql:"download_url"`

	// Error returns when jobs.status is failed. Specifies the reason why the job did not complete successfully.
	Error string `bson:"error" json:"error" sql:"error"`

	// ID is the unique identifier for this job.
	ID string `bson:"id" json:"id" sql:"id"`

	// Meta returns meta information about the request.
	Meta Meta `bson:"meta" json:"meta" sql:"meta"`

	// Name is the user defined job name. Only returned if specified when the job was created.
	Name string `bson:"name" json:"name" sql:"name"`

	// Status is the status of this job.
	Status Status `bson:"status" json:"status" sql:"status"`

	// Type is the type of the job, whether tweets or users.
	Type ComplianceJob `bson:"type" json:"type" sql:"type"`

	// UploadExpiresAt represents the date and time until which the upload URL will be available (usually 15 minutes from
	// the request time).
	UploadExpiresAt time.Time `bson:"upload_expires_at" json:"upload_expires_at" sql:"upload_expires_at"`

	// UploadURL is a URL representing the location where to upload IDs consumed by your app. This URL is already signed
	// with an authentication key, so you will not need to pass any additional credentials or headers to authenticate the
	// request.
	UploadURL string `bson:"upload_url" json:"upload_url" sql:"upload_url"`
}

Compliance is some recent compliance jobs.

type ComplianceJob

type ComplianceJob string
const (
	ComplianceJobTweets ComplianceJob = "tweets"
	ComplianceJobUsers  ComplianceJob = "users"
)

func (*ComplianceJob) String

func (ComplianceJob *ComplianceJob) String() string

String will convert a ComplianceJob into a string.

type ComplianceJobsOptions

type ComplianceJobsOptions struct {
	// Status allows to filter by job status. Only one filter can be specified per request. Default: `all`
	Status *Status `bson:"status" json:"status" sql:"status"`

	// Type allows to filter by job type - either by tweets or user ID. Only one filter (tweets or users) can be specified
	// per request.
	Type ComplianceJob `bson:"type" json:"type" sql:"type"`
}

ComplianceJobsOptions are options for API requests.

func (*ComplianceJobsOptions) EncodeBody

func (opts *ComplianceJobsOptions) EncodeBody() (buf io.Reader, err error)

func (*ComplianceJobsOptions) EncodeQuery

func (opts *ComplianceJobsOptions) EncodeQuery(req *http.Request)

func (*ComplianceJobsOptions) SetStatus

func (opts *ComplianceJobsOptions) SetStatus(Status Status) *ComplianceJobsOptions

SetStatus sets the Status field on ComplianceJobsOptions. Status allows to filter by job status. Only one filter can be specified per request. Default: `all`

func (*ComplianceJobsOptions) SetType

SetType sets the Type field on ComplianceJobsOptions. Type allows to filter by job type - either by tweets or user ID. Only one filter (tweets or users) can be specified per request.

type ContextAnnotation

type ContextAnnotation struct {
	// Domain are elements which identify detailed information regarding the domain classification based on Tweet text.
	Domain Domain `bson:"domain" json:"domain" sql:"domain"`

	// Entity are elements which identify detailed information regarding the domain classification bases on Tweet text.
	Entity Entity `bson:"entity" json:"entity" sql:"entity"`
}

TODO

type Coordinates

type Coordinates struct {
	Coordinates []float64 `bson:"coordinates" json:"coordinates" sql:"coordinates"`
	Type        string    `bson:"type" json:"type" sql:"type"`
}

TODO

type CreateBookmarkOptions

type CreateBookmarkOptions struct {
	// TweetID is the ID of the Tweet that you would like the user id to Bookmark.
	TweetID *string `bson:"tweet_id" json:"tweet_id" sql:"tweet_id"`
}

CreateBookmarkOptions are options for API requests.

func (*CreateBookmarkOptions) EncodeBody

func (opts *CreateBookmarkOptions) EncodeBody() (buf io.Reader, err error)

func (*CreateBookmarkOptions) EncodeQuery

func (opts *CreateBookmarkOptions) EncodeQuery(req *http.Request)

func (*CreateBookmarkOptions) SetTweetID

func (opts *CreateBookmarkOptions) SetTweetID(TweetID string) *CreateBookmarkOptions

SetTweetID sets the TweetID field on CreateBookmarkOptions. TweetID is the ID of the Tweet that you would like the user id to Bookmark.

type Domain

type Domain struct {
	// Description is the Long form description of domain classification.
	Description string `bson:"description" json:"description" sql:"description"`

	// ID is the numeric value of the domain.
	ID string `bson:"id" json:"id" sql:"id"`

	// Name is the domain name based on the Tweet text.
	Name string `bson:"name" json:"name" sql:"name"`
}

Domain identifies detailed information regarding the domain classification based on Tweet text.

type Entities

type Entities struct {
	// Annotations contain details about annotations relative to the text within a Tweet.
	Annotations []*Annotation `bson:"annotations" json:"annotations" sql:"annotations"`

	// Cashtags contain details about text recognized as a Cashtag.
	Cashtags []*Cashtag `bson:"cashtags" json:"cashtags" sql:"cashtags"`

	// Hashtags contains details about text recognized as a Hashtag.
	Hashtags []*Hashtag `bson:"hashtags" json:"hashtags" sql:"hashtags"`

	// Mentions contains details about text recognized as a user mention.
	Mentions []*Mention `bson:"mentions" json:"mentions" sql:"mentions"`

	// Urls contains details about text recognized as a URL.
	Urls []*URL `bson:"urls" json:"urls" sql:"urls"`
}

Entities are details about text that has a special meaning in a Tweet. To return this field, add tweet.fields=entities in the request's query parameter.

type Entity

type Entity struct {
	// Description is additional information regarding referenced entity.
	Description string `bson:"description" json:"description" sql:"description"`

	// ID is a unique value which correlates to an explicitly mentioned Person, Place, Product or Organization.
	ID string `bson:"id" json:"id" sql:"id"`

	// Name is the name or reference of entity referenced in the Tweet.
	Name string `bson:"name" json:"name" sql:"name"`
}

Entity identifies detailed information regarding the domain classification bases on Tweet text.

type Expansion

type Expansion string
const (
	ExpansionAttachmentsPollIds         Expansion = "attachments.poll_ids"
	ExpansionAttachmentsMediaKeys       Expansion = "attachments.media_keys"
	ExpansionAuthorID                   Expansion = "author_id"
	ExpansionEntitiesMentionsUsername   Expansion = "entities.mentions.username"
	ExpansionGeoPlaceID                 Expansion = "geo.place_id"
	ExpansionInReplyToUserID            Expansion = "in_reply_to_user_id"
	ExpansionReferencedTweetsID         Expansion = "referenced_tweets.id"
	ExpansionReferencedTweetsIDAuthorID Expansion = "referenced_tweets.id.author_id"
)

func (*Expansion) String

func (Expansion *Expansion) String() string

String will convert a Expansion into a string.

type Expansions

type Expansions []Expansion

func (*Expansions) String

func (Expansions *Expansions) String() string

String will convert a slice of Expansion into a CSV.

type Geo

type Geo struct {
	Coordinates *Coordinates `bson:"coordinates" json:"coordinates" sql:"coordinates"`
	PlaceID     string       `bson:"place_id" json:"place_id" sql:"place_id"`
}

TODO

type Hashtag

type Hashtag struct {
	// End is the end position (zero-based) of the recognized Hashtag within the Tweet. This end index is exclusive.
	End int `bson:"end" json:"end" sql:"end"`

	// Start is the start position (zero-based) of the recognized Hashtag within the Tweet. All start indices are inclusive.
	Start int `bson:"start" json:"start" sql:"start"`

	// Tag is the text of the Hashtag.
	Tag string `bson:"tag" json:"tag" sql:"tag"`
}

Hashtag contains details about text recognized as a Hashtag.

type MediaField

type MediaField string
const (
	MediaFieldDurationMs       MediaField = "duration_ms"
	MediaFieldHeight           MediaField = "height"
	MediaFieldMediaKey         MediaField = "media_key"
	MediaFieldPreviewImageURL  MediaField = "preview_image_url"
	MediaFieldType             MediaField = "type"
	MediaFieldURL              MediaField = "url"
	MediaFieldWidth            MediaField = "width"
	MediaFieldPublicMetrics    MediaField = "public_metrics"
	MediaFieldNonPublicMetrics MediaField = "non_public_metrics"
	MediaFieldOrganicMetrics   MediaField = "organic_metrics"
	MediaFieldPromotedMetrics  MediaField = "promoted_metrics"
	MediaFieldAltText          MediaField = "alt_text"
)

func (*MediaField) String

func (MediaField *MediaField) String() string

String will convert a MediaField into a string.

type MediaFields

type MediaFields []MediaField

func (*MediaFields) String

func (MediaFields *MediaFields) String() string

String will convert a slice of MediaField into a CSV.

type Mention

type Mention struct {
	// End is the end position (zero-based) of the recognized user mention within the Tweet. This end index is exclusive.
	End int `bson:"end" json:"end" sql:"end"`

	// Start is the start position (zero-based) of the recognized user mention within the Tweet. All start indices are
	// inclusive.
	Start int `bson:"start" json:"start" sql:"start"`

	// Username is the part of text recognized as a user mention. You can obtain the expanded object in includes.users by
	// adding expansions=entities.mentions.username in the request's query parameter.
	Username string `bson:"username" json:"username" sql:"username"`
}

Mention contains details about text recognized as a user mention.

type Meta

type Meta struct {
	ResultCount int `bson:"result_count" json:"result_count" sql:"result_count"`
}

Meta holds metadata concerning requests

type NonPublicMetrics

type NonPublicMetrics struct {
	// ImpressionCount are the number of times the Tweet has been viewed. This is a private metric, and requires the use of
	// OAuth 2.0 User Context authentication..
	ImpressionCount int `bson:"impression_count" json:"impression_count" sql:"impression_count"`

	// URLLinkClicks are the number of times a user clicks on a URL link or URL preview card in a Tweet. This is a private
	// metric, and requires the use of OAuth 2.0 User Context authentication.
	URLLinkClicks int `bson:"url_link_clicks" json:"url_link_clicks" sql:"url_link_clicks"`

	// UserProfileClicks are the number of times a user clicks the following portions of a Tweet - display name, user name,
	// profile picture. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
	UserProfileClicks int `bson:"user_profile_clicks" json:"user_profile_clicks" sql:"user_profile_clicks"`
}

NonPublicMetrics are non-public engagement metrics for the Tweet at the time of the request. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.

type OrganicMetrics

type OrganicMetrics struct {
	// ImpressionCount is the number of times the Tweet has been viewed organically. This is a private metric, and requires
	// the use of OAuth 2.0 User Context authentication.
	ImpressionCount int `bson:"impression_count" json:"impression_count" sql:"impression_count"`

	// LikeCount is the number of likes the Tweet has received organically.
	LikeCount int `bson:"like_count" json:"like_count" sql:"like_count"`

	// ReplyCount is the number of replies the Tweet has received organically.
	ReplyCount int `bson:"reply_count" json:"reply_count" sql:"reply_count"`

	// RetweetCountis the number of times the Tweet has been Retweeted organically.
	RetweetCount int `bson:"retweet_count" json:"retweet_count" sql:"retweet_count"`

	// URLLinkClicks is the number of times a user clicks on a URL link or URL preview card in a Tweet organically. This is
	// a private metric, and requires the use of OAuth 2.0 User Context authentication.
	URLLinkClicks int `bson:"url_link_clicks" json:"url_link_clicks" sql:"url_link_clicks"`

	// UserProfileClicks is the number of times a user clicks the following portions of a Tweet organically - display name,
	// user name, profile picture. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
	UserProfileClicks int `bson:"user_profile_clicks" json:"user_profile_clicks" sql:"user_profile_clicks"`
}

OrganicMetrics are engagement metrics for the Tweet at the time of the request. Requires user context authentication.

type PlaceField

type PlaceField string
const (
	PlaceFieldContainedWithin PlaceField = "contained_within"
	PlaceFieldCountry         PlaceField = "country"
	PlaceFieldCountryCode     PlaceField = "country_code"
	PlaceFieldFullName        PlaceField = "full_name"
	PlaceFieldGeo             PlaceField = "geo"
	PlaceFieldID              PlaceField = "id"
	PlaceFieldName            PlaceField = "name"
	PlaceFieldPlaceType       PlaceField = "place_type"
)

func (*PlaceField) String

func (PlaceField *PlaceField) String() string

String will convert a PlaceField into a string.

type PlaceFields

type PlaceFields []PlaceField

func (*PlaceFields) String

func (PlaceFields *PlaceFields) String() string

String will convert a slice of PlaceField into a CSV.

type PollField

type PollField string
const (
	PollFieldDurationMinutes PollField = "duration_minutes"
	PollFieldEndDatetime     PollField = "end_datetime"
	PollFieldID              PollField = "id"
	PollFieldOptions         PollField = "options"
	PollFieldVotingStatus    PollField = "voting_status"
)

func (*PollField) String

func (PollField *PollField) String() string

String will convert a PollField into a string.

type PollFields

type PollFields []PollField

func (*PollFields) String

func (PollFields *PollFields) String() string

String will convert a slice of PollField into a CSV.

type PromotedMetrics

type PromotedMetrics struct {
	ImpressionCount   int `bson:"impression_count" json:"impression_count" sql:"impression_count"`
	LikeCount         int `bson:"like_count" json:"like_count" sql:"like_count"`
	ReplyCount        int `bson:"reply_count" json:"reply_count" sql:"reply_count"`
	RetweetCount      int `bson:"retweet_count" json:"retweet_count" sql:"retweet_count"`
	URLLinkClicks     int `bson:"url_link_clicks" json:"url_link_clicks" sql:"url_link_clicks"`
	UserProfileClicks int `bson:"user_profile_clicks" json:"user_profile_clicks" sql:"user_profile_clicks"`
}

PromotedMetrics are engagement metrics for the Tweet at the time of the request in a promoted context. Requires user context authentication.

type PublicMetrics

type PublicMetrics struct {
	// LikeCount is the number of Likes of this Tweet.
	LikeCount int `bson:"like_count" json:"like_count" sql:"like_count"`

	// QuoteCount is the number of times this Tweet has been Retweeted with a comment (also known as Quote).
	QuoteCount int `bson:"quote_count" json:"quote_count" sql:"quote_count"`

	// ReplyCount is the number of Replies of this Tweet.
	ReplyCount int `bson:"reply_count" json:"reply_count" sql:"reply_count"`

	// RetweetCount is the number of times this Tweet has been Retweeted.
	RetweetCount int `bson:"retweet_count" json:"retweet_count" sql:"retweet_count"`
}

PublicMetrics are the engagement metrics for the Tweet at the time of the request.

type ReferencedTweet

type ReferencedTweet struct {
	// ID is the unique identifier of the referenced Tweet. You can obtain the expanded object in includes.tweets by adding
	// expansions=referenced_tweets.id in the request's query parameter.
	ID string `bson:"id" json:"id" sql:"id"`

	// Type indicates the type of relationship between this Tweet and the Tweet returned in the response: retweeted (this
	// Tweet is a Retweet), quoted (a Retweet with comment, also known as Quoted Tweet), or replied_to (this Tweet is a
	// reply).
	Type string `bson:"type" json:"type" sql:"type"`
}

ReferencedTweet is a tweet referenced by another tweet.

type ReferencedTweetType

type ReferencedTweetType string
const (
	ReferencedTweetTypeRetweeted ReferencedTweetType = "retweeted"
	ReferencedTweetTypeQuoted    ReferencedTweetType = "quoted"
	ReferencedTweetTypeRepliedTo ReferencedTweetType = "replied_to"
)

func (*ReferencedTweetType) String

func (ReferencedTweetType *ReferencedTweetType) String() string

String will convert a ReferencedTweetType into a string.

type ReferencedTweetTypes

type ReferencedTweetTypes []ReferencedTweetType

func (*ReferencedTweetTypes) String

func (ReferencedTweetTypes *ReferencedTweetTypes) String() string

String will convert a slice of ReferencedTweetType into a CSV.

type Status

type Status string
const (
	StatusOnline     Status = "online"
	StatusOffline    Status = "offline"
	StatusInternal   Status = "internal"
	StatusDelisted   Status = "delisted"
	StatusPending    Status = "pending"
	StatusCreating   Status = "creating"
	StatusReady      Status = "ready"
	StatusCreated    Status = "created"
	StatusInProgress Status = "in_progress"
	StatusFailed     Status = "failed"
	StatusComplete   Status = "complete"
)

func (*Status) String

func (Status *Status) String() string

String will convert a Status into a string.

type Tweet

type Tweet struct {
	// Creation time of the Tweet. To return this field, add tweet.fields=created_at in the request's query parameter.
	CreatedAt time.Time `bson:"created_at" json:"created_at" sql:"created_at"`

	// ID is a unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages
	// and tools that cannot handle large integers.
	ID string `bson:"id" json:"id" sql:"id"`

	// Text is the content of the Tweet. To return this field, add tweet.fields=text in the request's query parameter.
	Text string `bson:"text" json:"text" sql:"text"`
}

TODO

type TweetField

type TweetField string
const (
	TweetFieldAttachments        TweetField = "attachments"
	TweetFieldAuthorID           TweetField = "author_id"
	TweetFieldContextAnnotations TweetField = "context_annotations"
	TweetFieldConversationID     TweetField = "conversation_id"
	TweetFieldCreatedAt          TweetField = "created_at"
	TweetFieldEntities           TweetField = "entities"
	TweetFieldGeo                TweetField = "geo"
	TweetFieldID                 TweetField = "id"
	TweetFieldInReplyToUserID    TweetField = "in_reply_to_user_id"
	TweetFieldLang               TweetField = "lang"
	TweetFieldNonPublicMetrics   TweetField = "non_public_metrics"
	TweetFieldPublicMetrics      TweetField = "public_metrics"
	TweetFieldOrganicMetrics     TweetField = "organic_metrics"
	TweetFieldPromotedMetrics    TweetField = "promoted_metrics"
	TweetFieldPossiblySensitive  TweetField = "possibly_sensitive"
	TweetFieldReferencedTweets   TweetField = "referenced_tweets"
	TweetFieldReplySettings      TweetField = "reply_settings"
	TweetFieldSource             TweetField = "source"
	TweetFieldText               TweetField = "text"
	TweetFieldWithheld           TweetField = "withheld"
)

func (*TweetField) String

func (TweetField *TweetField) String() string

String will convert a TweetField into a string.

type TweetFields

type TweetFields []TweetField

func (*TweetFields) String

func (TweetFields *TweetFields) String() string

String will convert a slice of TweetField into a CSV.

type Tweets

type Tweets struct {
	Data []*Tweet `bson:"data" json:"data" sql:"data"`
	Meta Meta     `bson:"meta" json:"meta" sql:"meta"`
}

TODO

type TweetsOptions

type TweetsOptions struct {
	// TODO
	Ids []string `bson:"ids" json:"ids" sql:"ids"`
}

TweetsOptions are options for API requests.

func (*TweetsOptions) EncodeBody

func (opts *TweetsOptions) EncodeBody() (buf io.Reader, err error)

func (*TweetsOptions) EncodeQuery

func (opts *TweetsOptions) EncodeQuery(req *http.Request)

func (*TweetsOptions) SetIds

func (opts *TweetsOptions) SetIds(Ids []string) *TweetsOptions

SetIds sets the Ids field on TweetsOptions. TODO

type URL

type URL struct {
	// DisplayUrl is the URL as displayed in the Twitter client.
	DisplayURL string `bson:"display_url" json:"display_url" sql:"display_url"`

	// End is the end position (zero-based) of the recognized URL within the Tweet. This end index is exclusive.
	End int `bson:"end" json:"end" sql:"end"`

	// ExpandedUrl is the The fully resolved URL.
	ExpandedURL string `bson:"expanded_url" json:"expanded_url" sql:"expanded_url"`

	// Start is the start position (zero-based) of the recognized URL within the Tweet. All start indices are inclusive.
	Start int `bson:"start" json:"start" sql:"start"`

	// UnwoundUrl is the full destination URL.
	UnwoundURL string `bson:"unwound_url" json:"unwound_url" sql:"unwound_url"`

	// Url is the URL in the format tweeted by the user.
	URL string `bson:"url" json:"url" sql:"url"`
}

Entity identifies detailed information regarding the domain classification bases on Tweet text.

type User

type User struct {
	// ID is a unique identifier of this user. This is returned as a string in order to avoid complications with languages
	// and tools that cannot handle large integers.
	ID string `bson:"id" json:"id" sql:"id"`
}

TODO

type UserField

type UserField string
const (
	UserFieldCreatedAt       UserField = "created_at"
	UserFieldDescription     UserField = "description"
	UserFieldEntities        UserField = "entities"
	UserFieldID              UserField = "id"
	UserFieldLocation        UserField = "location"
	UserFieldName            UserField = "name"
	UserFieldPinnedTweetID   UserField = "pinned_tweet_id"
	UserFieldProfileImageURL UserField = "profile_image_url"
	UserFieldProtected       UserField = "protected"
	UserFieldPublicMetrics   UserField = "public_metrics"
	UserFieldURL             UserField = "url"
	UserFieldUsername        UserField = "username"
	UserFieldVerified        UserField = "verified"
	UserFieldWithheld        UserField = "withheld"
)

func (*UserField) String

func (UserField *UserField) String() string

String will convert a UserField into a string.

type UserFields

type UserFields []UserField

func (*UserFields) String

func (UserFields *UserFields) String() string

String will convert a slice of UserField into a CSV.

type Withheld

type Withheld struct {
	// Copyright indicates if the content is being withheld for on the basis of copyright infringement.
	Copyright bool `bson:"copyright" json:"copyright" sql:"copyright"`

	// CountryCodes is a list of countries where this content is not available.
	CountryCodes []string `bson:"country_codes" json:"country_codes" sql:"country_codes"`

	// Scope indicates whether the content being withheld is a Tweet or a user.
	Scope WithholdingScope `bson:"scope" json:"scope" sql:"scope"`
}

Withheld contains withholding details for withheld content.

type WithholdingScope

type WithholdingScope string

WithholdingScope indicates whether the content being withheld is a Tweet or a user.

const (
	WithholdingScopeTweet WithholdingScope = "tweet"
	WithholdingScopeUser  WithholdingScope = "user"
)

func (*WithholdingScope) String

func (WithholdingScope *WithholdingScope) String() string

String will convert a WithholdingScope into a string.

type WithholdingScopes

type WithholdingScopes []WithholdingScope

func (*WithholdingScopes) String

func (WithholdingScopes *WithholdingScopes) String() string

String will convert a slice of WithholdingScope into a CSV.

Jump to

Keyboard shortcuts

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