yasuna

package
v0.0.0-...-253b301 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Attachment

type Attachment struct{}

TODO

type Counts

type Counts struct {
	Start      time.Time `json:"start"`
	End        time.Time `json:"end"`
	TweetCount int       `json:"tweet_count"`
}

type Deleted

type Deleted struct {
	Deleted bool `json:"deleted"`
}

type Entities

type Entities struct{}

TODO

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"
)

type Geo

type Geo struct{}

TODO

type GetTweetOption

type GetTweetOption interface {
	// contains filtered or unexported methods
}

type GetTweetsCountsOption

type GetTweetsCountsOption interface {
	// contains filtered or unexported methods
}

type GetTweetsSearchOption

type GetTweetsSearchOption interface {
	// contains filtered or unexported methods
}

type GetUserFollowOption

type GetUserFollowOption interface {
	// contains filtered or unexported methods
}

type GetUserTweetOption

type GetUserTweetOption interface {
	// contains filtered or unexported methods
}

type Granularity

type Granularity string
const (
	GranularityMinute Granularity = "minute"
	GranularityHour   Granularity = "hour"
	GranularityDay    Granularity = "day"
)

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"
)

type OAuth2

type OAuth2 struct {
	ClientID     string
	ClientSecret string
	RedirectURI  string
	Client       *http.Client
	// contains filtered or unexported fields
}

func (*OAuth2) AuthCodeURL

func (o *OAuth2) AuthCodeURL(scope ...Scope) string

func (*OAuth2) Exchange

func (o *OAuth2) Exchange(code, state string) (*Twitter, error)

func (*OAuth2) Refresh

func (o *OAuth2) Refresh(token *Token) error

type OrganicMetrics

type OrganicMetrics struct{}

TODO

type PlaceField

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

type PollField

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

type PostTweetGeoParams

type PostTweetGeoParams struct {
	PlaceID string `json:"place_id,omitempty"`
}

type PostTweetMediaParams

type PostTweetMediaParams struct {
	MediaIDs      []string `json:"media_ids,omitempty"`
	TaggedUserIDs []int64  `json:"tagged_user_ids,string,omitempty"`
}

type PostTweetParams

type PostTweetParams struct {
	DirectMessageDeepLink string                `json:"direct_message_deeplink,omitempty"`
	ForSuperFollowersOnly bool                  `json:"for_super_followers_only,omitempty"`
	Geo                   *PostTweetGeoParams   `json:"geo,omitempty"`
	Media                 *PostTweetMediaParams `json:"media,omitempty"`
	Poll                  *PostTweetPollParams  `json:"poll,omitempty"`
	QuoteTweetID          int64                 `json:"quote_tweet_id,string,omitempty"`
	Reply                 *PostTweetReplyParams `json:"reply,omitempty"`
	ReplySettings         string                `json:"reply_settings,omitempty"`
	Text                  string                `json:"text,omitempty"`
}

type PostTweetPollParams

type PostTweetPollParams struct {
	DurationMinutes int      `json:"duration_minutes,omitempty"`
	Options         []string `json:"options,omitempty"`
}

type PostTweetReplyParams

type PostTweetReplyParams struct {
	ExcludeReplyUserIDs []int64 `json:"exclude_reply_user_ids,string,omitempty"`
	InReplyToTweetID    int64   `json:"in_reply_to_tweet_id,string,omitempty"`
}

type PromotedMetrics

type PromotedMetrics struct{}

TODO

type PublicMetrics

type PublicMetrics struct{}

TODO

type ReferencedTweet

type ReferencedTweet struct {
	Type string `json:"type"`
	ID   int64  `json:"id,string"`
}

type Response

type Response[T any] struct {
	Data     T `json:"data"`
	Includes *struct {
		Users []*User `json:"users,omitempty"`
	} `json:"includes,omitempty"`
	Meta *struct {
		ResultCount     int    `json:"result_count"`
		NextToken       string `json:"next_token"`
		NewestID        int64  `json:"newest_id,string"`
		OldestID        int64  `json:"oldest_id,string"`
		TotalTweetCount int    `json:"total_tweet_count"`
	} `json:"meta,omitempty"`
}

func (*Response[T]) IncludeUser

func (r *Response[T]) IncludeUser(id int64) *User

type ResponseError

type ResponseError struct {
	Errors []struct {
		Parameters struct {
			Expansions []string `json:"expansions"`
		} `json:"parameters"`
		Message string `json:"message"`
	} `json:"errors"`
	Title  string `json:"title"`
	Detail string `json:"detail"`
	Type   string `json:"type"`
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

type Scope

type Scope string

Scope

https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code#scopes

const (
	// All the Tweets you can view, including Tweets from protected accounts.
	ScopeTweetRead Scope = "tweet.read"
	// Tweet and Retweet for you.
	ScopeTweetWrite Scope = "tweet.write"
	// Hide and unhide replies to your Tweets.
	ScopeTweetModerateWrite Scope = "tweet.moderate.write"
	// Any account you can view, including protected accounts.
	ScopeUsersRead Scope = "users.read"
	// People who follow you and people who you follow.
	ScopeFollowsRead Scope = "follows.read"
	// Follow and unfollow people for you.
	ScopeFollowsWrite Scope = "follows.write"
	// Stay connected to your account until you revoke access.
	ScopeOfflineAccess Scope = "offline.access"
	// All the Spaces you can view.
	ScopeSpaceRead Scope = "space.read"
	// Accounts you’ve muted.
	ScopeMuteRead Scope = "mute.read"
	// Mute and unmute accounts for you.
	ScopeMuteWrite Scope = "mute.write"
	// Tweets you’ve liked and likes you can view.
	ScopeLikeRead Scope = "like.read"
	// Like and un-like Tweets for you.
	ScopeLikeWrite Scope = "like.write"
	// Lists, list members, and list followers of lists you’ve created or are a member of, including private lists.
	ScopeListRead Scope = "list.read"
	// Create and manage Lists for you.
	ScopeListWrite Scope = "list.write"
	// Accounts you’ve blocked.
	ScopeBlockRead Scope = "block.read"
	// Block and unblock accounts for you.
	ScopeBlockWrite Scope = "block.write"
	// Get Bookmarked Tweets from an authenticated user.
	ScopeBookmarkRead Scope = "bookmark.read"
	// Bookmark and remove Bookmarks from Tweets
	ScopeBookmarkWrite Scope = "bookmark.write"
)

func (Scope) Remove

func (s Scope) Remove(x Scope) Scope

func (Scope) Split

func (s Scope) Split() []Scope

type SortOrder

type SortOrder string
const (
	SortOrderRecency   SortOrder = "recency"
	SortOrderRelevancy SortOrder = "relevancy"
)

type Token

type Token struct {
	Expire       time.Time
	AccessToken  string
	RefreshToken string
	Scope        Scope
}

func (*Token) Expired

func (t *Token) Expired() bool

type Tweet

type Tweet struct {
	ID                 int64              `json:"id,string"`
	Text               string             `json:"text"`
	Attachment         *Attachment        `json:"attachment,omitempty"`
	AuthorID           int64              `json:"author_id,string"`
	ContextAnnotations []any              `json:"context_annotations,omitempty"`
	ConversationID     int64              `json:"conversation_id,string"`
	CreatedAt          time.Time          `json:"created_at"`
	Entities           *Entities          `json:"entities,omitempty"`
	Geo                *Geo               `json:"geo,omitempty"`
	InReplyToUserID    int64              `json:"in_reply_to_user_id,string"`
	Lang               string             `json:"lang,omitempty"`
	OrganicMetrics     *OrganicMetrics    `json:"organic_metrics,omitempty"`
	PositiveSensitive  bool               `json:"positive_sensitive"`
	PromotedMetrics    *PromotedMetrics   `json:"promoted_metrics,omitempty"`
	ReferencedTweet    []*ReferencedTweet `json:"referenced_tweet,omitempty"`
	ReplySettings      string             `json:"reply_settings"`
	Source             string             `json:"source"`
	Withheld           *Withheld          `json:"withheld,omitempty"`
}

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"
)

type Twitter

type Twitter struct {
	Token  *Token
	OAuth2 *OAuth2
	// contains filtered or unexported fields
}

func NewTwitter

func NewTwitter(client *http.Client, oauth2 *OAuth2, token *Token) *Twitter

func (*Twitter) DeleteTweet

func (t *Twitter) DeleteTweet(id int64) (*Response[*Deleted], error)

DeleteTweet allows a user or authenticated user ID to delete a Tweet.

https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/delete-tweets-id

func (*Twitter) GetTweet

func (t *Twitter) GetTweet(id int64, opts ...GetTweetOption) (*Response[*Tweet], error)

GetTweet returns a variety of information about a single Tweet specified by the requested ID.

https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets-id

func (*Twitter) GetTweets

func (t *Twitter) GetTweets(ids []int64, opts ...GetTweetOption) (*Response[[]*Tweet], error)

GetTweets returns a variety of information about the Tweet specified by the requested ID or list of IDs.

https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets

