Class: FacetzApi::Client
- Inherits:
-
Object
- Object
- FacetzApi::Client
- Defined in:
- lib/facetz_api/client.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Instance Method Summary collapse
- #body(ids: [], tids: {}) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #lookup(ids: [], tids: {}) ⇒ Object
- #pars_response(body) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/facetz_api/client.rb', line 5 def initialize @conn = FacetzApi::API.call end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
3 4 5 |
# File 'lib/facetz_api/client.rb', line 3 def conn @conn end |
Instance Method Details
#body(ids: [], tids: {}) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/facetz_api/client.rb', line 19 def body(ids: [], tids: {}) { user: FacetzApi.configuration.user, key: FacetzApi.configuration.key, ids: ids, } end |
#lookup(ids: [], tids: {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/facetz_api/client.rb', line 9 def lookup(ids: [], tids: {}) response = @conn.post do |req| req.url FacetzApi.configuration.version req.headers['Content-Type'] = 'application/json' req.body = body(ids: ids).to_json end pars_response(response.body) end |
#pars_response(body) ⇒ Object
27 28 29 |
# File 'lib/facetz_api/client.rb', line 27 def pars_response(body) JSON.parse(body) unless body.empty? end |