Advertisement
ajkessel

Hydroxide modification illustrating folder/label filtering

Dec 5th, 2024 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.65 KB | None | 0 0
  1. func (c *Client) ListLabels() ([]*Label, error) {
  2.     req, err := c.newRequest(http.MethodGet, "/labels", nil)
  3.     if err != nil {
  4.         return nil, err
  5.     }
  6.  
  7.     var respData struct {
  8.         resp
  9.         Labels []*Label
  10.     }
  11.     if err := c.doJSON(req, &respData); err != nil {
  12.         return nil, err
  13.     }
  14.     var filteredLabels []*Label
  15.     for _, label := range respData.Labels {
  16.         if label.Type == 4 || label.Name == "[Bulk]" || label.Name == "Bulk" || label.Name == "Newsletters" {
  17.             filteredLabels = append(filteredLabels, label)
  18.             log.Printf(">> added label %v", label.Name)
  19.         } else {
  20.             log.Printf(">> discarding label %v", label.Name)
  21.         }
  22.     }
  23.  
  24.     return filteredLabels, nil
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement