emoji.go
author Mikael Berthe <mikael@lilotux.net>
Fri, 07 Sep 2018 19:17:12 +0200
changeset 243 7386c6a454a8
parent 238 1c0042e76902
permissions -rw-r--r--
Change the way parameter lists are handled internally Instead of trying to guess if a query key is a list (to strip the index number, since Rails expects list IDs without index number), we prefix the key name with the index when dealing with lists. E.g.: [0]ids: "one" [1]ids: "two" will be sent as ids[]=one&ids[]=two It makes it more reliable and let us differenciate between arrays and objects (objects are untouched and sent as-is).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
208
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     1
/*
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     2
Copyright 2018 Mikael Berthe
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     3
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     4
Licensed under the MIT license.  Please see the LICENSE file is this directory.
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     5
*/
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     6
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     7
package madon
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     8
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     9
import (
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    10
	"github.com/sendgrid/rest"
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    11
)
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    12
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    13
// GetCustomEmojis returns a list with the server custom emojis
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    14
func (mc *Client) GetCustomEmojis(lopt *LimitParams) ([]Emoji, error) {
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    15
	var emojiList []Emoji
238
1c0042e76902 Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents: 208
diff changeset
    16
	if err := mc.apiCall("v1/custom_emojis", rest.Get, nil, lopt, nil, &emojiList); err != nil {
208
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    17
		return nil, err
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    18
	}
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    19
	return emojiList, nil
0b58780582d9 Add GetCustomEmojis
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    20
}