Skip to content

vikunja

import "github.com/atropos112/gocore/vikunja"

Index

func ConsumeWebhookCallback

func ConsumeWebhookCallback(body io.ReadCloser, callback func(webhook WebhookCallback) error) error

ConsumeWebhookCallback consumes a webhook callback and calls the callback function

func RegisterVikunjaWebhookHandler

func RegisterVikunjaWebhookHandler(path string, callback func(Webhook WebhookCallback, c *Client) error) error

RegisterVikunjaWebhookHandler registers a webhook handler for Vikunja Webhook

Typical usage is something like: l := utils.GetInitLogger()

if err := vikunja.RegisterVikunjaWebhookHandler("/", SomeWebhookHandler); err != nil {
    log.Fatal(err)
}

utils.RunAPIServer(8080)

type Client

Client is the interface for the Vikunja API client

type Client utils.AuthenticatedAPIClient

func GetVikunjaAPIClient

func GetVikunjaAPIClient(token, apiURL string) (*Client, error)

GetVikunjaAPIClient returns a new Vikunja API client

func (*Client) AddLabelToTask

func (c *Client) AddLabelToTask(taskID, labelID int) (LabelID, error)

AddLabelToTask adds a label to a task

func (*Client) CreateProjectWebhook

func (c *Client) CreateProjectWebhook(projectID int, webhook Webhook) (Webhook, error)

CreateProjectWebhook creates a webhook for a project

func (*Client) DeleteProjectWebhook

func (c *Client) DeleteProjectWebhook(projectID, webhookID int) (Webhook, error)

DeleteProjectWebhook deletes a webhook for a project

func (*Client) GetAllLabels

func (c *Client) GetAllLabels() ([]Label, error)

GetAllLabels returns a list of labels for a task

func (*Client) GetProject

func (c *Client) GetProject(projectID int) (Project, error)

GetProject returns a specific project

func (*Client) GetProjectTasks

func (c *Client) GetProjectTasks(projectID int) ([]Task, error)

GetProjectTasks returns a list of tasks for a project

func (*Client) GetProjectWebhooks

func (c *Client) GetProjectWebhooks(projectID int) ([]Webhook, error)

GetProjectWebhooks returns a list of webhooks for a project

func (*Client) GetProjects

func (c *Client) GetProjects() ([]Project, error)

GetProjects returns a list of projects

func (*Client) GetTask

func (c *Client) GetTask(taskID int) (Task, error)

GetTask returns a task

func (*Client) GetTaskComments

func (c *Client) GetTaskComments(taskID int) ([]Comment, error)

GetTaskComments returns a list of comments for a task

func (*Client) GetUsersOnAProject

func (c *Client) GetUsersOnAProject(projectID int) ([]User, error)

GetUsersOnAProject returns a list of users added to a project

func (*Client) UpdateProject

func (c *Client) UpdateProject(project Project) (Project, error)

UpdateProject updates a project

func (*Client) UpdateProjectWebhook

func (c *Client) UpdateProjectWebhook(projectID int, webhook Webhook) (Webhook, error)

UpdateProjectWebhook updates a webhook for a project, only can update events (nothing else)

func (*Client) UpdateTask

func (c *Client) UpdateTask(task Task) (Task, error)

UpdateTask updates a task

type Comment

type Comment struct {
    ID      int    `json:"id"`
    Comment string `json:"comment"`
    Author  User   `json:"author"`
    Created string `json:"created"`
    Updated string `json:"updated"`
}

func GetLatestComment

func GetLatestComment(comments []Comment) (Comment, error)

GetLatestComment returns the latest comment from a list of comments

type Label

type Label struct {
    ID          int    `json:"id"`
    Title       string `json:"title"`
    Description string `json:"description"`
    HexColor    string `json:"hex_color"`
    CreatedBy   User   `json:"created_by"`
    Created     string `json:"created"`
    Updated     string `json:"updated"`
}

func LabelsWithGivenTitles

func LabelsWithGivenTitles(labels []Label, titles []string) ([]Label, error)

LabelsWithGivenTitles returns a list of labels with the given titles If the title of a label is not found, an error is returned, it is expected that you only provide valid titles

type LabelID

LabelID is a struct used to communicate to vikunja which label you are after. It is not the ID field in Label though.

type LabelID struct {
    ID      int    `json:"label_id"`
    Created string `json:"created,omitempty"`
}

type Project

Project is a struct that represents a project in Vikunja

