Documentation ¶
Overview ¶
Package monday is taken mostly from here: https://golang.ir/play/p/aZ7tgaqFxWP.
Index ¶
- Constants
- Variables
- func CreateClient(config Config, opts ...ClientOption)
- func ResponseUnwrapped[ResT any, RetT any](binding api.Binding[ResT, RetT], responseWrapper reflect.Value, args ...any) (response ResT, err error)
- func ResponseWrapper[ResT any, RetT any](binding api.Binding[ResT, RetT], args ...any) (responseWrapper reflect.Value, err error)
- type Board
- type Checkbox
- type Client
- type ClientOption
- type Column
- type ColumnMap
- type ColumnType
- type ColumnValue
- type Config
- type DateTime
- type Dropdown
- type DropdownMap
- type DropdownValue
- type Error
- type Group
- type Item
- type ItemId
- type ItemResponse
- type Link
- type MappingConfig
- type People
- type PersonTeam
- type Request
- type StatusIndex
- type StatusLabel
- type Text
- type Timeline
- type User
- type Value
- type Votes
Constants ¶
const ( DateFormat = "2006-01-02" TimeFormat = "15:04:05" DateTimeFormat = DateFormat + " " + TimeFormat )
Variables ¶
var AddItem = api.NewBinding[ItemId, string]( func(b api.Binding[ItemId, string], args ...any) api.Request { req := NewRequest(`mutation ($boardId: Int!, $groupId: String!, $itemName: String!, $colValues: JSON!) { create_item (board_id: $boardId, group_id: $groupId, item_name: $itemName, column_values: $colValues ) { id } }`) boardId := args[0].(int) groupId := args[1].(string) itemName := args[2].(string) columnValues := args[3].(map[string]interface{}) jsonValues, _ := json.Marshal(&columnValues) req.Var("boardId", boardId) req.Var("groupId", groupId) req.Var("itemName", itemName) req.Var("colValues", string(jsonValues)) return req }, ResponseWrapper[ItemId, string], ResponseUnwrapped[ItemId, string], func(b api.Binding[ItemId, string], response ItemId, args ...any) string { return response.Id }, func(binding api.Binding[ItemId, string]) []api.BindingParam { return api.Params("boardId", 0, true, "groupId", 0, true, "itemName", "", true, "columnValues", map[string]any{}) }, false, func(client api.Client) (string, any) { return "jsonResponseKey", "create_item" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("AddItem")
AddItem is a Binding that adds an Item of the given name and column values to the given Board and Group combination. Arguments provided to Binding.Execute:
• boardId (int): The ID of the Board to which to add the Item to.
• groupId (string): The ID of the Group to which to add the Item to.
• itemName (string): The name of the new Item.
• columnValues (map[string]interface{}): The values of the columns of the new Item.
Binding.Execute returns the ID of the newly added Item.
var AddItemUpdate = api.NewBinding[ItemId, string]( func(b api.Binding[ItemId, string], args ...any) api.Request { itemId := args[0].(int) msg := args[1].(string) req := NewRequest(`mutation ($itemId: Int!, $body: String!) { create_update (item_id: $itemId, body: $body ) { id } }`) req.Var("itemId", itemId) req.Var("body", msg) return req }, ResponseWrapper[ItemId, string], ResponseUnwrapped[ItemId, string], func(b api.Binding[ItemId, string], response ItemId, args ...any) string { return response.Id }, func(binding api.Binding[ItemId, string]) []api.BindingParam { return api.Params("itemId", 0, true, "msg", "", true) }, false, func(client api.Client) (string, any) { return "jsonResponseKey", "create_update" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("AddItemUpdate")
AddItemUpdate is a Binding that adds an update with the given message to the Item of the given ID. Arguments provided to Binding.Execute:
• itemId (int): The ID of the Item to add an update to.
• msg (string): The body of the update that will be added to the Item.
Binding.Execute returns the ID of the Item to which the update was added.
var ChangeMultipleColumnValues = api.NewBinding[ItemId, string]( func(b api.Binding[ItemId, string], args ...any) api.Request { req := NewRequest(`mutation ($itemId: Int, $boardId: Int!, $colValues: JSON!) { change_multiple_column_values (item_id: $itemId, board_id: $boardId, column_values: $colValues) { id } }`) itemId := args[0].(int) boardId := args[1].(int) columnValues := args[2].(map[string]interface{}) jsonValues, _ := json.Marshal(&columnValues) req.Var("itemId", itemId) req.Var("boardId", boardId) req.Var("colValues", string(jsonValues)) return req }, ResponseWrapper[ItemId, string], ResponseUnwrapped[ItemId, string], func(b api.Binding[ItemId, string], response ItemId, args ...any) string { return response.Id }, func(binding api.Binding[ItemId, string]) []api.BindingParam { return api.Params("itemId", 0, true, "boardId", 0, true, "columnValues", map[string]any{}) }, false, func(client api.Client) (string, any) { return "jsonResponseKey", "change_multiple_column_values" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("ChangeMultipleColumnValues")
ChangeMultipleColumnValues is a Binding that changes multiple ColumnValue for the given Item and Board combination. Arguments provided to Binding.Execute:
• itemId (int): The ID of the Item for which we want to change the column values for.
• boardId (int): The ID of the Board that the Item resides within.
• columnValues (map[string]interface{}): The values to set the columns of the Item of the given ID that is within the Board of the given ID.
Binding.Execute returns the ID of the Item that has been mutated.
var DefaultClient api.Client
var DeleteItem = api.NewBinding[ItemId, string]( func(binding api.Binding[ItemId, string], args ...any) (request api.Request) { req := NewRequest(`mutation ($itemId: Int) { delete_item (item_id: $itemId) { id } }`) itemId := args[0].(int) req.Var("itemId", itemId) return req }, ResponseWrapper[ItemId, string], ResponseUnwrapped[ItemId, string], func(binding api.Binding[ItemId, string], response ItemId, args ...any) string { return response.Id }, func(binding api.Binding[ItemId, string]) []api.BindingParam { return api.Params("itemId", 0, true) }, false, func(client api.Client) (string, any) { return "jsonResponseKey", "delete_item" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, )
DeleteItem is an api.Binding that deletes the Item of the given item ID. Arguments provided to Binding.Execute:
itemId (int): The ID of the Item that we want to delete.
Binding.Execute returns the ID for the Item that was deleted.
var GetBoards = api.NewBinding[[]Board, []Board]( func(b api.Binding[[]Board, []Board], args ...any) api.Request { var ( page int workspaceIds []int ) req := NewRequest(`query ($page: Int!, $workspaceIds: [Int]) { boards (page: $page, workspace_ids: $workspaceIds) { id name } }`) page = args[0].(int) workspaceIds = slices.Comprehension[any, int](args[1:], func(idx int, value any, arr []any) int { return value.(int) }) req.Var("page", page) req.Var("workspaceIds", workspaceIds) return req }, ResponseWrapper[[]Board, []Board], ResponseUnwrapped[[]Board, []Board], nil, func(binding api.Binding[[]Board, []Board]) []api.BindingParam { return api.Params("page", 1, "workspaceIds", []int{}, false, true) }, true, func(client api.Client) (string, any) { return "jsonResponseKey", "boards" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("GetBoards")
GetBoards is a Binding to retrieve multiple Board from the given workspaces. Arguments provided to Binding.Execute:
• page (int): The page of results to retrieve. This means that GetBoards can be passed to an api.Paginator.
• workspaceIds ([]int...): The IDs of the workspaces to retrieve all Board from.
Binding.Execute returns a list of Board instances from the given workspaces for the given page of results.
var GetColumnMap = api.NewBinding[columnResponse, map[string]ColumnMap]( getColumnsRequest[columnResponse, map[string]ColumnMap], ResponseWrapper[columnResponse, map[string]ColumnMap], ResponseUnwrapped[columnResponse, map[string]ColumnMap], func(b api.Binding[columnResponse, map[string]ColumnMap], response columnResponse, args ...any) map[string]ColumnMap { m := make(map[string]ColumnMap) for _, board := range response { m[board.Id] = make(ColumnMap) for _, column := range board.Columns { m[board.Id][column.Id] = column } } return m }, func(binding api.Binding[columnResponse, map[string]ColumnMap]) []api.BindingParam { return boardIdsParam() }, false, func(client api.Client) (string, any) { return "jsonResponseKey", "boards" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("GetColumnMap")
GetColumnMap is a Binding to retrieve the multiple ColumnMap from the given boards. Arguments provided to Binding.Execute:
• boardIds ([]int...): The IDs of the boards to retrieve all ColumnMap for.
Binding.Execute returns a map of Board IDs to ColumnMap instances for the given boards.
var GetColumns = api.NewBinding[columnResponse, []Column]( getColumnsRequest[columnResponse, []Column], ResponseWrapper[columnResponse, []Column], ResponseUnwrapped[columnResponse, []Column], func(b api.Binding[columnResponse, []Column], response columnResponse, args ...any) []Column { columns := make([]Column, 0) for _, board := range response { columns = append(columns, board.Columns...) } return columns }, func(binding api.Binding[columnResponse, []Column]) []api.BindingParam { return boardIdsParam() }, false, func(client api.Client) (string, any) { return "jsonResponseKey", "boards" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("GetColumns")
GetColumns is a Binding to retrieve multiple Column from the given boards. Arguments provided to Binding.Execute:
• boardIds ([]int...): The IDs of the boards to retrieve all Column from.
Binding.Execute returns a list of Column instances from the given boards.
var GetGroups = api.NewBinding[groupResponse, []Group]( func(b api.Binding[groupResponse, []Group], args ...any) api.Request { req := NewRequest(`query ($boardIds: [Int]) { boards (ids: $boardIds) { groups { id title } } }`) req.Var("boardIds", slices.Comprehension(args, func(idx int, value any, arr []any) int { return value.(int) })) return req }, ResponseWrapper[groupResponse, []Group], ResponseUnwrapped[groupResponse, []Group], func(b api.Binding[groupResponse, []Group], response groupResponse, args ...any) []Group { groups := make([]Group, 0) for _, board := range response { groups = append(groups, board.Groups...) } return groups }, func(binding api.Binding[groupResponse, []Group]) []api.BindingParam { return boardIdsParam() }, false, func(client api.Client) (string, any) { return "jsonResponseKey", "boards" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("GetGroups")
GetGroups is a Binding to retrieve multiple Group from the given boards. Arguments provided to Binding.Execute:
• boardIds ([]int...): The IDs of the boards to retrieve all Group from.
Binding.Execute returns a list of Group instances from the given boards.
var GetItems = api.NewBinding[ItemResponse, []Item]( func(b api.Binding[ItemResponse, []Item], args ...any) api.Request { var ( page int boardIds []int groupIds []string ) req := NewRequest(` query ($page: Int!, $boardIds: [Int], $groupIds: [String]) { boards (ids: $boardIds) { id groups (ids: $groupIds) { id items (limit: 10, page: $page) { id name column_values { id title value } } } } } `) if len(args) > 0 { page = args[0].(int) } if len(args) > 1 { boardIds = args[1].([]int) } if len(args) > 2 { groupIds = args[2].([]string) } req.Var("page", page) req.Var("boardIds", boardIds) req.Var("groupIds", groupIds) return req }, ResponseWrapper[ItemResponse, []Item], ResponseUnwrapped[ItemResponse, []Item], func(b api.Binding[ItemResponse, []Item], response ItemResponse, args ...any) []Item { items := make([]Item, 0) for _, board := range response { for _, group := range board.Groups { for _, item := range group.Items { items = append(items, Item{ Id: item.Id, GroupId: group.Id, BoardId: board.Id, Name: item.Name, ColumnValues: item.ColumnValues, }) } } } return items }, func(binding api.Binding[ItemResponse, []Item]) []api.BindingParam { return api.Params("page", 1, "boardIds", []int{}, "groupIds", []string{}) }, true, func(client api.Client) (string, any) { return "jsonResponseKey", "boards" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("GetItems")
GetItems is a Binding that retrieves multiple Item from the given Board(s) and Group(s). Arguments provided to Binding.Execute:
• page (int): The page of results to retrieve. This means that GetItems can be passed to an api.Paginator.
• boardIds ([]int): The IDs of the Board from which to retrieve all Item from.
• groupIds ([]string): The IDs of the Group from which to retrieve all Item from.
Binding.Execute returns a list of Item instances from the given Board(s) and Group(s).
var GetUsers = api.NewBinding[[]User, []User]( func(binding api.Binding[[]User, []User], args ...any) api.Request { return NewRequest(`{ users { id name email } }`) }, ResponseWrapper[[]User, []User], ResponseUnwrapped[[]User, []User], nil, nil, false, func(client api.Client) (string, any) { return "jsonResponseKey", "users" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("GetUsers")
GetUsers is a Binding to retrieve all User from the linked Monday.com organisation for the API token.
var Me = api.NewBinding[User, User]( func(binding api.Binding[User, User], args ...any) (request api.Request) { return NewRequest(`{ me { id name email } }`) }, ResponseWrapper[User, User], ResponseUnwrapped[User, User], nil, nil, false, func(client api.Client) (string, any) { return "jsonResponseKey", "me" }, func(client api.Client) (string, any) { return "config", client.(*Client).Config }, ).SetName("Me")
Me is an api.Binding that will retrieve the User bound to the Monday API token used to fetch it.
Functions ¶
func CreateClient ¶
func CreateClient(config Config, opts ...ClientOption)
CreateClient creates and sets the DefaultClient.
func ResponseUnwrapped ¶
Types ¶
type Checkbox ¶
type Checkbox struct {
C string `json:"checked"`
}
func BuildCheckbox ¶
func (Checkbox) Type ¶
func (cb Checkbox) Type() ColumnType
type ClientOption ¶
type ClientOption func(*Client)
type Column ¶
type Column struct { Id string `json:"id"` Title string `json:"title"` Type ColumnType `json:"type"` // text, boolean, color, ... Settings string `json:"settings_str"` // used to get label index values for color(status) and dropdown column types // contains filtered or unexported fields }
func (*Column) SettingsMap ¶
type ColumnMap ¶
ColumnMap is a map of column IDs to Column. To fetch the ColumnMap for a specific board/multiple boards you can use the GetColumnMap Binding.
func (ColumnMap) DecodeValue ¶
func (cm ColumnMap) DecodeValue(columnValue ColumnValue) (Value, error)
type ColumnType ¶
type ColumnType string
const ( TextType ColumnType = "text" StatusType ColumnType = "color" BooleanType ColumnType = "boolean" DateType ColumnType = "date" TimelineType ColumnType = "timerange" MultiplePersonType ColumnType = "multiple-person" DropdownType ColumnType = "dropdown" VotesType ColumnType = "votes" )
func (ColumnType) String ¶
func (ct ColumnType) String() string
type ColumnValue ¶
type Config ¶
type Config interface { MondayToken() string MondayMappingForModel(model any) MappingConfig }
type DropdownMap ¶
type DropdownMap map[string]DropdownValue
func (DropdownMap) Selected ¶
func (dm DropdownMap) Selected() []DropdownValue
type DropdownValue ¶
type Error ¶
type Item ¶
type Item struct { Id string GroupId string BoardId string Name string ColumnValues []ColumnValue }
type ItemResponse ¶
type ItemResponse []struct { Id string `json:"id"` Groups []struct { Id string `json:"id"` Items []struct { Id string `json:"id"` Name string `json:"name"` ColumnValues []ColumnValue `json:"column_values"` } `json:"items"` } `json:"groups"` }
type MappingConfig ¶
type MappingConfig interface { MappingModelName() string MappingBoardIDs() []int MappingGroupIDs() []string MappingColumnsToUpdate() []string MappingModelInstanceIDColumnID() string MappingModelInstanceUpvotesColumnID() string MappingModelInstanceDownvotesColumnID() string MappingModelInstanceWatchedColumnID() string ColumnValues(game any, columnIDs ...string) (columnValues map[string]any, err error) }
type People ¶
type People struct {
PersonsAndTeams []PersonTeam `json:"personsAndTeams"`
}
func BuildPeople ¶
func (People) Type ¶
func (p People) Type() ColumnType
type PersonTeam ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is a GraphQL request.
func NewRequest ¶
NewRequest makes a new Request with the specified string.
type StatusIndex ¶
type StatusIndex struct {
Index int `json:"index"`
}
func BuildStatusIndex ¶
func BuildStatusIndex(index int) StatusIndex
type StatusLabel ¶
type StatusLabel struct {
Label string `json:"label"`
}
func BuildStatusLabel ¶
func BuildStatusLabel(label string) StatusLabel
type Value ¶
type Value interface { Type() ColumnType Value() (any, error) }
func DecodeLabels ¶
func DecodeLabels(column Column, columnValue ColumnValue) Value
DecodeLabels displays index value of all labels for a column. Uses column settings_str (see GetColumns and Column). Use for Status (color) and Dropdown fields.
func DecodeValue ¶
func DecodeValue(columnMap ColumnMap, columnValue ColumnValue) (value Value, err error)
DecodeValue converts column value returned from Monday to a Value.
color(status) returns index of label chosen, ex. "3" boolean(checkbox) returns "true" or "false" date returns "2019-05-22"
Types "multi-person" and "dropdown" may have multiple values. For these, a slice of strings is returned