Documentation
¶
Index ¶
- Variables
- func NewDefaultLogger() *defaultLogger
- type APIError
- type Client
- func (c *Client) CreateGlossary(ctx context.Context, req models.CreateGlossaryRequest) (*models.CreateGlossaryResponse, error)
- func (c *Client) DeleteAllLangDictionaries(ctx context.Context, id string, query models.GlossaryLangPair) error
- func (c *Client) DeleteGlossary(ctx context.Context, id string) error
- func (c *Client) EditGlossary(ctx context.Context, id string, req models.EditGlossaryRequest) (*models.Glossary, error)
- func (c *Client) GetGlossaryByID(ctx context.Context, id string) (*models.Glossary, error)
- func (c *Client) GetGlossaryEntries(ctx context.Context, id string, query models.GlossaryLangPair) (*models.GlossaryEntriesResponse, error)
- func (c *Client) GetLanguages(ctx context.Context) ([]models.SupportedLanguage, error)
- func (c *Client) GetUsageAndLimits(ctx context.Context) (*models.UsageAndLimitResponse, error)
- func (c *Client) ImproveText(ctx context.Context, req models.RephraseRequest) (string, error)
- func (c *Client) ListAllGlossaries(ctx context.Context) (*models.AllGlossaryListResponse, error)
- func (c *Client) ListLangPairsSupportedByGlossaries(ctx context.Context) (*models.GlossaryListResponse, error)
- func (c *Client) ReplaceOrCreateDictionaryInGlossary(ctx context.Context, id string, req models.Dictionary) (*models.EditOrCreateDictionaryInGlossaryResponse, error)
- func (c *Client) Translate(ctx context.Context, request models.TranslationRequest) ([]string, error)
- func (c *Client) TranslateFile(ctx context.Context, req models.FileTranslationRequest, targetDir string) (string, error)
- type ClientOption
- type Config
- type Logger
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadRequest = &APIError{StatusCode: 400, Message: "Bad Request"} ErrInvalidAuth = &APIError{StatusCode: 401, Message: "Authentication failed"} ErrForbidden = &APIError{StatusCode: 403, Message: "Forbidden. Insufficient access rights."} ErrNotFound = &APIError{StatusCode: 404, Message: "The requested resource could not be found"} ErrRateLimit = &APIError{StatusCode: 413, Message: "Rate limit exceeded"} ErrHeader = &APIError{StatusCode: 415, Message: "The requested entries format specified in \"Accept\" is not supported."} Err429TooMany = &APIError{StatusCode: 429, Message: "Too many requests. Please wait and resend request"} ErrQuotaExceeded = &APIError{StatusCode: 456, Message: "Quota exceeded"} ErrInternal = &APIError{StatusCode: 500, Message: "Internal error"} Err529TooMany = &APIError{StatusCode: 529, Message: "Too many requests. Please wait and resend request"} )
Common error types for more specific handling
Functions ¶
func NewDefaultLogger ¶
func NewDefaultLogger() *defaultLogger
NewDefaultLogger Initialize the logger field with default values
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(apiKey string, isPro bool, opts ...ClientOption) *Client
NewClient creates a new DeepL API client for v2 API
func NewClientV3 ¶
func NewClientV3(apiKey string, isPro bool, opts ...ClientOption) *Client
NewClientV3 creates a new DeepL API client for v3 API
func (*Client) CreateGlossary ¶
func (c *Client) CreateGlossary(ctx context.Context, req models.CreateGlossaryRequest) (*models.CreateGlossaryResponse, error)
CreateGlossary creates a new glossary and returns info about it. Note: Use V3 client for this endpoint.
func (*Client) DeleteAllLangDictionaries ¶
func (c *Client) DeleteAllLangDictionaries(ctx context.Context, id string, query models.GlossaryLangPair) error
DeleteAllLangDictionaries deletes the dictionary associated with the given language pair with the given glossary ID. Note: Use V3 client for this endpoint.
func (*Client) DeleteGlossary ¶
DeleteGlossary deletes the specified glossary. Note: Use V3 client for this endpoint.
func (*Client) EditGlossary ¶
func (c *Client) EditGlossary(ctx context.Context, id string, req models.EditGlossaryRequest) (*models.Glossary, error)
EditGlossary edits glossary details, such as name or a dictionary for a source and target language. Note: Use V3 client for this endpoint.
func (*Client) GetGlossaryByID ¶
GetGlossaryByID retrieves meta information for a single glossary, omitting the glossary entries. Note: Use V3 client for this endpoint.
func (*Client) GetGlossaryEntries ¶
func (c *Client) GetGlossaryEntries(ctx context.Context, id string, query models.GlossaryLangPair) (*models.GlossaryEntriesResponse, error)
GetGlossaryEntries lists the entries of a single glossary in tsv format. Note: Use V3 client for this endpoint.
func (*Client) GetLanguages ¶
GetLanguages returns struct with all supported languages
func (*Client) GetUsageAndLimits ¶
GetUsageAndLimits returns characters translated in the current billing period and current maximum number of characters that can be translated per billing period.
func (*Client) ImproveText ¶
ImproveText improves a text using the DeepL API
func (*Client) ListAllGlossaries ¶
ListAllGlossaries returns all glossaries and their meta-information, but not the glossary entries. Note: Use V3 client for this endpoint.
func (*Client) ListLangPairsSupportedByGlossaries ¶
func (c *Client) ListLangPairsSupportedByGlossaries(ctx context.Context) (*models.GlossaryListResponse, error)
ListLangPairsSupportedByGlossaries retrieves the list of language pairs supported by the glossary feature.
func (*Client) ReplaceOrCreateDictionaryInGlossary ¶
func (c *Client) ReplaceOrCreateDictionaryInGlossary(ctx context.Context, id string, req models.Dictionary) (*models.EditOrCreateDictionaryInGlossaryResponse, error)
ReplaceOrCreateDictionaryInGlossary replaces or creates a dictionary in the glossary with the specified entries. Note: Use V3 client for this endpoint.
func (*Client) Translate ¶
func (c *Client) Translate(ctx context.Context, request models.TranslationRequest) ([]string, error)
Translate text using the DeepL API
func (*Client) TranslateFile ¶
func (c *Client) TranslateFile(ctx context.Context, req models.FileTranslationRequest, targetDir string) (string, error)
TranslateFile uploads a file for translation and monitors progress
type ClientOption ¶
type ClientOption func(*Client)
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom timeout for the HTTP client