func (*Twitter) GetTweetsCountsAll

func (t *Twitter) GetTweetsCountsAll(query string, opts ...GetTweetsCountsOption) (*Response[[]*Counts], error)

This endpoint is only available to those users who have been approved for Academic Research access.

The full-archive Tweet counts endpoint returns the count of Tweets that match your query from the complete history of public Tweets; since the first Tweet was created March 26, 2006.

https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-all

func (*Twitter) GetTweetsCountsRecent

func (t *Twitter) GetTweetsCountsRecent(query string, opts ...GetTweetsCountsOption) (*Response[[]*Counts], error)

GetTweetsCountsRecent returns count of Tweets from the last seven days that match a query.

https://developer.twitter.com/en/docs/twitter-api/tweets/counts/api-reference/get-tweets-counts-recent

func (*Twitter) GetTweetsSearchAll

func (t *Twitter) GetTweetsSearchAll(query string, opts ...GetTweetsSearchOption) (*Response[[]*Tweet], error)

This endpoint is only available to those users who have been approved for Academic Research access.

The full-archive search endpoint returns the complete history of public Tweets matching a search query; since the first Tweet was created March 26, 2006.

The Tweets returned by this endpoint count towards the Project-level Tweet cap.

https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-all

func (*Twitter) GetTweetsSearchRecent

func (t *Twitter) GetTweetsSearchRecent(query string, opts ...GetTweetsSearchOption) (*Response[[]*Tweet], error)

The recent search endpoint returns Tweets from the last seven days that match a search query.

The Tweets returned by this endpoint count towards the Project-level Tweet cap.

https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent

func (*Twitter) GetUserFollowers

func (t *Twitter) GetUserFollowers(id int64, opts ...GetUserFollowOption) (*Response[[]*User], error)

GetUserFollowers returns a list of users who are followers of the specified user ID.

https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-followers

func (*Twitter) GetUserFollowing

func (t *Twitter) GetUserFollowing(id int64, opts ...GetUserFollowOption) (*Response[[]*User], error)

GetUserFollow returns a list of users the specified user ID is following.

https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-following

func (*Twitter) GetUserMentions

func (t *Twitter) GetUserMentions(id int64, opts ...GetUserTweetOption) (*Response[[]*Tweet], error)

GetUserMentions returns Tweets mentioning a single user specified by the requested user ID. By default, the most recent ten Tweets are returned per request. Using pagination, up to the most recent 800 Tweets can be retrieved.

The Tweets returned by this endpoint count towards the Project-level Tweet cap.

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

func (*Twitter) GetUserTweets

func (t *Twitter) GetUserTweets(id int64, opt ...GetUserTweetOption) (*Response[[]*Tweet], error)

GetUserTweets returns Tweets composed by a single user, specified by the requested user ID. By default, the most recent ten Tweets are returned per request. Using pagination, the most recent 3,200 Tweets can be retrieved.

The Tweets returned by this endpoint count towards the Project-level Tweet cap.

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

func (*Twitter) PostTweet

func (t *Twitter) PostTweet(params *PostTweetParams) (*Response[*Tweet], error)

PostTweet creates a Tweet on behalf of an authenticated user.

https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets

type User

type User struct {
	ID       int64  `json:"id,string"`
	Name     string `json:"name"`
	Username string `json:"username"`
	Verified bool   `json:"verified"`
}

type UserField

type UserField string
const (
	UserFieldCreatedAt       UserField = "created_at"
	UserFieldDescription     UserField = "description"
	UserFieldEntities        UserField = "entities"
	UserFieldID              UserField = "id"
	UserFieldLocation        UserField = "location"
	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"
)

type WithEndTime

type WithEndTime time.Time

type WithExpansions

type WithExpansions []Expansion

type WithGranularity

type WithGranularity Granularity

type WithMaxResults

type WithMaxResults int

type WithMediaFields

type WithMediaFields []MediaField

type WithNextToken

type WithNextToken string

type WithPaginationToken

type WithPaginationToken string

type WithPlaceFields

type WithPlaceFields []PlaceField

type WithPollFields

type WithPollFields []PollField

type WithSinceID

type WithSinceID int64

type WithSortOrder

type WithSortOrder SortOrder

type WithStartTime

type WithStartTime time.Time

type WithTweetFields

type WithTweetFields []TweetField

type WithUntilID

type WithUntilID int64

type WithUserFields

type WithUserFields []UserField

type Withheld

type Withheld struct {
	Copyright    bool     `json:"copyright"`
	CountryCodes []string `json:"country_codes"`
}

Jump to

Keyboard shortcuts

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