Class: DeeplRequest
- Inherits:
-
Object
- Object
- DeeplRequest
- Defined in:
- lib/deepl_srt/deepl_request.rb
Overview
Class to send request to DeepL API
Instance Method Summary collapse
-
#initialize(api_key) ⇒ DeeplRequest
constructor
A new instance of DeeplRequest.
- #request(target_lang, text) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ DeeplRequest
Returns a new instance of DeeplRequest.
9 10 11 12 |
# File 'lib/deepl_srt/deepl_request.rb', line 9 def initialize(api_key) @uri = URI('https://api-free.deepl.com/v2/translate') @api_key = api_key end |
Instance Method Details
#request(target_lang, text) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/deepl_srt/deepl_request.rb', line 14 def request(target_lang, text) Net::HTTP.post_form(@uri, 'auth_key' => @api_key, 'text' => text, 'target_lang' => target_lang, 'preserve_formatting' => 1) end |