Class: PolyLingo::Client
- Inherits:
-
Object
- Object
- PolyLingo::Client
- Defined in:
- lib/polylingo/client.rb
Instance Attribute Summary collapse
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
Instance Method Summary collapse
- #batch(items:, targets:, source: nil, model: nil) ⇒ Object
- #health ⇒ Object
-
#initialize(api_key:, base_url: nil, timeout: 120) ⇒ Client
constructor
A new instance of Client.
- #languages ⇒ Object
- #translate(content:, targets:, format: nil, source: nil, model: nil) ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize(api_key:, base_url: nil, timeout: 120) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/polylingo/client.rb', line 10 def initialize(api_key:, base_url: nil, timeout: 120) if api_key.nil? || api_key.to_s.empty? raise ArgumentError, "PolyLingo: api_key is required" end @api_key = api_key resolved_base = base_url.nil? || base_url.to_s.empty? ? HttpClient::DEFAULT_BASE_URL : base_url @http = HttpClient.new( api_key: @api_key, base_url: resolved_base.chomp("/"), timeout: timeout ) @jobs = Resources::Jobs.new(@http) end |
Instance Attribute Details
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
5 6 7 |
# File 'lib/polylingo/client.rb', line 5 def jobs @jobs end |
Instance Method Details
#batch(items:, targets:, source: nil, model: nil) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/polylingo/client.rb', line 48 def batch(items:, targets:, source: nil, model: nil) Resources::Batch.call( @http, items: items, targets: targets, source: source, model: model ) end |
#health ⇒ Object
25 26 27 |
# File 'lib/polylingo/client.rb', line 25 def health Resources::Health.call(@http) end |
#languages ⇒ Object
29 30 31 |
# File 'lib/polylingo/client.rb', line 29 def languages Resources::Languages.call(@http) end |
#translate(content:, targets:, format: nil, source: nil, model: nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/polylingo/client.rb', line 37 def translate(content:, targets:, format: nil, source: nil, model: nil) Resources::Translate.call( @http, content: content, targets: targets, format: format, source: source, model: model ) end |