Skip to content

Commit

Permalink
bug: fixes missing expiry during update #341
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Dec 2, 2023
1 parent 9d3ff8b commit c88639f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/apiclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func handleResponse(resp *http.Response) (respBody []byte, err error) {
clilog.HttpError.Println(string(respBody))
return nil, errors.New(getErrorMessage(resp.StatusCode))
}

clilog.Debug.Println("Response: ", string(respBody))
return respBody, PrettyPrint(resp.Header.Get("Content-Type"), respBody)
}

Expand Down
10 changes: 7 additions & 3 deletions internal/client/apps/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func CreateKey(developerEmail string, appID string, consumerKey string, consumer
// since the API does not support adding products when creating a key, use a second API call to add products
if len(apiProducts) > 0 {
apiclient.ClientPrintHttpResponse.Set(false)
respBody, err = UpdateKeyProducts(developerEmail, appID, consumerKey, apiProducts)
respBody, err = UpdateKeyProducts(developerEmail, appID, consumerKey, apiProducts, expires)
apiclient.ClientPrintHttpResponse.Set(apiclient.GetCmdPrintHttpResponseSetting())
}

Expand All @@ -87,7 +87,8 @@ func GetKey(developerEmail string, appID string, key string) (respBody []byte, e
}

// UpdateKey
func UpdateKey(developerEmail string, appID string, consumerKey string, consumerSecret string, apiProducts []string, scopes []string, expires string, attrs map[string]string) (respBody []byte, err error) {
func UpdateKey(developerEmail string, appID string, consumerKey string, consumerSecret string,
apiProducts []string, scopes []string, expires string, attrs map[string]string) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.BaseURL)

key := []string{}
Expand Down Expand Up @@ -127,11 +128,14 @@ func UpdateKey(developerEmail string, appID string, consumerKey string, consumer
return respBody, err
}

func UpdateKeyProducts(developerEmail string, appID string, consumerKey string, apiProducts []string) (respBody []byte, err error) {
func UpdateKeyProducts(developerEmail string, appID string, consumerKey string, apiProducts []string, expires string) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.BaseURL)

key := []string{}
key = append(key, "\"apiProducts\":[\""+getArrayStr(apiProducts)+"\"]")
if expires != "" {
key = append(key, "\"expiresAt\":\""+expires+"\"")
}

payload := "{" + strings.Join(key, ",") + "}"

Expand Down

0 comments on commit c88639f

Please sign in to comment.