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

remove unnecessary pointers #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions checklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,26 @@ func (c *Checklist) Delete() error {
// 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 (c *Checklist) AddItem(name string, pos *string, checked *bool) (*ChecklistItem, error) {
func (c *Checklist) AddItem(name string, pos string, checked bool) (*ChecklistItem, error) {
payload := url.Values{}
if len(name) < 1 || len(name) > 16384 {
return nil, fmt.Errorf("Checklist item name %q has invalid length. 1 <= length <= 16384", name)
}
payload.Set("name", name)
if pos != nil {
if *pos != "top" && *pos != "bottom" {
i, err := strconv.Atoi(*pos)
if pos != "" {
if pos != "top" && pos != "bottom" {
i, err := strconv.Atoi(pos)
if err != nil {
return nil, err
}
if i < 1 {
return nil, fmt.Errorf("Checklist item position %q is invalid. Only 'top', 'bottom', or a positive integer", *pos)
return nil, fmt.Errorf("Checklist item position %q is invalid. Only 'top', 'bottom', or a positive integer", pos)
}
}
payload.Set("pos", *pos)
payload.Set("pos", pos)
}
if checked != nil {
payload.Set("checked", strconv.FormatBool(*checked))
if checked {
payload.Set("checked", strconv.FormatBool(checked))
}
body, err := c.client.Post("/checklist/"+c.Id+"/checkItems", payload)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (c *Client) Delete(resource string) ([]byte, error) {
type bearerRoundTripper struct {
Delegate http.RoundTripper
key string
token *string
token string
}

func (b *bearerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
Expand All @@ -87,7 +87,7 @@ func (b *bearerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error
}
values := req.URL.Query()
values.Add("key", b.key)
values.Add("token", *b.token)
values.Add("token", b.token)
req.URL.RawQuery = values.Encode()
return b.Delegate.RoundTrip(req)
}
Expand All @@ -98,7 +98,7 @@ func (b *bearerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error
// 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
func NewBearerTokenTransport(applicationKey string, token *string) *bearerRoundTripper {
func NewBearerTokenTransport(applicationKey string, token string) *bearerRoundTripper {
return &bearerRoundTripper{
key: applicationKey,
token: token,
Expand All @@ -120,7 +120,7 @@ func NewCustomClient(client *http.Client) (*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 NewAuthClient(applicationKey string, token *string) (*Client, error) {
func NewAuthClient(applicationKey string, token string) (*Client, error) {
rr := NewBearerTokenTransport(applicationKey, token)
client := &http.Client{
Transport: rr,
Expand Down
2 changes: 1 addition & 1 deletion tests/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestManyThings(t *testing.T) {
g.It("should create a client", func() {
key := os.Getenv("API_KEY")
token := os.Getenv("API_TOKEN")
Client, err = trello.NewAuthClient(key, &token)
Client, err = trello.NewAuthClient(key, token)
Expect(err).To(BeNil())
})

Expand Down