Class: Unbabel::Client
- Inherits:
-
Object
- Object
- Unbabel::Client
- Includes:
- LanguangePair, Tone, Topic, Translation
- Defined in:
- lib/unbabel/client.rb
Constant Summary collapse
- TEST_MODE =
ENV['UNBABEL_SANDBOX'] == 'true'
- SANDBOX =
'http://sandbox.unbabel.com/tapi/v2'- ENDPOINT =
TEST_MODE ? SANDBOX : 'https://unbabel.com/tapi/v2'
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #credentials ⇒ Object
- #credentials? ⇒ Boolean
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
Methods included from Translation
#find, #request_translation, #translations
Methods included from Tone
Methods included from Topic
Methods included from LanguangePair
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 23 |
# File 'lib/unbabel/client.rb', line 15 def initialize( = {}) @username = [:username] @token = [:token] yield(self) if block_given? validate_credentials! Unirest.default_header('Content-Type', 'application/json') Unirest.default_header('Authorization', "ApiKey #{@username}:#{@token}") end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
12 13 14 |
# File 'lib/unbabel/client.rb', line 12 def token @token end |
#username ⇒ Object
Returns the value of attribute username.
12 13 14 |
# File 'lib/unbabel/client.rb', line 12 def username @username end |
Instance Method Details
#credentials ⇒ Object
25 26 27 28 29 30 |
# File 'lib/unbabel/client.rb', line 25 def credentials { username: username, token: token } end |
#credentials? ⇒ Boolean
32 33 34 |
# File 'lib/unbabel/client.rb', line 32 def credentials? credentials.values.all? end |