Documentation
¶
Overview ¶
Package client implements the Translaas SDK HTTP client matching .NET TranslaasClient.
Package client implements the Translaas SDK HTTP client matching .NET TranslaasClient.
Index ¶
Constants ¶
const ( // DefaultTimeout is applied when Options.Timeout is zero. DefaultTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
GetEntry(ctx context.Context, group, entry, lang string, opts ...GetEntryOption) (string, error)
GetGroup(ctx context.Context, project, group, lang string, opts ...GetGroupOption) (*models.TranslationGroup, error)
GetProject(ctx context.Context, project, lang string, opts ...GetProjectOption) (*models.TranslationProject, error)
GetProjectLocales(ctx context.Context, project string, opts ...GetProjectLocalesOption) (*models.ProjectLocales, error)
GetOfflineCache(ctx context.Context, project string, opts ...GetOfflineCacheOption) (*models.OfflineCacheDownloadResult, error)
ReportMissingKeys(ctx context.Context, keys []models.ReportMissingKeyItem) error
ValidateAPIKey(ctx context.Context) (*models.ValidateAPIKeyResponse, error)
}
Client is the consumer-facing HTTP client boundary.
type GetEntryCallOptions ¶
type GetEntryCallOptions struct {
Number *float64
Parameters map[string]string
RequestContext *models.RequestContext
}
GetEntryCallOptions holds parsed GetEntry call options for decorators.
func ParseGetEntryOptions ¶
func ParseGetEntryOptions(opts ...GetEntryOption) GetEntryCallOptions
ParseGetEntryOptions parses GetEntry options for use by decorators.
type GetEntryOption ¶
type GetEntryOption func(*getEntryConfig)
GetEntryOption configures a single GetEntry call.
func WithNumber ¶
func WithNumber(n float64) GetEntryOption
WithNumber sets the plural/interpolation count (merged as query key N).
func WithParameters ¶
func WithParameters(params map[string]string) GetEntryOption
WithParameters adds interpolation query parameters merged after the request DTO.
func WithRequestContext ¶
func WithRequestContext(rc *models.RequestContext) GetEntryOption
WithRequestContext supplies per-request channel, version, project, and conditional headers.
type GetGroupOption ¶
type GetGroupOption func(*getGroupConfig)
GetGroupOption configures a single GetGroup call.
func WithGroupFormat ¶
func WithGroupFormat(format string) GetGroupOption
WithGroupFormat sets the response format query parameter (for example "flat-json").
func WithGroupRequestContext ¶
func WithGroupRequestContext(rc *models.RequestContext) GetGroupOption
WithGroupRequestContext supplies per-request channel, version, includeContext, and conditional headers.
type GetOfflineCacheOption ¶
type GetOfflineCacheOption func(*getOfflineCacheConfig)
GetOfflineCacheOption configures a single GetOfflineCache call.
func WithOfflineCacheRequestContext ¶
func WithOfflineCacheRequestContext(rc *models.RequestContext) GetOfflineCacheOption
WithOfflineCacheRequestContext supplies per-request channel, version, includeContext, and conditional headers.
type GetProjectLocalesOption ¶
type GetProjectLocalesOption func(*getProjectLocalesConfig)
GetProjectLocalesOption configures a single GetProjectLocales call.
func WithLocalesRequestContext ¶
func WithLocalesRequestContext(rc *models.RequestContext) GetProjectLocalesOption
WithLocalesRequestContext supplies per-request channel, version, and conditional headers.
type GetProjectOption ¶
type GetProjectOption func(*getProjectConfig)
GetProjectOption configures a single GetProject call.
func WithProjectFormat ¶
func WithProjectFormat(format string) GetProjectOption
WithProjectFormat sets the response format query parameter (for example "flat-json").
func WithProjectRequestContext ¶
func WithProjectRequestContext(rc *models.RequestContext) GetProjectOption
WithProjectRequestContext supplies per-request channel, version, includeContext, and conditional headers.
type Option ¶
type Option func(*clientConfig)
Option configures client construction.
func WithCacheMode ¶
WithCacheMode overrides Options.CacheMode.
func WithCacheProvider ¶
WithCacheProvider supplies a custom in-memory cache provider (primarily for tests).
func WithCacheTTL ¶
WithCacheTTL overrides Options.CacheTTL.
func WithHTTPClient ¶
WithHTTPClient supplies a custom HTTP client (primarily for tests).