type Project struct {
    ID                    int         `json:"id"`
    Title                 string      `json:"title"`
    HexColor              string      `json:"hex_color"`
    BackgroundBlurHash    string      `json:"background_blur_hash"`
    Position              float64     `json:"position"`
    Created               string      `json:"created"`
    Updated               string      `json:"updated"`
    Description           string      `json:"description"`
    DefaultBucketID       int         `json:"default_bucket_id"`
    DoneBucketID          int         `json:"done_bucket_id"`
    Identifier            string      `json:"identifier"`
    IsArchived            bool        `json:"is_archived"`
    IsFavorite            bool        `json:"is_favorite"`
    Owner                 User        `json:"owner"`
    ParentProjectID       int         `json:"parent_project_id"`
    BackgroundInformation interface{} `json:"background_information"`
}

type Task

Task represents a task in Vikunja

type Task struct {
    ID                     int                      `json:"id"`
    Title                  string                   `json:"title"`
    Description            string                   `json:"description"`
    Done                   bool                     `json:"done"`
    DoneAt                 string                   `json:"done_at"`
    DueDate                string                   `json:"due_date"`
    Reminders              interface{}              `json:"reminders"`
    ProjectID              int                      `json:"project_id"`
    RepeatAfter            int                      `json:"repeat_after"`
    RepeatMode             int                      `json:"repeat_mode"`
    Priority               int                      `json:"priority"`
    StartDate              string                   `json:"start_date"`
    EndDate                string                   `json:"end_date"`
    Assignees              []User                   `json:"assignees"`
    Labels                 []Label                  `json:"labels"`
    HexColor               string                   `json:"hex_color"`
    PercentDone            float32                  `json:"percent_done"`
    Identifier             string                   `json:"identifier"`
    Index                  int                      `json:"index"`
    RelatedTasks           map[string][]interface{} `json:"related_tasks,omitempty"` // Marking this with []Task instead of interface{} causes parsing errors...
    Attachments            interface{}              `json:"attachments"`
    CoverImageAttachmentID int                      `json:"cover_image_attachment_id"`
    IsFavorite             bool                     `json:"is_favorite"`
    Created                string                   `json:"created"`
    Updated                string                   `json:"updated"`
    BucketID               int                      `json:"bucket_id"`
    Position               float64                  `json:"position"`
    KanbanPosition         float64                  `json:"kanban_position"`
    CreatedBy              User                     `json:"created_by"`
}

type User

User is a struct that represents a user in Vikunja

type User struct {
    ID       int    `json:"id"`
    Name     string `json:"name"`
    Username string `json:"username"`
    Created  string `json:"created"`
    Updated  string `json:"updated"`
}

type VikunjaWebhookEventType

type VikunjaWebhookEventType string

const (
    ProjectDeleted        VikunjaWebhookEventType = "project.deleted"
    TaskAssigneeCreated   VikunjaWebhookEventType = "task.assignee.created"
    TaskCommentCreated    VikunjaWebhookEventType = "task.comment.created"
    TaskDeleted           VikunjaWebhookEventType = "task.deleted"
    TaskRelationCreated   VikunjaWebhookEventType = "task.relation.created"
    TaskCommentDeleted    VikunjaWebhookEventType = "task.comment.deleted"
    TaskAssigneeDeleted   VikunjaWebhookEventType = "task.assignee.deleted"
    ProjectSharedTeam     VikunjaWebhookEventType = "project.shared.team"
    ProjectSharedUser     VikunjaWebhookEventType = "project.shared.user"
    TaskAttachmentCreated VikunjaWebhookEventType = "task.attachment.created"
    TaskCommentEdited     VikunjaWebhookEventType = "task.comment.edited"
    TaskRelationDeleted   VikunjaWebhookEventType = "task.relation.deleted"
    TaskUpdated           VikunjaWebhookEventType = "task.updated"
    TaskCreated           VikunjaWebhookEventType = "task.created"
    TaskAttachmentDeleted VikunjaWebhookEventType = "task.attachment.deleted"
    ProjectUpdated        VikunjaWebhookEventType = "project.updated"
)

type Webhook

Webhook represents a webhook in Vikunja

type Webhook struct {
    ID        int      `json:"id"`
    TargetURL string   `json:"target_url"`
    Events    []string `json:"events"`
    ProjectID int      `json:"project_id"`
    Secret    *string  `json:"secret,omitempty"`
    Created   *string  `json:"created,omitempty"`
    Updated   *string  `json:"updated,omitempty"`
    CreatedBy *User    `json:"created_by,omitempty"`
}

type WebhookCallback

WebhookCallback represents a webhook callback

type WebhookCallback struct {
    EventName VikunjaWebhookEventType `json:"event_name"`
    Time      string                  `json:"time"`
    Data      WebhookCallbackData     `json:"data"`
}

type WebhookCallbackData

WebhookCallbackData represents the data that is sent to a webhook callback

type WebhookCallbackData struct {
    Doer User `json:"doer"`
    Task Task `json:"task"`
}

Generated by gomarkdoc