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

package onepassword

import (
	"context"
	"encoding/json"

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

// The Groups API holds all the operations the SDK client can perform on 1Password groups.
type GroupsAPI interface {
	// Get a group by its ID and parameters.
	Get(ctx context.Context, groupID string, groupParams GroupGetParams) (Group, error)
}

type GroupsSource struct {
	*internal.InnerClient
}

func NewGroupsSource(inner *internal.InnerClient) GroupsAPI {
	return &GroupsSource{InnerClient: inner}
}

// Get a group by its ID and parameters.
func (g GroupsSource) Get(ctx context.Context, groupID string, groupParams GroupGetParams) (Group, error) {
	resultString, err := clientInvoke(ctx, g.InnerClient, "GroupsGet", map[string]interface{}{
		"group_id":     groupID,
		"group_params": groupParams,
	})
	if err != nil {
		return Group{}, err
	}
	var result Group
	err = json.Unmarshal([]byte(*resultString), &result)
	if err != nil {
		return Group{}, err
	}
	return result, nil
}
