Class: Rescuetime::Client
- Inherits:
-
Object
- Object
- Rescuetime::Client
- Includes:
- QueryBuildable
- Defined in:
- lib/rescuetime/client.rb
Overview
Rescuetime::Client makes HTTP requests to the RescueTime API and returns the appropriate values
Constant Summary
Constants included from QueryBuildable
QueryBuildable::BASE_PARAMS, QueryBuildable::VALID
Instance Attribute Summary collapse
-
#api_key ⇒ String?
Represents the client’s Rescuetime API key, required for successful requests.
Instance Method Summary collapse
-
#api_key? ⇒ Boolean
Returns true if the API key is present.
-
#initialize(key = nil, api_key: nil) ⇒ Rescuetime::Client
constructor
Creates a new Rescuetime client.
-
#valid_credentials? ⇒ Boolean
Returns true if the provided api key is valid.
Methods included from QueryBuildable
#activities, #categories, #date, #efficiency, #from, #order_by, #overview, #productivity, #to, #where
Constructor Details
#initialize(key = nil, api_key: nil) ⇒ Rescuetime::Client
Creates a new Rescuetime client. The API key can be passed as either a parameter or option (with “key” taking priority over “:api_key”)
46 47 48 |
# File 'lib/rescuetime/client.rb', line 46 def initialize(key = nil, api_key: nil) @api_key = key || api_key end |
Instance Attribute Details
#api_key ⇒ String?
Represents the client’s Rescuetime API key, required for successful requests
21 22 23 |
# File 'lib/rescuetime/client.rb', line 21 def api_key @api_key end |
Instance Method Details
#api_key? ⇒ Boolean
Returns true if the API key is present.
66 67 68 69 |
# File 'lib/rescuetime/client.rb', line 66 def api_key? key = CoreExtensions::String.new api_key.to_s key.present? end |
#valid_credentials? ⇒ Boolean
Returns true if the provided api key is valid. Performs a request to the Rescuetime API.
91 92 93 94 95 96 |
# File 'lib/rescuetime/client.rb', line 91 def valid_credentials? return false unless api_key? !activities.all.nil? rescue Rescuetime::Errors::InvalidCredentialsError false end |