// Code generated by op-codegen - DO NOT EDIT

package onepassword

import (
	"context"
	"encoding/json"

	"github.com/1password/onepassword-sdk-go/internal"
)

// The Vaults API holds all the operations the SDK client can perform on 1Password vaults.
type VaultsAPI interface {
	// List all vaults
	List(ctx context.Context) ([]VaultOverview, error)
}

type VaultsSource struct {
	internal.InnerClient
}

func NewVaultsSource(inner internal.InnerClient) VaultsAPI {
	return &VaultsSource{InnerClient: inner}
}

// List all vaults
func (v VaultsSource) List(ctx context.Context) ([]VaultOverview, error) {
	resultString, err := clientInvoke(ctx, v.InnerClient, "VaultsList", map[string]interface{}{})
	if err != nil {
		return nil, err
	}
	var result []VaultOverview
	err = json.Unmarshal([]byte(*resultString), &result)
	if err != nil {
		return nil, err
	}
	return result, nil
}
