trello

package module
v0.0.0-...-28ebf27 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2016 License: Apache-2.0 Imports: 7 Imported by: 10

README

Golang Trello API client

go-trello is a Go client package for accessing the Trello API.

Go package

GoDoc Travis

Example

package main

import (
	"fmt"
	"log"

	"github.com/VojtechVitek/go-trello"
)

func main() {
	// New Trello Client
	appKey := "application-key"
	token := "token"
	trello, err := trello.NewAuthClient(appKey, &token)
	if err != nil {
		log.Fatal(err)
	}

	// User @trello
	user, err := trello.Member("trello")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(user.FullName)

	// @trello Boards
	boards, err := user.Boards()
	if err != nil {
		log.Fatal(err)
	}

	if len(boards) > 0 {
		board := boards[0]
		fmt.Printf("* %v (%v)\n", board.Name, board.ShortUrl)

		// @trello Board Lists
		lists, err := board.Lists()
		if err != nil {
			log.Fatal(err)
		}

		for _, list := range lists {
			fmt.Println("   - ", list.Name)

			// @trello Board List Cards
			cards, _ := list.Cards()
			for _, card := range cards {
				fmt.Println("      + ", card.Name)
			}
		}
	}
}

prints

Trello
* How to Use Trello for Android (https://trello.com/b/9dnaRkNt)
   -  Getting Started
      +  Welcome to Trello! This is a card.
      +  Tap on a card to open it up.
      +  Color-coded labels can be used to classify cards.
      +  Create as many cards as you want. We've got an unlimited supply!
      +  Here is a picture of Taco, our Siberian Husky.
   -  Diving In
      +  Tap and hold this card to drag it to another list.
      +  Tap on the board name to view other sections.
      +  Make as many lists and boards as you need. We'll make more!
   -  Mastering Trello
      +  Finished with a card? Drag it to the top of the board to archive it.
      +  You can reorder lists too.
      +  Invite team members to collaborate on this board.
   -  More Info
      +  Want updates on new features?
      +  You can also view your boards on trello.com

Influenced by

License

Licensed under the Apache License, Version 2.0.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeArgs

func EncodeArgs(args []*Argument) string

func NewBearerTokenTransport

func NewBearerTokenTransport(applicationKey string, token *string) *bearerRoundTripper

NewBearerTokenTransport will return an http.RoundTripper which will add the provided application id and token to API calls.

If Delegate is left unset the http.DefaultTransport will be used.

See https://trello.com/app-key to get your applicationKey See https://trello.com/1/connect?key=MYKEYFROMABOVE&name=MYAPPNAME&response_type=token&scope=read,write&expiration=1d to get a read/write token good for 1 day

Types

type Action

type Action struct {
	Id              string `json:"id"`
	IdMemberCreator string `json:"idMemberCreator"`
	Data            struct {
		DateLastEdited string `json:"dateLastEdited"`
		ListBefore     struct {
			Id   string `json:"id"`
			Name string `json:"name"`
		} `json:"listBefore"`
		ListAfter struct {
			Id   string `json:"id"`
			Name string `json:"name"`
		} `json:"listAfter"`
		CheckItem struct {
			Id    string `json:"id"`
			State string `json:"state"`
			Name  string `json:"name"`
		} `json:"checkItem"`
		CheckList struct {
			Id   string `json:"id"`
			Name string `json:"name"`
		} `json:"checklist"`
		List struct {
			Id   string `json:"id"`
			Name string `json:"name"`
		} `json:"list"`
		TextData struct {
			Emoji struct{} `json:"emoji"`
		} `json:"textData"`
		Board struct {
			Id        string `json:"id"`
			Name      string `json:"name"`
			ShortLink string `json:"shortLink"`
		} `json:"board"`
		Card struct {
			Id        string `json:"id"`
			Name      string `json:"name"`
			ShortLink string `json:"shortLink"`
			IdShort   int    `json:"idShort"`
		} `json:"card"`
		Text string `json:"text"`
	} `json:"data"`
	Type          string `json:"type"`
	Date          string `json:"date"`
	MemberCreator struct {
		Id         string `json:"id"`
		AvatarHash string `json:"avatarHash"`
		FullName   string `json:"fullName"`
		Initials   string `json:"initials"`
		Username   string `json:"username"`
	} `json:"memberCreator"`
	// contains filtered or unexported fields
}

type Argument

type Argument struct {
	Name  string
	Value string
}

func NewArgument

func NewArgument(name, value string) *Argument

type Attachment

type Attachment struct {
	Id        string `json:"id"`
	Bytes     int    `json:"bytes"`
	Date      string `json:"date"`
	EdgeColor string `json:"edgeColor"`
	IdMember  string `json:"idMember"`
	IsUpload  bool   `json:"isUpload"`
	MimeType  string `json:"mimeType"`
	Name      string `json:"name"`
	Previews  []struct {
		Width  int    `json:"width"`
		Height int    `json:"height"`
		Url    string `json:"url"`
		Bytes  int    `json:"bytes"`
		Id     string `json:"_id"`
		Scaled bool   `json:"scaled"`
	} `json:"previews"`
	Url string `json:"url"`
	// contains filtered or unexported fields
}

type Board

type Board struct {
	Id       string `json:"id"`
	Name     string `json:"name"`
	Desc     string `json:"desc"`
	DescData struct {
		Emoji struct{} `json:"emoji"`
	} `json:"descData"`
	Closed         bool   `json:"closed"`
	IdOrganization string `json:"idOrganization"`
	Pinned         bool   `json:"pinned"`
	Url            string `json:"url"`
	ShortUrl       string `json:"shortUrl"`
	Prefs          struct {
		PermissionLevel       string            `json:"permissionLevel"`
		Voting                string            `json:"voting"`
		Comments              string            `json:"comments"`
		Invitations           string            `json:"invitations"`
		SelfJoin              bool              `json:"selfjoin"`
		CardCovers            bool              `json:"cardCovers"`
		CardAging             string            `json:"cardAging"`
		CalendarFeedEnabled   bool              `json:"calendarFeedEnabled"`
		Background            string            `json:"background"`
		BackgroundColor       string            `json:"backgroundColor"`
		BackgroundImage       string            `json:"backgroundImage"`
		BackgroundImageScaled []BoardBackground `json:"backgroundImageScaled"`
		BackgroundTile        bool              `json:"backgroundTile"`
		BackgroundBrightness  string            `json:"backgroundBrightness"`
		CanBePublic           bool              `json:"canBePublic"`
		CanBeOrg              bool              `json:"canBeOrg"`
		CanBePrivate          bool              `json:"canBePrivate"`
		CanInvite             bool              `json:"canInvite"`
	} `json:"prefs"`
	LabelNames struct {
		Red    string `json:"red"`
		Orange string `json:"orange"`
		Yellow string `json:"yellow"`
		Green  string `json:"green"`
		Blue   string `json:"blue"`
		Purple string `json:"purple"`
	} `json:"labelNames"`
	// contains filtered or unexported fields
}

func (*Board) Actions

func (b *Board) Actions(arg ...*Argument) (actions []Action, err error)

func (*Board) Card

func (b *Board) Card(IdCard string) (card *Card, err error)

func (*Board) Cards

func (b *Board) Cards() (cards []Card, err error)

func (*Board) Checklists

func (b *Board) Checklists() (checklists []Checklist, err error)

func (*Board) Lists

func (b *Board) Lists() (lists []List, err error)

func (*Board) MemberCards

func (b *Board) MemberCards(IdMember string) (cards []Card, err error)

func (*Board) Members

func (b *Board) Members() (members []Member, err error)

type BoardBackground

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

type Card

type Card struct {
	Id                    string   `json:"id"`
	Name                  string   `json:"name"`
	Email                 string   `json:"email"`
	IdShort               int      `json:"idShort"`
	IdAttachmentCover     string   `json:"idAttachmentCover"`
	IdCheckLists          []string `json:"idCheckLists"`
	IdBoard               string   `json:"idBoard"`
	IdList                string   `json:"idList"`
	IdMembers             []string `json:"idMembers"`
	IdMembersVoted        []string `json:"idMembersVoted"`
	ManualCoverAttachment bool     `json:"manualCoverAttachment"`
	Closed                bool     `json:"closed"`
	Pos                   float64  `json:"pos"`
	ShortLink             string   `json:"shortLink"`
	DateLastActivity      string   `json:"dateLastActivity"`
	ShortUrl              string   `json:"shortUrl"`
	Subscribed            bool     `json:"subscribed"`
	Url                   string   `json:"url"`
	Due                   string   `json:"due"`
	Desc                  string   `json:"desc"`
	DescData              struct {
		Emoji struct{} `json:"emoji"`
	} `json:"descData"`
	CheckItemStates []struct {
		IdCheckItem string `json:"idCheckItem"`
		State       string `json:"state"`
	} `json:"checkItemStates"`
	Badges struct {
		Votes              int    `json:"votes"`
		ViewingMemberVoted bool   `json:"viewingMemberVoted"`
		Subscribed         bool   `json:"subscribed"`
		Fogbugz            string `json:"fogbugz"`
		CheckItems         int    `json:"checkItems"`
		CheckItemsChecked  int    `json:"checkItemsChecked"`
		Comments           int    `json:"comments"`
		Attachments        int    `json:"attachments"`
		Description        bool   `json:"description"`
		Due                string `json:"due"`
	} `json:"badges"`
	Labels []struct {
		Color string `json:"color"`
		Name  string `json:"name"`
	} `json:"labels"`
	// contains filtered or unexported fields
}

func (*Card) Actions

func (c *Card) Actions() (actions []Action, err error)

func (*Card) AddChecklist

func (c *Card) AddChecklist(name string) (*Checklist, error)

AddChecklist will add a checklist to the card. https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-checklists

func (*Card) AddComment

func (c *Card) AddComment(text string) (*Action, error)

AddComment will add a new comment to the card https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-actions-comments

func (*Card) Attachment

func (c *Card) Attachment(attachmentId string) (*Attachment, error)

Attachment will return the specified attachment on the card https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-attachments-idattachment

func (*Card) Attachments

func (c *Card) Attachments() (attachments []Attachment, err error)

func (*Card) Checklists

func (c *Card) Checklists() (checklists []Checklist, err error)

func (*Card) Members

func (c *Card) Members() (members []Member, err error)

type Checklist

type Checklist struct {
	Id         string          `json:"id"`
	Name       string          `json:"name"`
	IdBoard    string          `json:"idBoard"`
	IdCard     string          `json:"idCard"`
	Pos        float32         `json:"pos"`
	CheckItems []ChecklistItem `json:"checkItems"`
	// contains filtered or unexported fields
}

Checklist is a representation of a checklist on a trello card https://developers.trello.com/advanced-reference/checklist

func (*Checklist) AddItem

func (c *Checklist) AddItem(name string, pos *string, checked *bool) (*ChecklistItem, error)

AddItem will add a new item to the given checklist. The position will default to 'bottom' if nil and the item will default to 'unchecked'.

name must have a length 1 <= length <= 16384
pos can take the values 'top', 'bottom', or a positive integer

https://developers.trello.com/advanced-reference/checklist#post-1-checklists-idchecklist-checkitems

func (*Checklist) Delete

func (c *Checklist) Delete() error

Delete will delete the checklist https://developers.trello.com/advanced-reference/checklist#delete-1-checklists-idchecklist

type ChecklistItem

type ChecklistItem struct {
	State    string `json:"state"`
	Id       string `json:"id"`
	Name     string `json:"name"`
	NameData struct {
		Emoji struct{} `json:"emoji"`
	} `json:"nameData"`
	Pos int `json:"pos"`
	// contains filtered or unexported fields
}

func (*ChecklistItem) Delete

func (i *ChecklistItem) Delete() error

type Client

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

func NewAuthClient

func NewAuthClient(applicationKey string, token *string) (*Client, error)

NewAuthClient will create a trello client which allows authentication. It uses NewBearerTokenTransport to create an http.Client which can be used as a trello client.

func NewClient

func NewClient() (*Client, error)

NewClient returns a client needed to make trello API calls. If transport is nil all API calls will be unauthenticated. If you have a bearer token, NewBearerTokenTransport() may be helpful in making calls authenticated.

func NewCustomClient

func NewCustomClient(client *http.Client) (*Client, error)

NewCustomClient can be used to implement your own client

func (*Client) Board

func (c *Client) Board(boardId string) (board *Board, err error)

func (*Client) Boards

func (c *Client) Boards() (boards []Board, err error)

func (*Client) Card

func (c *Client) Card(CardId string) (card *Card, err error)

func (*Client) Delete

func (c *Client) Delete(resource string) ([]byte, error)

func (*Client) Get

func (c *Client) Get(resource string) ([]byte, error)

func (*Client) List

func (c *Client) List(listId string) (list *List, err error)

func (*Client) Member

func (c *Client) Member(nick string) (member *Member, err error)

func (*Client) Notification

func (c *Client) Notification(notificationId string) (notification *Notification, err error)

func (*Client) Organization

func (c *Client) Organization(orgId string) (organization *Organization, err error)

func (*Client) Post

func (c *Client) Post(resource string, data url.Values) ([]byte, error)

func (*Client) Put

func (c *Client) Put(resource string, data url.Values) ([]byte, error)

func (*Client) Version

func (c *Client) Version() string

type List

type List struct {
	Id      string  `json:"id"`
	Name    string  `json:"name"`
	Closed  bool    `json:"closed"`
	IdBoard string  `json:"idBoard"`
	Pos     float32 `json:"pos"`
	// contains filtered or unexported fields
}

func (*List) Actions

func (l *List) Actions() (actions []Action, err error)

func (*List) AddCard

func (l *List) AddCard(opts Card) (*Card, error)

AddCard creates with the attributes of the supplied Card struct https://developers.trello.com/advanced-reference/card#post-1-cards

func (*List) Cards

func (l *List) Cards() (cards []Card, err error)

type Member

type Member struct {
	Id         string `json:"id"`
	AvatarHash string `json:"avatarHash"`
	Bio        string `json:"bio"`
	BioData    struct {
		Emoji interface{} `json:"emoji,omitempty"`
	} `json:"bioData"`
	Confirmed                bool     `json:"confirmed"`
	FullName                 string   `json:"fullName"`
	IdPremOrgsAdmin          []string `json:"idPremOrgsAdmin"`
	Initials                 string   `json:"initials"`
	MemberType               string   `json:"memberType"`
	Products                 []int    `json:"products"`
	Status                   string   `json:"status"`
	Url                      string   `json:"url"`
	Username                 string   `json:"username"`
	AvatarSource             string   `json:"avatarSource"`
	Email                    string   `json:"email"`
	GravatarHash             string   `json:"gravatarHash"`
	IdBoards                 []string `json:"idBoards"`
	IdBoardsPinned           []string `json:"idBoardsPinned"`
	IdOrganizations          []string `json:"idOrganizations"`
	LoginTypes               []string `json:"loginTypes"`
	NewEmail                 string   `json:"newEmail"`
	OneTimeMessagesDismissed []string `json:"oneTimeMessagesDismissed"`
	Prefs                    struct {
		SendSummaries                 bool   `json:"sendSummaries"`
		MinutesBetweenSummaries       int    `json:"minutesBetweenSummaries"`
		MinutesBeforeDeadlineToNotify int    `json:"minutesBeforeDeadlineToNotify"`
		ColorBlind                    bool   `json:"colorBlind"`
		Locale                        string `json:"locale"`
	} `json:"prefs"`
	Trophies           []string `json:"trophies"`
	UploadedAvatarHash string   `json:"uploadedAvatarHash"`
	PremiumFeatures    []string `json:"premiumFeatures"`
	// contains filtered or unexported fields
}

func (*Member) AvatarUrl

func (m *Member) AvatarUrl() string

TODO: Avatar sizes [170, 30]

func (*Member) Boards

func (m *Member) Boards(field ...string) (boards []Board, err error)

func (*Member) Notifications

func (m *Member) Notifications() (notifications []Notification, err error)

type Notification

type Notification struct {
	Id     string `json:"id"`
	Unread bool   `json:"unread"`
	Type   string `json:"type"`
	Date   string `json:"date"`
	Data   struct {
		ListBefore struct {
			Id   string `json:"id"`
			Name string `json:"name"`
		} `json:"listBefore"`
		ListAfter struct {
			Id   string `json:"id"`
			Name string `json:"name"`
		} `json:"listAfter"`
		Board struct {
			Id        string `json:"id"`
			Name      string `json:"name"`
			ShortLink string `json:"shortLink"`
		} `json:"board"`
		Card struct {
			Id        string `json:"id"`
			Name      string `json:"name"`
			ShortLink string `json:"shortLink"`
			IdShort   int    `json:"idShort"`
		} `json:"card"`
		Old struct {
			IdList string `json:"idList"`
		} `json:"old"`
	} `json:"data"`
	IdMemberCreator string `json:"idMemberCreator"`
	MemberCreator   struct {
		Id         string `json:"id"`
		AvatarHash string `json:"avatarHash"`
		FullName   string `json:"fullName"`
		Initials   string `json:"initials"`
		Username   string `json:"username"`
	} `json:"memberCreator"`
	// contains filtered or unexported fields
}

type Organization

type Organization struct {
	Id          string   `json:"id"`
	Name        string   `json:"name"`
	DisplayName string   `json:"displayName"`
	Desc        string   `json:"desc"`
	DescData    string   `json:"descData"`
	Url         string   `json:"url"`
	Website     string   `json:"website"`
	LogoHash    string   `json:"logoHash"`
	Products    []string `json:"products"`
	PowerUps    []string `json:"powerUps"`
	// contains filtered or unexported fields
}

func (*Organization) Boards

func (o *Organization) Boards() (boards []Board, err error)

func (*Organization) Members

func (o *Organization) Members() (members []Member, err error)

Jump to

Keyboard shortcuts

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