otypes

package
v0.0.0-...-d727afa Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DateFormat = "Mon Jan _2 15:04:05 -0700 2006"

DateFormat is the timestamp format used by the Twitter v1.1 API.

Variables

This section is empty.

Functions

This section is empty.

Types

type DateTime

type DateTime time.Time

DateTime represents a timestamp encoded in JSON.

func (DateTime) String

func (d DateTime) String() string

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(data []byte) error

type Entities

type Entities struct {
	Hashtags []SpanText `json:"hashtags"`
	Cashtags []SpanText `json:"symbols"`

	URLs []struct {
		Span     []int  `json:"indices"`
		URL      string `json:"url"`
		Expanded string `json:"expanded_url"`
		Display  string `json:"display_url"`
	} `json:"urls"`

	Mentions []struct {
		Span     []int  `json:"indices"`
		Username string `json:"screen_name"`
	} `json:"user_mentions"`
}

Entities encodes a subset of API v1.1 Tweet entities.

func (*Entities) ToEntitiesV2

func (e *Entities) ToEntitiesV2() *types.Entities

ToEntitiesV2 converts o into an approximately equivalent API v2 value.

type SpanText

type SpanText struct {
	Span []int  `json:"indices"`
	Text string `json:"text"`
}

SpanText represents a span of text.

func (SpanText) ToTagV2

func (s SpanText) ToTagV2() *types.Tag

ToTagV2 converts s into an equivalent API v2 Tag.

type Tweet

type Tweet struct {
	CreatedAt       DateTime  `json:"created_at"`
	ID              string    `json:"id_str"` // N.B. the "id" field is a number
	Text            string    `json:"text"`
	FullText        string    `json:"full_text"` // requires tweet_mode=extended
	Source          string    `json:"source"`    // in HTML anchor form
	Truncated       bool      `json:"truncated"`
	InReplyToStatus string    `json:"in_reply_to_status_id_str"`
	QuotedStatusID  string    `json:"quoted_status_id_str"`
	InReplyToUser   string    `json:"in_reply_to_user_id_str"`
	Sensitive       bool      `json:"possibly_sensitive"`
	Language        string    `json:"lang"`
	Entities        *Entities `json:"entities"`

	// Public metrics
	LikeCount    int `json:"favorite_count"` // note name difference
	QuoteCount   int `json:"quote_count"`
	ReplyCount   int `json:"reply_count"`
	RetweetCount int `json:"retweet_count"`

	// Author information (we only need the ID)
	User *struct {
		ID string `json:"id_str"` // N.B. the "id" field is a number
	} `json:"user"`
}

Tweet captures a subset of the fields of the v1.1 API Tweet object, as needed to populate some of the essential fields of a v2 Tweet.

See https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/overview/tweet-object

func (Tweet) ToTweetV2

func (o Tweet) ToTweetV2(opt types.TweetFields) *types.Tweet

ToTweetV2 converts o into an approximately equivalent API v2 Tweet value.

type User

type User struct {
	CreatedAt       DateTime `json:"created_at"`
	Description     string   `json:"description"`
	FuzzyLocation   string   `json:"location"`
	ID              string   `json:"id_str"` // N.B. the "id" field is a number
	Name            string   `json:"name"`
	ProfileImageURL string   `json:"profile_image_url_https"`
	ProfileURL      string   `json:"url"`
	Protected       bool     `json:"protected"`
	Username        string   `json:"screen_name"`
	Verified        bool     `json:"verified"`

	Entities struct {
		URL  *Entities `json:"urls"`
		Desc *Entities `json:"description"`
	} `json:"entities"`

	// Public metrics
	FollowersCount int `json:"followers_count"`
	FollowingCount int `json:"friends_count"`
	ListedCount    int `json:"listed_count"`
	TweetCount     int `json:"statuses_count"`
}

User captures a subset of the fields of the v1.1 API User object, as needed to populate some of the essential fields of a v2 User.

See https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/overview/user-object

func (User) ToUserV2

func (o User) ToUserV2(opt types.UserFields) *types.User

ToUserV2 converts o to an approximately-equivalent API v2 User value.

Jump to

Keyboard shortcuts

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