2017-09-04 21:09:59 +00:00
|
|
|
package telegraph
|
|
|
|
|
2020-01-14 06:30:18 +00:00
|
|
|
type getAccountInfo struct {
|
|
|
|
// Access token of the Telegraph account.
|
|
|
|
AccessToken string `json:"access_token"`
|
2017-09-04 21:09:59 +00:00
|
|
|
|
2020-01-14 06:30:18 +00:00
|
|
|
// List of account fields to return.
|
|
|
|
Fields []string `json:"fields,omitempty"`
|
|
|
|
}
|
2017-09-04 21:09:59 +00:00
|
|
|
|
2017-12-13 10:11:23 +00:00
|
|
|
// GetAccountInfo get information about a Telegraph account. Returns an Account object on success.
|
2019-07-24 08:03:29 +00:00
|
|
|
func (a *Account) GetAccountInfo(fields ...string) (*Account, error) {
|
2020-01-14 06:30:18 +00:00
|
|
|
data, err := makeRequest("getAccountInfo", getAccountInfo{
|
|
|
|
AccessToken: a.AccessToken,
|
|
|
|
Fields: fields,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2019-07-24 08:03:29 +00:00
|
|
|
}
|
2017-09-04 21:09:59 +00:00
|
|
|
|
2020-01-14 06:30:18 +00:00
|
|
|
result := new(Account)
|
|
|
|
if err = parser.Unmarshal(data, result); err != nil {
|
2017-09-04 21:09:59 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-01-14 06:30:18 +00:00
|
|
|
return result, nil
|
2017-09-04 21:09:59 +00:00
|
|
|
}
|