Class: Wit::Client
- Inherits:
-
Object
- Object
- Wit::Client
- Defined in:
- lib/wit/client.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #classify_message(message = '') ⇒ Object
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/wit/client.rb', line 5 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/wit/client.rb', line 3 def token @token end |
Instance Method Details
#classify_message(message = '') ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/wit/client.rb', line 9 def ( = '') response = connection.get do |req| req.headers['Authorization'] = "Bearer #{token}" req.url '/message', q: end case response.status when 200 then return Result.new JSON.parse(response.body) when 401 then raise Unauthorized, "incorrect token" else raise BadResponse, "response code: #{response.status}" end end |