From 061898a3104e2e78098e1a1c60f8badf084d3cb2 Mon Sep 17 00:00:00 2001 From: gfleury Date: Wed, 5 Jun 2019 10:19:00 +0200 Subject: [PATCH] Adding GetPullRequestResponse and fixing Create (PullRequest) --- api_response.go | 9 ++++++++- default_api.go | 14 +++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/api_response.go b/api_response.go index adb409f..5459b8a 100644 --- a/api_response.go +++ b/api_response.go @@ -125,7 +125,7 @@ type PullRequestRef struct { type PullRequest struct { ID int `json:"id"` - Version int32 `json:"version"` + Version int32 `json:"version"` Title string `json:"title"` Description string `json:"description"` State string `json:"state"` @@ -299,6 +299,13 @@ func GetSSHKeysResponse(r *APIResponse) ([]SSHKey, error) { return m, err } +// GetPullRequestResponse cast PullRequest into structure +func GetPullRequestResponse(r *APIResponse) (PullRequest, error) { + var m PullRequest + err := mapstructure.Decode(r.Values["values"], &m) + return m, err +} + // NewAPIResponse create new APIResponse from http.Response func NewAPIResponse(r *http.Response) *APIResponse { diff --git a/default_api.go b/default_api.go index 4c03851..a0e6a49 100644 --- a/default_api.go +++ b/default_api.go @@ -5,6 +5,7 @@ package bitbucketv1 import ( + "encoding/json" "fmt" "io/ioutil" "net/url" @@ -611,18 +612,13 @@ func (a *DefaultApiService) Create(projectKey, repositorySlug string, localVarOp return nil, err } - if localVarTempParam, localVarOk := localVarOptionals["from"].(string); localVarOk { - localVarQueryParams.Add("from", parameterToString(localVarTempParam, "")) - } - if localVarTempParam, localVarOk := localVarOptionals["to"].(string); localVarOk { - localVarQueryParams.Add("to", parameterToString(localVarTempParam, "")) - } - if localVarTempParam, localVarOk := localVarOptionals["fromRepo"].(string); localVarOk { - localVarQueryParams.Add("fromRepo", parameterToString(localVarTempParam, "")) + localVarPostBody, err := json.Marshal(localVarOptionals) + if err != nil { + return nil, err } // to determine the Content-Type header - localVarHTTPContentTypes := []string{} + localVarHTTPContentTypes := []string{"application/json"} // set Content-Type header localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)