deepl

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FreeHost   = "https://api-free.deepl.com"
	ProHost    = "https://api.deepl.com"
	APIVersion = "v2"

	AccountPlanIdentificationKey = ":fx"
)

Variables

This section is empty.

Functions

func HandleHTTPError

func HandleHTTPError(resp *http.Response) error

Types

type Client

type Client struct {
	BaseURL    *url.URL
	HTTPClient *http.Client
	AuthKey    string
}

func NewClient

func NewClient(authKey string) *Client

func (*Client) Do added in v0.4.0

func (c *Client) Do(req *http.Request, v interface{}) error

func (*Client) NewRequest added in v0.4.0

func (c *Client) NewRequest(method, _path string, body io.Reader) (*http.Request, error)

func (*Client) TranslateText added in v0.4.0

func (c *Client) TranslateText(text, sourceLang, targetLang string) (*model.TranslateText, error)

type HTTPError

type HTTPError struct {
	RequestURL string
	Message    string
	StatusCode int
}

func (HTTPError) Error

func (err HTTPError) Error() string

type TranslationResponse added in v0.4.0

type TranslationResponse struct {
	Translations []struct {
		DetectedSourceLanguage string `json:"detected_source_language"`
		Text                   string `json:"text"`
	} `json:"translations"`
}

Jump to

Keyboard shortcuts

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