client

package module
v0.0.0-...-81f92f9 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: AGPL-3.0 Imports: 13 Imported by: 2

README

go.yarn.social/client

go.yarn.social/client is a Go client for the Yarn API for Pods (individual instances of yarnd)

Quick Start

TBD

License

go.yarn.social/client is licensed under the terms of the AGPLv3

Documentation

Index

Constants

View Source
const (
	APIVersion = 1
)
View Source
const (
	// DefaultURI is the default base URI to use for the Twtxt API endpoint
	DefaultURI = "http://localhost:8000/"
)

Variables

View Source
var (
	// DefaultUserAgent ...
	DefaultUserAgent = fmt.Sprintf("go.yarn.social/%s", FullVersion())

	// ErrBadRequest ...
	ErrBadRequest = errors.New("error: bad request")

	// ErrUnauthorized ...
	ErrUnauthorized = errors.New("error: authorization failed")

	// ErrServerError
	ErrServerError = errors.New("error: server error")
)
View Source
var (
	// Version release version
	Version = "1.0.0"

	// Commit will be overwritten automatically by the build system
	Commit = "HEAD"
)

Functions

func FullVersion

func FullVersion() string

FullVersion display the full version and build

Types

type Client

type Client struct {
	BaseURL   *url.URL
	Config    *Config
	UserAgent string
	Twter     types.Twter
	// contains filtered or unexported fields
}

Client ...

func NewClient

func NewClient(options ...Option) (*Client, error)

NewClient ...

func (*Client) Follow

func (c *Client) Follow(nick, url string) error

Follow ...

func (*Client) GetAndSetTwter

func (c *Client) GetAndSetTwter() error

GetAndSetTwter ...

func (*Client) Login

func (c *Client) Login(username, password string) (res types.AuthResponse, err error)

Login ...

func (*Client) Post

func (c *Client) Post(text, as string) (res types.PostResponse, err error)

Post ...

func (*Client) Profile

func (c *Client) Profile(username string) (res types.ProfileResponse, err error)

Profile ...

func (*Client) Sync

func (c *Client) Sync(delete bool, feed string, r io.Reader) (res types.SyncResponse, err error)

Sync ...

func (*Client) Timeline

func (c *Client) Timeline(page int) (res types.PagedResponse, err error)

Timeline ...

func (*Client) Unfollow

func (c *Client) Unfollow(nick string) error

Unfollow ...

type Config

type Config struct {
	URI   string `yaml:"uri"`
	Token string `yaml:"token"`
}

Config contains the client configuration parameters

func Load

func Load(path string) (*Config, error)

Load loads a configuration from the given path

func NewConfig

func NewConfig() *Config

NewConfig ...

func (*Config) Save

func (c *Config) Save(path string) error

Save saves the configuration to the provided path

type Option

type Option func(*Config) error

Option is a function that takes a config struct and modifies it

func WithToken

func WithToken(token string) Option

WithToken sets the API token to use for authenticating to Twtxt endpoints

func WithURI

func WithURI(uri string) Option

WithURI sets the base URI to used for the Twtxt API endpoint

Jump to

Keyboard shortcuts

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