announcements

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 CreateRequest

type CreateRequest struct {
	Title    string      `json:"title"`
	Text     string      `json:"text"`
	ImageURL core.String `json:"imageUrl,omitempty"`
}

CreateRequest represents an Create Announcement request.

func (CreateRequest) Validate

func (r CreateRequest) Validate() error

Validate the request.

type DeleteRequest

type DeleteRequest struct {
	ID string `json:"id"`
}

DeleteRequest represents an Delete Announcement request.

func (DeleteRequest) Validate

func (r DeleteRequest) Validate() error

Validate the request.

type ListRequest

type ListRequest struct {
	Limit   uint   `json:"limit"`
	SinceID string `json:"sinceId,omitempty"`
	UntilID string `json:"untilId,omitempty"`
}

ListRequest represents an List Announcement request.

func (ListRequest) Validate

func (r ListRequest) Validate() error

Validate the 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) Create

func (s *Service) Create(request CreateRequest) (models.Announcement, error)

Create an announcement.

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

response, err := client.Admin().Announcements().Create(announcements.CreateRequest{
	Title: "New Announcement",
	Text:  "Because we can do it!",
})
if err != nil {
	log.Printf("[Admin/Announcements] %s", err)

	return
}

log.Printf("[Admin/Announcements] %s", *response.ID)
Output:

func (*Service) Delete

func (s *Service) Delete(id string) error

Delete an announcement.

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

err := client.Admin().Announcements().Delete("8d44utwtj6")
if err != nil {
	log.Printf("[Admin/Announcements] %s", err)

	return
}
Output:

func (*Service) List

func (s *Service) List(request ListRequest) ([]models.Announcement, error)

List lists all announcements.

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

response, err := client.Admin().Announcements().List(announcements.ListRequest{
	Limit: 10,
})
if err != nil {
	log.Printf("[Admin/Announcements] %s", err)

	return
}

for _, item := range response {
	log.Printf("[Admin/Announcements] %s", *item.Title)
}
Output:

func (*Service) Update

func (s *Service) Update(request UpdateRequest) error

Update an announcement.

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

err := client.Admin().Announcements().Update(announcements.UpdateRequest{
	ID:    "8d44utwtj6",
	Title: "New Title",
	Text:  "New text",
})
if err != nil {
	log.Printf("[Admin/Announcements] %s", err)

	return
}
Output:

type UpdateRequest

type UpdateRequest struct {
	ID       string      `json:"id"`
	Title    string      `json:"title"`
	Text     string      `json:"text"`
	ImageURL core.String `json:"imageUrl,omitempty"`
}

UpdateRequest represents an Update Announcement request.

func (UpdateRequest) Validate

func (r UpdateRequest) Validate() error

Validate the request.

Jump to

Keyboard shortcuts

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