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

package onepassword

import (
	"context"
	"encoding/json"

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

// The Environments API holds all the operations the SDK client can perform on 1Password Environments.
type EnvironmentsAPI interface {
	// Get environment variables belonging to an Environment.
	GetVariables(ctx context.Context, environmentID string) (GetVariablesResponse, error)
}

type EnvironmentsSource struct {
	*internal.InnerClient
}

func NewEnvironmentsSource(inner *internal.InnerClient) EnvironmentsAPI {
	return &EnvironmentsSource{InnerClient: inner}
}

// Get environment variables belonging to an Environment.
func (e EnvironmentsSource) GetVariables(ctx context.Context, environmentID string) (GetVariablesResponse, error) {
	resultString, err := clientInvoke(ctx, e.InnerClient, "EnvironmentsGetVariables", map[string]interface{}{
		"environment_id": environmentID,
	})
	if err != nil {
		return GetVariablesResponse{}, err
	}
	var result GetVariablesResponse
	err = json.Unmarshal([]byte(*resultString), &result)
	if err != nil {
		return GetVariablesResponse{}, err
	}
	return result, nil
}
