requests

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptRequest

type AcceptRequest struct {
	UserID string `json:"userId"`
}

AcceptRequest is the request structure to accept a following request.

func (AcceptRequest) Validate

func (r AcceptRequest) Validate() error

Validate request.

type CancelRequest

type CancelRequest struct {
	UserID string `json:"userId"`
}

CancelRequest is the request structure to cancel a following request.

func (CancelRequest) Validate

func (r CancelRequest) Validate() error

Validate request.

type ListRequest

type ListRequest struct{}

ListRequest is the request structure to list following requests.

func (ListRequest) Validate

func (r ListRequest) Validate() error

Validate request.

type ListResponse

type ListResponse struct {
	ID       string      `json:"id"`
	Follower models.User `json:"follower"`
	Followee models.User `json:"followee"`
}

ListResponse is the response from the list following requests endpoint.

type RejectRequest

type RejectRequest struct {
	UserID string `json:"userId"`
}

RejectRequest is the request structure to reject a following request.

func (RejectRequest) Validate

func (r RejectRequest) Validate() error

Validate request.

type Service

type Service struct {
	Call core.RequestHandlerFunc
}

Service is the base for all the endpoints on this service.

func NewService

func NewService(requestHandler core.RequestHandlerFunc) *Service

NewService creates a new Service instance.

func (*Service) Accept

func (s *Service) Accept(userID string) error

Accept following endpoint.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))

err := client.Following().Requests().Accept("88v9vu5nbu")
if err != nil {
	log.Printf("[Following/Requests/Accept] %s", err)

	return
}

log.Println("[Following/Requests/Accept] Accepted")
Output:

func (*Service) Cancel

func (s *Service) Cancel(userID string) (models.User, error)

Cancel following endpoint.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))

user, err := client.Following().Requests().Cancel("88v9vu5nbu")
if err != nil {
	log.Printf("[Following/Requests/Cancel] %s", err)

	return
}

log.Printf("[Following/Requests/Cancel] Canceled: %s", user.ID)
Output:

func (*Service) List

func (s *Service) List() ([]ListResponse, error)

List following requests endpoint.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))

list, err := client.Following().Requests().List()
if err != nil {
	log.Printf("[Following/Requests/List] %s", err)

	return
}

for _, item := range list {
	log.Printf(
		"[Following/Requests/List] %s -> %s",
		item.Follower.Username,
		item.Followee.Username,
	)
}
Output:

func (*Service) Reject

func (s *Service) Reject(userID string) error

Reject following request endpoint.

Example
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))

err := client.Following().Requests().Reject("88v9vu5nbu")
if err != nil {
	log.Printf("[Following/Requests/Reject] %s", err)

	return
}

log.Println("[Following/Requests/Reject] Rejected")
Output:

Jump to

Keyboard shortcuts

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