Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 14 additions & 1 deletion internal/client/apps/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ type credential struct {
}

type apiProduct struct {
Name string `json:"apiproduct,omitempty"`
Name string `json:"apiproduct,omitempty"`
Status string `json:"status,omitempty"`
}

type importCredential struct {
Expand Down Expand Up @@ -540,6 +541,18 @@ func createAsyncApp(app application, developerEntities developers.Appdevelopers,
if err != nil {
return
}

// set the API product status on the credential if it was approved
for _, apiProd := range credential.APIProducts {
if apiProd.Status == "approved" {
apiclient.ClientPrintHttpResponse.Set(false)
_, err = ManageKey(url.QueryEscape(developerEmail), app.Name, credential.ConsumerKey, "approve", apiProd.Name)
apiclient.ClientPrintHttpResponse.Set(apiclient.GetCmdPrintHttpResponseSetting())
if err != nil {
clilog.Warning.Printf("failed to approve API product %s on key %s: %v\n", apiProd.Name, credential.ConsumerKey, err)
}
}
}
} else {
clilog.Warning.Println("NOTE: apiProducts are not associated with the app")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/client/apps/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestManageKey(t *testing.T) {
clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil {
t.Fatalf("%v", err)
}
if _, err := ManageKey(name, appID, "key1", "approve"); err != nil {
if _, err := ManageKey(name, appID, "key1", "approve", ""); err != nil {
t.Fatalf("%v", err)
}
}
Expand Down