Skip to content
This repository was archived by the owner on Apr 2, 2022. It is now read-only.

Added mechanism to pass arguments to client.#14

Merged
VojtechVitek merged 2 commits intoVojtechVitek:masterfrom
gedex:add-arg
Feb 26, 2016
Merged

Added mechanism to pass arguments to client.#14
VojtechVitek merged 2 commits intoVojtechVitek:masterfrom
gedex:add-arg

Conversation

@gedex
Copy link
Contributor

@gedex gedex commented Feb 6, 2016

The first endpoint to use is boards, specifically actionsresource that accept various arguments. If approved, will add other endpoints that accept arguments.

Example

var args []*trello.Argument
args = append(args, trello.NewArgument("filter", "updateCard:idList"))
args = append(args, trello.NewArgument("since", "2016-02-01"))
args = append(args, trello.NewArgument("before", "2016-02-05"))

actions, err := board.Actions(args...) // query string will be ?before=2016-02-05&filter=updateCard%3AidList&since=2016-01-28

Resolves #15

gedex added 2 commits February 6, 2016 21:17
The first endpoint to use is board. If approved, will add to other
endpoints that accept arguments.

import "net/url"

type Argument struct {
Copy link
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?

@VojtechVitek
Copy link
Owner

This is really good addition, @gedex. What would you think about the following API?

type Args []Arg

args := trello.Args{{"filter", "updateCard:idList"}, {"before", "2016-02-05"}}
actions, err := board.Actions(args...)

actions, err := board.Actions(trello.Arg{"filter": "updateCard:idList"})

@klauern
Copy link

klauern commented Feb 14, 2016

This is great, and something I was just thinking of adding. I merged this into my own fork and am using it. I fully support merging this or something like it.

@VojtechVitek
Copy link
Owner

@gedex any input on my last comment?

@VojtechVitek VojtechVitek added this to the v0.2 milestone Feb 22, 2016
@fiatjaf
Copy link
Contributor

fiatjaf commented Feb 24, 2016

Why trello.Arg instead of just map[string]string?

@fiatjaf
Copy link
Contributor

fiatjaf commented Feb 24, 2016

Accepting a list of argument keypairs is a good idea that it can be of the form of variadic arguments, instead of requiring a nil for all calls for which you don't want to send arguments.

@VojtechVitek
Copy link
Owner

Why trello.Arg instead of just map[string]string?

The only benefit would be the possibility of defining methods on Args without breaking the API. For example, we could add validation/normalization methods on Args etc. It's map[string]string anyway behind the hood.

Accepting a list of argument keypairs is a good idea that it can be of the form of variadic arguments, instead of requiring a nil for all calls for which you don't want to send arguments.

Yes, it will be variadic and optional for sure.

@VojtechVitek
Copy link
Owner

I'm gonna merge and rename to Arg. Thank you for this contribution!

VojtechVitek added a commit that referenced this pull request Feb 26, 2016
Added mechanism to pass arguments to client.
@VojtechVitek VojtechVitek merged commit eca4260 into VojtechVitek:master Feb 26, 2016
@gedex
Copy link
Contributor Author

gedex commented Feb 27, 2016

Apologies for late reply, been busy with works. Thanks for the merge @VojtechVitek.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants