Skip to content

Commit 77eb4a9

Browse files
authored
Regenerate OpenAPI client & add more features (#35)
1 parent 93a583d commit 77eb4a9

112 files changed

Lines changed: 20040 additions & 7004 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎client/client.gen.go‎

Lines changed: 17782 additions & 6923 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cmd/billing/billing.go‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package billing
2+
3+
import (
4+
"github.com/hostinger/api-cli/cmd/billing/catalog"
5+
"github.com/hostinger/api-cli/cmd/billing/payment_methods"
6+
"github.com/hostinger/api-cli/cmd/billing/subscriptions"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var GroupCmd = &cobra.Command{
11+
Use: "billing",
12+
Short: "Billing management",
13+
Long: ``,
14+
}
15+
16+
func init() {
17+
GroupCmd.AddCommand(catalog.GroupCmd)
18+
GroupCmd.AddCommand(payment_methods.GroupCmd)
19+
GroupCmd.AddCommand(subscriptions.GroupCmd)
20+
}

‎cmd/billing/catalog/catalog.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package catalog
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var GroupCmd = &cobra.Command{
8+
Use: "catalog",
9+
Short: "Catalog management",
10+
Long: ``,
11+
}
12+
13+
func init() {
14+
GroupCmd.AddCommand(ListCmd)
15+
}

‎cmd/billing/catalog/list.go‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package catalog
2+
3+
import (
4+
"context"
5+
"github.com/hostinger/api-cli/api"
6+
"github.com/hostinger/api-cli/client"
7+
"github.com/hostinger/api-cli/output"
8+
"github.com/hostinger/api-cli/utils"
9+
"github.com/spf13/cobra"
10+
"log"
11+
)
12+
13+
var ListCmd = &cobra.Command{
14+
Use: "list",
15+
Short: "Get catalog item list",
16+
Long: `This endpoint retrieves a list of available catalog items that can be ordered.
17+
18+
Prices in the response are displayed in cents.`,
19+
Run: func(cmd *cobra.Command, args []string) {
20+
r, err := api.Request().BillingGetCatalogItemListV1WithResponse(context.TODO(), catalogListRequestParameters(cmd))
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
25+
output.Format(cmd, r.Body, r.StatusCode())
26+
},
27+
}
28+
29+
func init() {
30+
ListCmd.Flags().StringP("category", "", "", "Filter catalog items by category (one of: DOMAIN, VPS)")
31+
ListCmd.Flags().StringP("name", "", "", "Filter catalog items by name. Use * for wildcard search, e.g. .COM* to find .com domain")
32+
}
33+
34+
func catalogListRequestParameters(cmd *cobra.Command) *client.BillingGetCatalogItemListV1Params {
35+
category, _ := cmd.Flags().GetString("category")
36+
name, _ := cmd.Flags().GetString("name")
37+
38+
params := &client.BillingGetCatalogItemListV1Params{
39+
Name: utils.StringPtrOrNil(name),
40+
}
41+
42+
if category != "" {
43+
c := client.BillingGetCatalogItemListV1ParamsCategory(category)
44+
params.Category = &c
45+
}
46+
47+
return params
48+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package payment_methods
2+
3+
import (
4+
"context"
5+
"github.com/hostinger/api-cli/api"
6+
"github.com/hostinger/api-cli/output"
7+
"github.com/hostinger/api-cli/utils"
8+
"github.com/spf13/cobra"
9+
"log"
10+
)
11+
12+
var DeleteCmd = &cobra.Command{
13+
Use: "delete <payment method ID>",
14+
Short: "Delete payment method",
15+
Long: `This endpoint deletes a payment method. Deleted payment methods can no longer be used for placing new orders.`,
16+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().BillingDeletePaymentMethodV1WithResponse(context.TODO(), utils.StringToInt(args[0]))
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
output.Format(cmd, r.Body, r.StatusCode())
24+
},
25+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package payment_methods
2+
3+
import (
4+
"context"
5+
"github.com/hostinger/api-cli/api"
6+
"github.com/hostinger/api-cli/output"
7+
"github.com/spf13/cobra"
8+
"log"
9+
)
10+
11+
var ListCmd = &cobra.Command{
12+
Use: "list",
13+
Short: "Get payment method list",
14+
Long: `This endpoint retrieves a list of available payment methods that can be used for placing new orders.`,
15+
Run: func(cmd *cobra.Command, args []string) {
16+
r, err := api.Request().BillingGetPaymentMethodListV1WithResponse(context.TODO())
17+
if err != nil {
18+
log.Fatal(err)
19+
}
20+
21+
output.Format(cmd, r.Body, r.StatusCode())
22+
},
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package payment_methods
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var GroupCmd = &cobra.Command{
8+
Use: "payment-methods",
9+
Short: "Payment method management",
10+
Long: ``,
11+
}
12+
13+
func init() {
14+
GroupCmd.AddCommand(ListCmd)
15+
GroupCmd.AddCommand(DeleteCmd)
16+
GroupCmd.AddCommand(SetDefaultCmd)
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package payment_methods
2+
3+
import (
4+
"context"
5+
"github.com/hostinger/api-cli/api"
6+
"github.com/hostinger/api-cli/output"
7+
"github.com/hostinger/api-cli/utils"
8+
"github.com/spf13/cobra"
9+
"log"
10+
)
11+
12+
var SetDefaultCmd = &cobra.Command{
13+
Use: "set-default <payment method ID>",
14+
Short: "Set default payment method",
15+
Long: `This endpoint sets a specified payment method as the default. The default payment method is used automatically for new orders.`,
16+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
r, err := api.Request().BillingSetDefaultPaymentMethodV1WithResponse(context.TODO(), utils.StringToInt(args[0]))
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
output.Format(cmd, r.Body, r.StatusCode())
24+
},
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package subscriptions
2+
3+
import (
4+
"context"
5+
"github.com/hostinger/api-cli/api"
6+
"github.com/hostinger/api-cli/output"
7+
"github.com/spf13/cobra"
8+
"log"
9+
)
10+
11+
var DisableAutoRenewalCmd = &cobra.Command{
12+
Use: "disable-auto-renewal <subscription ID>",
13+
Short: "Disable subscription auto-renewal",
14+
Long: `This endpoint disables auto-renewal for a subscription, which stops any further auto-renewal of the associated service.`,
15+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
16+
Run: func(cmd *cobra.Command, args []string) {
17+
r, err := api.Request().BillingDisableAutoRenewalV1WithResponse(context.TODO(), args[0])
18+
if err != nil {
19+
log.Fatal(err)
20+
}
21+
22+
output.Format(cmd, r.Body, r.StatusCode())
23+
},
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package subscriptions
2+
3+
import (
4+
"context"
5+
"github.com/hostinger/api-cli/api"
6+
"github.com/hostinger/api-cli/output"
7+
"github.com/spf13/cobra"
8+
"log"
9+
)
10+
11+
var EnableAutoRenewalCmd = &cobra.Command{
12+
Use: "enable-auto-renewal <subscription ID>",
13+
Short: "Enable subscription auto-renewal",
14+
Long: `This endpoint enables auto-renewal for a subscription, so the associated service is renewed automatically.`,
15+
Args: cobra.MatchAll(cobra.ExactArgs(1)),
16+
Run: func(cmd *cobra.Command, args []string) {
17+
r, err := api.Request().BillingEnableAutoRenewalV1WithResponse(context.TODO(), args[0])
18+
if err != nil {
19+
log.Fatal(err)
20+
}
21+
22+
output.Format(cmd, r.Body, r.StatusCode())
23+
},
24+
}

0 commit comments

Comments
 (0)