goteria

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 8 Imported by: 0

README

goteria

Simple and easy Soteria Library for Go.

Installation

Requirements

Instructions

  1. Go get it!!!
go get codeberg.org/soteria/goteria

Usage

import (
    "codeberg.org/soteria/goteria"
	"time"
    "log"
)

func main() {
	client := goteria.NewClient("https://api.soteria.social", time.Second*5, "<TOKEN>") // You can also leave the token string empty

	user, err := goteria.FetchUser(client, "ID")
	if err != nil {
		log.Fatal(err)
	}

	log.Println(user.Username)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logout

func Logout(c *Client) error

Logout

Types

type Authorization

type Authorization struct {
	Token string `json:"token"`
}

type BlockedUsers

type BlockedUsers struct {
	Blocked []string `json:"blocked"`
}

type Client

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

func Login

func Login(c *Client, username string, password string) (*Client, error)

Login

func NewClient

func NewClient(baseURL string, timeout time.Duration, auth string) *Client

Create a new client.

func (*Client) Get

func (c *Client) Get(endpoint string, result interface{}) error

func (*Client) Post

func (c *Client) Post(endpoint string, data []byte, result interface{}) error

func (*Client) Request

func (c *Client) Request(method string, endpoint string, body io.Reader, result interface{}) error

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type Followees

type Followees struct {
	Count     int      `json:"count"`
	Followees []string `json:"followees"`
}

type Followers

type Followers struct {
	Count     int      `json:"count"`
	Followers []string `json:"followers"`
}

type LikesPost

type LikesPost struct {
	Count int      `json:"count"`
	Likes []string `json:"likes"`
}

type Post

type Post struct {
	ID          string   `json:"id"`
	ReplyID     string   `json:"reply"`
	Author      string   `json:"author"`
	Content     string   `json:"content"`
	CreatedAt   string   `json:"created_at"`
	Attachments []string `json:"attachments"`
}

func CreatePost

func CreatePost(c *Client, content string, reply *Post) (*Post, error)

Create a new post.

func FetchPost

func FetchPost(c *Client, id int) (*Post, error)

Fetch a post.

func (*Post) Delete

func (p *Post) Delete(c *Client, content string) error

Delete post.

func (*Post) Edit

func (p *Post) Edit(c *Client, content string) (*Post, error)

Edit post.

func (*Post) Like

func (p *Post) Like(c *Client) error

Likes the post.

func (*Post) Likes

func (p *Post) Likes(c *Client) (LikesPost, error)

Get likes from the post.

func (*Post) Replies

func (p *Post) Replies(c *Client, offset int, limit int) (Posts, error)

Get replies from the post.

func (*Post) Reply

func (p *Post) Reply(c *Client, content string) (*Post, error)

Reply to the post.

func (*Post) Unlike

func (p *Post) Unlike(c *Client) error

Removes the like from the post.

type Posts

type Posts []*Post

func FetchPosts

func FetchPosts(c *Client, offset int, limit int) (Posts, error)

Fetch multiple posts.

type SelfUser

type SelfUser struct {
	User
	Email string `json:"email"`
}

func FetchSelf

func FetchSelf(c *Client) (*SelfUser, error)

Fetch yourself.

func (*SelfUser) Blocked

func (*SelfUser) Blocked(c *Client) (BlockedUsers, error)

Get blocked users.

func (*SelfUser) ModifyProfile

func (*SelfUser) ModifyProfile(c *Client, displayName *string, description *string) error

Modify your profile.

type User

type User struct {
	ID          string `json:"id"`
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
	Description string `json:"description"`
	CreatedAt   string `json:"created_at"`
	Visible     bool   `json:"visible"`
	Avatar      string `json:"avatar"`
	Banner      string `json:"banner"`
}

func FetchUser

func FetchUser(c *Client, id int) (*User, error)

Fetch a user.

func (*User) Block

func (u *User) Block(c *Client) error

Block user.

func (*User) Follow

func (u *User) Follow(c *Client) error

Follow user.

func (*User) Followees

func (u *User) Followees(c *Client) (Followees, error)

Get user's followees.

func (*User) Followers

func (u *User) Followers(c *Client) (Followers, error)

Get user's followers.

func (*User) LikedPosts

func (u *User) LikedPosts(c *Client, offset int, limit int) (Posts, error)

Get posts that the user liked.

func (*User) Posts

func (u *User) Posts(c *Client, offset int, limit int, replies bool) (Posts, error)

Get user's posts.

func (*User) Unblock

func (u *User) Unblock(c *Client) error

Unblock user.

func (*User) Unfollow

func (u *User) Unfollow(c *Client) error

Unfollow user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