Skip to content
This repository was archived by the owner on Apr 2, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions arg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2014 go-trello authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package trello

import "net/url"

type Argument struct {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call it Arg?

Name string
Value string
}

func NewArgument(name, value string) *Argument {
return &Argument{
Name: name,
Value: value,
}
}

func EncodeArgs(args []*Argument) string {
v := url.Values{}
for _, arg := range args {
v.Set(arg.Name, arg.Value)
}
return v.Encode()
}
9 changes: 7 additions & 2 deletions board.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,13 @@ func (b *Board) MemberCards(IdMember string) (cards []Card, err error) {
return
}

func (b *Board) Actions() (actions []Action, err error) {
body, err := b.client.Get("/boards/" + b.Id + "/actions")
func (b *Board) Actions(arg ...*Argument) (actions []Action, err error) {
ep := "/boards/" + b.Id + "/actions"
if query := EncodeArgs(arg); query != "" {
ep += "?" + query
}

body, err := b.client.Get(ep)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it'd be client.Get(string, ...*Arg) doing the encoding

if err != nil {
return
}
Expand Down