@@ -6,17 +6,27 @@ package supporttickets
66
77import (
88 _ "embed"
9+ "fmt"
10+ "net/url"
911
12+ "github.com/ovh/ovhcloud-cli/internal/display"
1013 "github.com/ovh/ovhcloud-cli/internal/flags"
14+ httpLib "github.com/ovh/ovhcloud-cli/internal/http"
1115 "github.com/ovh/ovhcloud-cli/internal/services/common"
1216 "github.com/spf13/cobra"
1317)
1418
1519var (
1620 supportticketsColumnsToDisplay = []string {"ticketId" , "serviceName" , "type" , "category" , "state" }
21+ messagesColumnsToDisplay = []string {"messageId" , "from" , "creationDate" , "body" }
1722
1823 //go:embed templates/supporttickets.tmpl
1924 supportticketsTemplate string
25+
26+ // ReplySpec holds the parameters for the reply command.
27+ ReplySpec struct {
28+ Body string `json:"body,omitempty"`
29+ }
2030)
2131
2232func ListSupportTickets (_ * cobra.Command , _ []string ) {
@@ -26,3 +36,19 @@ func ListSupportTickets(_ *cobra.Command, _ []string) {
2636func GetSupportTickets (_ * cobra.Command , args []string ) {
2737 common .ManageObjectRequest ("/v1/support/tickets" , args [0 ], supportticketsTemplate )
2838}
39+
40+ func ListSupportTicketMessages (_ * cobra.Command , args []string ) {
41+ endpoint := fmt .Sprintf ("/v1/support/tickets/%s/messages" , url .PathEscape (args [0 ]))
42+ common .ManageListRequestNoExpand (endpoint , messagesColumnsToDisplay , flags .GenericFilters )
43+ }
44+
45+ func ReplySupportTicket (_ * cobra.Command , args []string ) {
46+ endpoint := fmt .Sprintf ("/v1/support/tickets/%s/reply" , url .PathEscape (args [0 ]))
47+
48+ if err := httpLib .Client .Post (endpoint , ReplySpec , nil ); err != nil {
49+ display .OutputError (& flags .OutputFormatConfig , "failed to reply to ticket: %s" , err )
50+ return
51+ }
52+
53+ display .OutputInfo (& flags .OutputFormatConfig , nil , "✅ Reply sent successfully" )
54+ }
0 commit comments