Skip to content

Commit

Permalink
Support updating service location in appointments
Browse files Browse the repository at this point in the history
  • Loading branch information
gffking committed Aug 14, 2024
1 parent 53c847a commit e80c5aa
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions appointment.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type AppointmentUpdate struct {
Duration *int `json:"duration,omitempty"`
Instructions *string `json:"instructions,omitempty"`
Mode *string `json:"mode,omitempty"`
ServiceLocation *int `json:"service_location,omitempty"`
Status *AppointmentUpdateStatus `json:"status,omitempty"`
TelehealthDetails *string `json:"telehealth_details,omitempty"`
}
Expand Down
71 changes: 71 additions & 0 deletions cli/cmd/scheduling.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cmd

import (
"context"
"encoding/json"
"fmt"
"io"
"os"
"strconv"

"github.com/authorhealth/go-elation"
"github.com/spf13/cobra"
)

var getAppointment = &cobra.Command{
Use: "get-appointment [appointment ID]",
Args: cobra.ExactArgs(1),
Run: wrapRunFunc(func(ctx context.Context, client elation.Client, args []string) error {
appointmentID, _ := strconv.ParseInt(args[0], 10, 64)
response, _, err := client.Appointments().Get(ctx, appointmentID)
if err != nil {
return err
}

responseJson, err := json.Marshal(response)
if err != nil {
return err
}

_, err = fmt.Fprintln(os.Stdout, string(responseJson))

return err
}),
}

var updateAppointment = &cobra.Command{
Use: "update-appointment [appointment ID]",
Args: cobra.ExactArgs(1),
Run: wrapRunFunc(func(ctx context.Context, client elation.Client, args []string) error {
appointmentID, _ := strconv.ParseInt(args[0], 10, 64)
requestBytes, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}

request := &elation.AppointmentUpdate{}
err = json.Unmarshal(requestBytes, request)
if err != nil {
return err
}

response, _, err := client.Appointments().Update(ctx, appointmentID, request)
if err != nil {
return err
}

responseJson, err := json.Marshal(response)
if err != nil {
return err
}

_, err = fmt.Fprintln(os.Stdout, string(responseJson))

return err
}),
}

func init() {
rootCmd.AddCommand(getAppointment)
rootCmd.AddCommand(updateAppointment)
}

0 comments on commit e80c5aa

Please sign in to comment.