sphelper

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: MIT Imports: 10 Imported by: 0

README

sphelper

Library to interact with https://www.spieleplanet.eu/.

Features

Usage

Add sphelper to Your Project
go get github.com/yawn77/sphelper
Set Environment
export SP_USERNAME=<username>
export SP_PASSWORD=<password>
Use sphelper in Your Project
// read credentials from env variables
creds, _ := sphelper.GetCredentials()
// create http client
client, _ := sphelper.GetClient()
_ = client.Login(creds)
_ = client.Get("https://www.spieleplanet.eu/")
_ = client.Post("https://www.spieleplanet.eu/...", url.Values{...})
_ = client.Logout()

Development

For testing you have to provide a valid login for https://www.spieleplanet.eu/. If you are using vscode, you can do this by providing a .env.test file of the format

SP_USERNAME="<username>"
SP_PASSWORD="<password>"

In any case you can provide a username and a password as command-line arguments for the go test command

go test -v --race ./... -args -username="<username>" -password="<password>"

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMD5Hash

func GetMD5Hash(text string) string

func GetVersion

func GetVersion() string

func WriteBody

func WriteBody(filename string, body string) error

Types

type Client

type Client struct {
	Session session
	// contains filtered or unexported fields
}

func GetClient

func GetClient() (*Client, error)

func (Client) Get

func (c Client) Get(url string) (string, error)

func (*Client) Login

func (c *Client) Login(credentials Credentials) error

func (*Client) Logout

func (c *Client) Logout() error

func (Client) Post

func (c Client) Post(url string, values url.Values) (string, error)

type Credentials

type Credentials struct {
	Username    string
	Password    string
	PasswordMd5 string
}

func GetCredentials

func GetCredentials() (Credentials, error)

type Error

type Error string

func (Error) Error

func (e Error) Error() string

Jump to

Keyboard shortcuts

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