package digitalcredentials

import (
	"fmt"
	"strings"
)

// Code generated by cdproto-gen. DO NOT EDIT.

// VirtualWalletAction the type of virtual wallet action.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DigitalCredentials#type-VirtualWalletAction
type VirtualWalletAction string

// String returns the VirtualWalletAction as string value.
func (t VirtualWalletAction) String() string {
	return string(t)
}

// VirtualWalletAction values.
const (
	VirtualWalletActionRespond VirtualWalletAction = "respond"
	VirtualWalletActionDecline VirtualWalletAction = "decline"
	VirtualWalletActionWait    VirtualWalletAction = "wait"
	VirtualWalletActionClear   VirtualWalletAction = "clear"
)

// UnmarshalJSON satisfies [json.Unmarshaler].
func (t *VirtualWalletAction) UnmarshalJSON(buf []byte) error {
	s := string(buf)
	s = strings.TrimSuffix(strings.TrimPrefix(s, `"`), `"`)

	switch VirtualWalletAction(s) {
	case VirtualWalletActionRespond:
		*t = VirtualWalletActionRespond
	case VirtualWalletActionDecline:
		*t = VirtualWalletActionDecline
	case VirtualWalletActionWait:
		*t = VirtualWalletActionWait
	case VirtualWalletActionClear:
		*t = VirtualWalletActionClear
	default:
		return fmt.Errorf("unknown VirtualWalletAction value: %v", s)
	}
	return nil
}
