Class: TranslationDiff::HTTPProvider
- Inherits:
-
Provider
- Object
- Provider
- TranslationDiff::HTTPProvider
show all
- Defined in:
- lib/translation_diff/http_provider.rb
Overview
Every HTTP provider inherits this; no logging middleware, ever -- lines must carry no source text or credential.
Constant Summary
collapse
- RETRY_STATUSES =
[429, 500, 502, 503, 504].freeze
- TRANSPORT_FAILURES =
Faraday raises these when nobody answered, as opposed to answering "no".
[Faraday::ConnectionFailed, Faraday::TimeoutError, Faraday::SSLError].freeze
Instance Method Summary
collapse
Instance Method Details
#api_base ⇒ Object
12
|
# File 'lib/translation_diff/http_provider.rb', line 12
def api_base = raise NotImplementedError, "#{self.class} must implement #api_base"
|
#connection ⇒ Object
30
|
# File 'lib/translation_diff/http_provider.rb', line 30
def connection = @connection ||= build_connection
|
13
|
# File 'lib/translation_diff/http_provider.rb', line 13
def = {}
|
#parse_translate_response(_body, _headers, _request) ⇒ Object
21
22
23
|
# File 'lib/translation_diff/http_provider.rb', line 21
def parse_translate_response(_body, , _request)
raise NotImplementedError, "#{self.class} must implement #parse_translate_response"
end
|
#render_translate_payload(_request) ⇒ Object
17
18
19
|
# File 'lib/translation_diff/http_provider.rb', line 17
def render_translate_payload(_request)
raise NotImplementedError, "#{self.class} must implement #render_translate_payload"
end
|
#translate(request) ⇒ Object
25
26
27
28
|
# File 'lib/translation_diff/http_provider.rb', line 25
def translate(request)
response = post(translate_url, render_translate_payload(request))
parse_translate_response(response.body, response., request)
end
|
#translate_url ⇒ Object
15
|
# File 'lib/translation_diff/http_provider.rb', line 15
def translate_url = raise NotImplementedError, "#{self.class} must implement #translate_url"
|