Class: Tembin::Redash::Client
- Inherits:
-
Object
- Object
- Tembin::Redash::Client
show all
- Defined in:
- lib/tembin/redash/client.rb
Defined Under Namespace
Classes: RequestNotSucceedError
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
11
12
13
|
# File 'lib/tembin/redash/client.rb', line 11
def initialize(api_key)
@api_key = api_key
end
|
Class Method Details
.current ⇒ Object
7
8
9
|
# File 'lib/tembin/redash/client.rb', line 7
def self.current
Thread.current[:__tembin__redash_client__] ||= new(Tembin::Redash.config['api_key'])
end
|
Instance Method Details
#delete(path, params: {}) ⇒ Object
34
35
36
37
38
|
# File 'lib/tembin/redash/client.rb', line 34
def delete(path, params: {})
response = connection.delete(path, { api_key: @api_key }.merge(params))
raise RequestNotSucceedError, response.body if !response.success?
response
end
|
#get(path, params: {}) ⇒ Object
15
16
17
18
19
|
# File 'lib/tembin/redash/client.rb', line 15
def get(path, params: {})
response = connection.get(path, { api_key: @api_key }.merge(params))
raise RequestNotSucceedError, response.body if !response.success?
response
end
|
#post(path, body: {}, params: {}) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/tembin/redash/client.rb', line 21
def post(path, body: {}, params: {})
response = connection.post do |req|
req.url(path)
req.params = params.merge(api_key: @api_key)
req.body = body.to_json
req
end
raise RequestNotSucceedError, response.body if !response.success?
response
end
|