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, authorized_user_email: nil) ⇒ Client
Returns a new instance of Client.
11
12
13
14
|
# File 'lib/tembin/redash/client.rb', line 11
def initialize(api_key, authorized_user_email: nil)
@api_key = api_key
@authorized_user_email = authorized_user_email
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'], authorized_user_email: Tembin::Redash.config['authorized_user_email'])
end
|
Instance Method Details
#delete(path, params: {}) ⇒ Object
35
36
37
38
39
|
# File 'lib/tembin/redash/client.rb', line 35
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
16
17
18
19
20
|
# File 'lib/tembin/redash/client.rb', line 16
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
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/tembin/redash/client.rb', line 22
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
|