Skip to content

Commit

Permalink
feat: support official api
Browse files Browse the repository at this point in the history
  • Loading branch information
missuo committed Mar 20, 2024
1 parent 9fff35f commit dedd87c
Show file tree
Hide file tree
Showing 3 changed files with 293 additions and 218 deletions.
74 changes: 74 additions & 0 deletions dto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package main

type Config struct {
Port int
Token string
AuthKey string
}

type Lang struct {
SourceLangUserSelected string `json:"source_lang_user_selected"`
TargetLang string `json:"target_lang"`
}

type CommonJobParams struct {
WasSpoken bool `json:"wasSpoken"`
TranscribeAS string `json:"transcribe_as"`
// RegionalVariant string `json:"regionalVariant"`
}

type Params struct {
Texts []Text `json:"texts"`
Splitting string `json:"splitting"`
Lang Lang `json:"lang"`
Timestamp int64 `json:"timestamp"`
CommonJobParams CommonJobParams `json:"commonJobParams"`
}

type Text struct {
Text string `json:"text"`
RequestAlternatives int `json:"requestAlternatives"`
}

type PostData struct {
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
ID int64 `json:"id"`
Params Params `json:"params"`
}

type PayloadFree struct {
TransText string `json:"text"`
SourceLang string `json:"source_lang"`
TargetLang string `json:"target_lang"`
}

type PayloadAPI struct {
Text []string `json:"text"`
TargetLang string `json:"target_lang"`
SourceLang string `json:"source_lang"`
}

type Translation struct {
Text string `json:"text"`
}

type TranslationResponse struct {
Translations []Translation `json:"translations"`
}

type DeepLUsageResponse struct {
CharacterCount int `json:"character_count"`
CharacterLimit int `json:"character_limit"`
}

type DeepLXTranslationResult struct {
Code int
ID int64
Message string
Data string
Alternatives []string
SourceLang string
TargetLang string
Method string
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/OwO-Network/DeepLX

go 1.19
go 1.22.1

require (
github.com/abadojack/whatlanggo v1.0.1
Expand Down
Loading

0 comments on commit dedd87c

Please sign in to comment.