Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (c *Client) ListLabels() ([]*Label, error) {
- req, err := c.newRequest(http.MethodGet, "/labels", nil)
- if err != nil {
- return nil, err
- }
- var respData struct {
- resp
- Labels []*Label
- }
- if err := c.doJSON(req, &respData); err != nil {
- return nil, err
- }
- var filteredLabels []*Label
- for _, label := range respData.Labels {
- if label.Type == 4 || label.Name == "[Bulk]" || label.Name == "Bulk" || label.Name == "Newsletters" {
- filteredLabels = append(filteredLabels, label)
- log.Printf(">> added label %v", label.Name)
- } else {
- log.Printf(">> discarding label %v", label.Name)
- }
- }
- return filteredLabels, nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement