forms

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFormsHandlerDeps = common.NewDefaultHandlerDeps(NewFormsService)

DefaultFormsHandlerDeps holds the default dependencies for production use.

Functions

func InitDefaultFormsHandlerDeps added in v0.1.7

func InitDefaultFormsHandlerDeps(appDeps *common.Deps)

InitDefaultFormsHandlerDeps initializes the default Forms handler deps with explicit deps.

func RegisterTools

func RegisterTools(s *server.MCPServer)

RegisterTools registers all Forms tools with the MCP server.

func TestableFormsBatchUpdate

func TestableFormsBatchUpdate(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)

TestableFormsBatchUpdate performs a batch update on a form.

func TestableFormsCreate

func TestableFormsCreate(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)

TestableFormsCreate creates a new form.

func TestableFormsGet

func TestableFormsGet(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)

TestableFormsGet retrieves a form's metadata, items, and structure.

func TestableFormsGetResponse

func TestableFormsGetResponse(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)

TestableFormsGetResponse retrieves a single form response by ID.

func TestableFormsListResponses

func TestableFormsListResponses(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (*mcp.CallToolResult, error)

TestableFormsListResponses lists all responses for a form.

Types

type FormsHandlerDeps

type FormsHandlerDeps = common.HandlerDeps[FormsService]

Type alias using generic types from common package.

type FormsService

type FormsService interface {
	// GetForm retrieves a form by ID.
	GetForm(ctx context.Context, formID string) (*forms.Form, error)

	// CreateForm creates a new form with the given title.
	CreateForm(ctx context.Context, title string) (*forms.Form, error)

	// BatchUpdate performs a batch update on a form.
	BatchUpdate(ctx context.Context, formID string, requests []*forms.Request) (*forms.BatchUpdateFormResponse, error)

	// ListResponses lists responses for a form.
	ListResponses(ctx context.Context, formID string) ([]*forms.FormResponse, error)

	// GetResponse retrieves a single form response by ID.
	GetResponse(ctx context.Context, formID string, responseID string) (*forms.FormResponse, error)
}

FormsService defines the interface for Google Forms API operations. This interface enables dependency injection and testing with mocks.

func NewFormsService

func NewFormsService(ctx context.Context, client *http.Client) (FormsService, error)

NewFormsService creates a FormsService from an authenticated HTTP client.

func ResolveFormsServiceOrError

func ResolveFormsServiceOrError(ctx context.Context, request mcp.CallToolRequest, deps *FormsHandlerDeps) (FormsService, *mcp.CallToolResult, bool)

ResolveFormsServiceOrError resolves a Forms service, returning an MCP error result on failure.

type FormsTestFixtures

type FormsTestFixtures struct {
	DefaultEmail string
	MockService  *MockFormsService
	Deps         *FormsHandlerDeps
}

FormsTestFixtures contains test fixtures for Forms tool testing.

func NewFormsTestFixtures

func NewFormsTestFixtures() *FormsTestFixtures

NewFormsTestFixtures creates a new set of test fixtures.

type MockFormsService

type MockFormsService struct {
	// Forms stores mock form data keyed by ID.
	Forms map[string]*forms.Form

	// Responses stores mock response data keyed by form ID.
	Responses map[string][]*forms.FormResponse

	// Errors allows tests to configure specific errors for methods.
	Errors struct {
		GetForm       error
		Create        error
		BatchUpdate   error
		ListResponses error
		GetResponse   error
	}

	// Calls tracks method invocations for verification.
	Calls struct {
		GetForm     []string
		Create      []string
		BatchUpdate []struct {
			FormID   string
			Requests []*forms.Request
		}
		ListResponses []string
		GetResponse   []struct{ FormID, ResponseID string }
	}
}

MockFormsService implements FormsService for testing.

func NewMockFormsService

func NewMockFormsService() *MockFormsService

NewMockFormsService creates a new mock Forms service with default test data.

func (*MockFormsService) BatchUpdate

func (m *MockFormsService) BatchUpdate(ctx context.Context, formID string, requests []*forms.Request) (*forms.BatchUpdateFormResponse, error)

BatchUpdate performs a mock batch update.

func (*MockFormsService) CreateForm

func (m *MockFormsService) CreateForm(ctx context.Context, title string) (*forms.Form, error)

CreateForm creates a mock form.

func (*MockFormsService) GetForm

func (m *MockFormsService) GetForm(ctx context.Context, formID string) (*forms.Form, error)

GetForm retrieves a mock form by ID.

func (*MockFormsService) GetResponse

func (m *MockFormsService) GetResponse(ctx context.Context, formID string, responseID string) (*forms.FormResponse, error)

GetResponse retrieves a mock form response by ID.

func (*MockFormsService) ListResponses

func (m *MockFormsService) ListResponses(ctx context.Context, formID string) ([]*forms.FormResponse, error)

ListResponses lists mock responses for a form.

type RealFormsService

type RealFormsService struct {
	// contains filtered or unexported fields
}

RealFormsService wraps the Forms API client and implements FormsService.

func NewRealFormsService

func NewRealFormsService(service *forms.Service) *RealFormsService

NewRealFormsService creates a new RealFormsService wrapping the given API service.

func (*RealFormsService) BatchUpdate

func (s *RealFormsService) BatchUpdate(ctx context.Context, formID string, requests []*forms.Request) (*forms.BatchUpdateFormResponse, error)

BatchUpdate performs a batch update on a form.

func (*RealFormsService) CreateForm

func (s *RealFormsService) CreateForm(ctx context.Context, title string) (*forms.Form, error)

CreateForm creates a new form with the given title.

func (*RealFormsService) GetForm

func (s *RealFormsService) GetForm(ctx context.Context, formID string) (*forms.Form, error)

GetForm retrieves a form by ID.

func (*RealFormsService) GetResponse

func (s *RealFormsService) GetResponse(ctx context.Context, formID string, responseID string) (*forms.FormResponse, error)

GetResponse retrieves a single form response by ID.

func (*RealFormsService) ListResponses

func (s *RealFormsService) ListResponses(ctx context.Context, formID string) ([]*forms.FormResponse, error)

ListResponses lists responses for a form (up to maxResponsePages pages).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL