-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_account_info.go
37 lines (30 loc) · 1.11 KB
/
edit_account_info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package telegraph
type editAccountInfo struct {
// Access token of the Telegraph account.
AccessToken string `json:"access_token"`
// New account name.
ShortName string `json:"short_name,omitempty"`
// New default author name used when creating new articles.
AuthorName string `json:"author_name,omitempty"`
// New default profile link, opened when users click on the author's name below the title. Can be any link,
// not necessarily to a Telegram profile or channel.
AuthorURL string `json:"author_url,omitempty"`
}
// EditAccountInfo update information about a Telegraph account. Pass only the parameters that you want to edit. On
// success, returns an Account object with the default fields.
func (a *Account) EditAccountInfo(update Account) (*Account, error) {
data, err := makeRequest("editAccountInfo", editAccountInfo{
AccessToken: a.AccessToken,
ShortName: update.ShortName,
AuthorName: update.AuthorName,
AuthorURL: update.AuthorURL,
})
if err != nil {
return nil, err
}
result := new(Account)
if err = parser.Unmarshal(data, result); err != nil {
return nil, err
}
return result, nil
}