This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
e621-sdk-go/pkg/e621/builder/db_export_file.go
SoXX 9cee99ecb5 docs: added more & unified documentation format
Signed-off-by: SoXX <soxx@fenpa.ws>
2023-11-15 14:37:44 +01:00

55 lines
1.9 KiB
Go

package builder
import (
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
)
// DBExportFileBuilder defines an interface for building and executing requests to retrieve a specific exported database file.
type DBExportFileBuilder interface {
// SetFile sets the name of the file to be retrieved.
SetFile(fileName string) DBExportFileBuilder
// Execute sends the request and returns the content of the exported database file or an error if the request fails.
Execute() ([]byte, error)
}
// NewGetDBExportFileBuilder creates a new instance of DBExportFileBuilder.
//
// Parameters:
// - requestContext: The context for the API request, including the host, user agent, username, and API key.
//
// Returns:
// - DBExportFileBuilder: An instance of the DBExportFileBuilder interface.
func NewGetDBExportFileBuilder(requestContext model.RequestContext) DBExportFileBuilder {
return &getDBExportFile{
requestContext: requestContext,
}
}
// getDBExportFile is an implementation of the DBExportFileBuilder interface.
type getDBExportFile struct {
requestContext model.RequestContext
fileName string
}
// SetFile sets the name of the file to be retrieved.
//
// Parameters:
// - fileName: The name of the exported database file.
//
// Returns:
// - DBExportFileBuilder: The instance of the DBExportFileBuilder for method chaining.
func (g *getDBExportFile) SetFile(fileName string) DBExportFileBuilder {
g.fileName = fileName
return g
}
// Execute sends the API request to retrieve the content of a specific exported database file.
//
// Returns:
// - []byte: The content of the exported database file.
// - error: An error, if any, encountered during the API request or response handling.
func (g *getDBExportFile) Execute() ([]byte, error) {
return endpoints.GetDBExportFile(g.requestContext, g.fileName)
}