From 792d95fe6ddd813915bd552723c02208bacbec48 Mon Sep 17 00:00:00 2001 From: Hugues Malphettes Date: Tue, 3 Sep 2019 21:08:26 +0800 Subject: [PATCH] Add the AccessTokenResponse https://docs.atlassian.com/bitbucket-server/rest/5.5.2/bitbucket-access-tokens-rest.html --- api_response.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api_response.go b/api_response.go index d5242cb..d0972fe 100644 --- a/api_response.go +++ b/api_response.go @@ -538,6 +538,23 @@ func (p PermissionRepository) String() string { return string(p) } +type AccessTokenResponse struct { + ID string `json:"id"` + CreatedDate int64 `json:"createdDate"` + LastAuthenticated int64 `json:"lastAuthenticated"` + Name string `json:"name"` + Permissions []string `json:"permissions"` + User User `json:"user"` + Token string `json:"token"` +} + +// GetAccessTokenResponse cast AccessTokenResponse into structure +func GetAccessTokenResponse(r *APIResponse) (AccessTokenResponse, error) { + var m AccessTokenResponse + err := mapstructure.Decode(r.Values, &m) + return m, err +} + func (k *SSHKey) String() string { parts := make([]string, 1, 2) parts[0] = strings.TrimSpace(k.Text)