Skip to content

Commit e80c5aa

Browse files
committed
Support updating service location in appointments
1 parent 53c847a commit e80c5aa

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

appointment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ type AppointmentUpdate struct {
172172
Duration *int `json:"duration,omitempty"`
173173
Instructions *string `json:"instructions,omitempty"`
174174
Mode *string `json:"mode,omitempty"`
175+
ServiceLocation *int `json:"service_location,omitempty"`
175176
Status *AppointmentUpdateStatus `json:"status,omitempty"`
176177
TelehealthDetails *string `json:"telehealth_details,omitempty"`
177178
}

cli/cmd/scheduling.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package cmd
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"fmt"
7+
"io"
8+
"os"
9+
"strconv"
10+
11+
"github.com/authorhealth/go-elation"
12+
"github.com/spf13/cobra"
13+
)
14+
15+
var getAppointment = &cobra.Command{
16+
Use: "get-appointment [appointment ID]",
17+
Args: cobra.ExactArgs(1),
18+
Run: wrapRunFunc(func(ctx context.Context, client elation.Client, args []string) error {
19+
appointmentID, _ := strconv.ParseInt(args[0], 10, 64)
20+
response, _, err := client.Appointments().Get(ctx, appointmentID)
21+
if err != nil {
22+
return err
23+
}
24+
25+
responseJson, err := json.Marshal(response)
26+
if err != nil {
27+
return err
28+
}
29+
30+
_, err = fmt.Fprintln(os.Stdout, string(responseJson))
31+
32+
return err
33+
}),
34+
}
35+
36+
var updateAppointment = &cobra.Command{
37+
Use: "update-appointment [appointment ID]",
38+
Args: cobra.ExactArgs(1),
39+
Run: wrapRunFunc(func(ctx context.Context, client elation.Client, args []string) error {
40+
appointmentID, _ := strconv.ParseInt(args[0], 10, 64)
41+
requestBytes, err := io.ReadAll(os.Stdin)
42+
if err != nil {
43+
return err
44+
}
45+
46+
request := &elation.AppointmentUpdate{}
47+
err = json.Unmarshal(requestBytes, request)
48+
if err != nil {
49+
return err
50+
}
51+
52+
response, _, err := client.Appointments().Update(ctx, appointmentID, request)
53+
if err != nil {
54+
return err
55+
}
56+
57+
responseJson, err := json.Marshal(response)
58+
if err != nil {
59+
return err
60+
}
61+
62+
_, err = fmt.Fprintln(os.Stdout, string(responseJson))
63+
64+
return err
65+
}),
66+
}
67+
68+
func init() {
69+
rootCmd.AddCommand(getAppointment)
70+
rootCmd.AddCommand(updateAppointment)
71+
}

0 commit comments

Comments
 (0)