app

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

app package provides the core interface for ajtweet. It is used in decoupling from the CLI and thus makes it easier to unit-test.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockfileExists = errors.New("another instance is running and have acquired the lock file")
)
View Source
var (
	// The tweet has already been added to the list.
	ErrMissingAuth = errors.New("authentication parameters are missing")
)

Functions

This section is empty.

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

The main "context" used in the application.

func (*Application) AcquireLock

func (app *Application) AcquireLock() error

func (*Application) Add

func (app *Application) Add(message string, scheduledTimeString string) error

Add a new scheduled tweet to the Application. The scheduledTimeString must be in the RFC 3339 standard, e.g. 2006-03-05T10:42:01Z

func (*Application) Configure

func (app *Application) Configure(config Config) error

Configure and load any exsiting tweets to be used by the Application.

func (*Application) Delete

func (app *Application) Delete(idString string) error

Delete the tweet matching the specified identifier.

func (*Application) DeleteAll

func (app *Application) DeleteAll() error

Delete all the tweets.

func (*Application) List

func (app *Application) List(out io.Writer) error

Write the list of scheduled tweets that still need to be sent to the specified io.Writer.

func (*Application) ListJSON

func (app *Application) ListJSON(out io.Writer) error

Write the list of scheduled tweets that still need to be sent in a JSON encoding to the specified io.Writer.

func (*Application) ReleaseLock

func (app *Application) ReleaseLock() error

func (*Application) Save

func (app *Application) Save() error

Save any changes made by the Application.

func (*Application) Send

func (app *Application) Send(out io.Writer, dryRun bool) error

Send any scheduled tweets.

type Authentication

type Authentication struct {
	APIKey    string `mapstructure:"api_key"`    // Consumer / API Key
	APISecret string `mapstructure:"api_secret"` // Consumer / API Secret

	OAuth1 OAuth1
}

Authentication details for the Twitter API

type Config

type Config struct {
	Datastore Datastore
	Send      Send

	Lockfile string // File path of where the lock file will be created.
}

Configuration data used by the Application.

func NewConfig

func NewConfig() Config

Create a new Config and set the default values required

func (*Config) PopulateFromEnv

func (config *Config) PopulateFromEnv()

Configure values from matching environment variables

type Datastore

type Datastore struct {
	Filepath string // File path of where the tweets should be stored.
}

Datastore configures how the tweets are stored by the Application.

type OAuth1

type OAuth1 struct {
	Token  string // User token
	Secret string // User token secret
}

OAuth1.0a authentication for the Twitter API

type Send

type Send struct {
	Max   int // The maximum number of tweets to send in this call of the app.
	Delay int // The number of seconds to delay between each sending of a tweet.

	Authentication Authentication
}

Send parameters

Jump to

Keyboard shortcuts

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