Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: fixes missing expiry during update #341 #343

Merged
merged 5 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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