Class: TableauRestApi::Client
- Inherits:
-
Object
- Object
- TableauRestApi::Client
- Defined in:
- lib/tableau_rest_api/client.rb
Overview
Client class wrapping a subset of the Tableau Rest API This class just contains worker methods for interacting with Tableau. See the Request sub-class for resource requests.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #authorised? ⇒ Boolean
- #configure(config) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #login(*_args) ⇒ Object
- #logout ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/tableau_rest_api/client.rb', line 6 def config @config end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/tableau_rest_api/client.rb', line 6 def token @token end |
Instance Method Details
#authorised? ⇒ Boolean
29 30 31 32 |
# File 'lib/tableau_rest_api/client.rb', line 29 def token = self.token token && !token.expired? ? true : false end |
#configure(config) ⇒ Object
12 13 14 |
# File 'lib/tableau_rest_api/client.rb', line 12 def configure(config) @config = Config.new(config). end |
#login(*_args) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/tableau_rest_api/client.rb', line 16 def login(*_args) return if url = build_url ['auth', 'signin'] resp = post url, @config[:credentials] @token = Token.new(resp.credentials.token, @config[:auth_duration]) end |
#logout ⇒ Object
23 24 25 26 27 |
# File 'lib/tableau_rest_api/client.rb', line 23 def logout post(build_url ['auth', 'signout']) @token = nil ! end |