This repository has been archived on 2022-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
elon-eats-my-tweets/twitterapi/types.go

46 lines
1.3 KiB
Go

package twitterapi
//go:generate mockery --recursive --name Store --output ../generated/mocks
//go:generate mockery --recursive --name APIClient --structname TwitterAPIClient --filename TwitterAPIClient.go --output ../generated/mocks
import (
"context"
"time"
"git.netflux.io/rob/elon-eats-my-tweets/generated/store"
)
// Store is a persistent store.
type Store interface {
CreateUser(context.Context, store.CreateUserParams) (store.User, error)
GetLastElonTweet(context.Context) (store.ElonTweet, error)
UpsertElonTweet(context.Context, store.UpsertElonTweetParams) (store.ElonTweet, error)
}
// Client is a client for the Twitter API.
type Client interface {
GetLastTweet(string) (*Tweet, error)
GetTweets(string, string) ([]*Tweet, error)
GetMe() (*User, error)
}
// TwitterMetadata contains the metadata returned in Twitter API responses.
type TwitterMetadata struct {
ResultCount int `json:"result_count"`
NewestID string `json:"newest_id"`
}
// User represents a Twitter user as returned from the Twitter API.
type User struct {
ID string `json:"id"`
Name string `json:"name"`
Username string `json:"username"`
}
// Tweet represents a tweet as returned from the Twitter API.
type Tweet struct {
ID string `json:"id"`
Text string `json:"text"`
CreatedAt time.Time `json:"created_at"`
}