suggestions.go
author Mikael Berthe <mikael@lilotux.net>
Mon, 29 Jul 2019 21:57:47 +0200
changeset 253 0e8c8026cf40
parent 238 1c0042e76902
permissions -rw-r--r--
Update dependencies
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
233
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     1
/*
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     2
Copyright 2018 Mikael Berthe
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     3
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     4
Licensed under the MIT license.  Please see the LICENSE file is this directory.
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     5
*/
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     6
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     7
package madon
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     8
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     9
import (
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    10
	"strconv"
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    11
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    12
	"github.com/sendgrid/rest"
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    13
)
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    14
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    15
// GetSuggestions returns a list of follow suggestions from the server
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    16
func (mc *Client) GetSuggestions(lopt *LimitParams) ([]Account, error) {
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    17
	endPoint := "suggestions"
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    18
	method := rest.Get
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    19
	var accountList []Account
238
1c0042e76902 Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents: 233
diff changeset
    20
	if err := mc.apiCall("v1/"+endPoint, method, nil, lopt, nil, &accountList); err != nil {
233
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    21
		return nil, err
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    22
	}
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    23
	return accountList, nil
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    24
}
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    25
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    26
// DeleteSuggestion removes the account from the suggestion list
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    27
func (mc *Client) DeleteSuggestion(accountID int64) error {
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    28
	endPoint := "suggestions/" + strconv.FormatInt(accountID, 10)
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    29
	method := rest.Delete
238
1c0042e76902 Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents: 233
diff changeset
    30
	return mc.apiCall("v1/"+endPoint, method, nil, nil, nil, nil)
233
b5fb9a1b68c4 Add suggestions
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    31
}