Skip to content

Commit

Permalink
bug: Create Developer Subscription (#558)
Browse files Browse the repository at this point in the history
* fix: for #557

* fix: removed startTime and name
  • Loading branch information
ssvaidyanathan authored Oct 30, 2024
1 parent 3777528 commit 15ea283
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
6 changes: 1 addition & 5 deletions internal/client/developers/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ import (
"strings"
)

func CreateSubscription(email string, name string, apiproduct string, startTime string, endTime string) (respBody []byte, err error) {
func CreateSubscription(email string, apiproduct string) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.GetApigeeBaseURL())

subscription := []string{}

subscription = append(subscription, "\"name\":\""+name+"\"")
subscription = append(subscription, "\"apiproduct\":\""+apiproduct+"\"")
subscription = append(subscription, "\"startTime\":\""+startTime+"\"")
subscription = append(subscription, "\"endTime\":\""+endTime+"\"")

payload := "{" + strings.Join(subscription, ",") + "}"
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "developers", url.QueryEscape(email), "subscriptions")
Expand Down
16 changes: 4 additions & 12 deletions internal/cmd/developers/crtsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,28 @@ import (
// CreateSubCmd to create developer subscription
var CreateSubCmd = &cobra.Command{
Use: "create",
Short: "Create a subcription for a developer",
Long: "Create a developer",
Short: "Create a subscription for a developer",
Long: "Create a subscription for a developer",
Args: func(cmd *cobra.Command, args []string) (err error) {
apiclient.SetRegion(region)
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
cmd.SilenceUsage = true

_, err = developers.CreateSubscription(email, name, apiproduct, startTime, endTime)
_, err = developers.CreateSubscription(email, apiproduct)
return
},
}

var apiproduct, startTime, endTime string
var apiproduct string

func init() {
CreateSubCmd.Flags().StringVarP(&email, "email", "e",
"", "The developer's email")
CreateSubCmd.Flags().StringVarP(&name, "name", "n",
"", "The subscription name")
CreateSubCmd.Flags().StringVarP(&apiproduct, "apiproduct", "p",
"", "The name of the API Product")
CreateSubCmd.Flags().StringVarP(&startTime, "start", "s",
"", "Subscription start time")
CreateSubCmd.Flags().StringVarP(&endTime, "end", "d",
"", "Subscription end time")

_ = CreateSubCmd.MarkFlagRequired("email")
_ = CreateSubCmd.MarkFlagRequired("apiproduct")
_ = CreateSubCmd.MarkFlagRequired("start")
_ = CreateSubCmd.MarkFlagRequired("end")
}

0 comments on commit 15ea283

Please sign in to comment.