class BWAPI::Client
Public Class Methods
new(options = {})
click to toggle source
Initializes Client
@params options [Hash] the configuration options
# File lib/bwapi/client.rb, line 67 def initialize(options = {}) BWAPI::Configuration.keys.each do |key| instance_variable_set(:"@#{key}", options[key] || BWAPI.instance_variable_get(:"@#{key}")) end end
Public Instance Methods
access_token=(value)
click to toggle source
# File lib/bwapi/client.rb, line 109 def access_token=(value) reset_connection @access_token = value end
access_token_expired?()
click to toggle source
Check is access token has expired
@return [Boolean] access token expiry status
# File lib/bwapi/client.rb, line 76 def access_token_expired? return true if @access_token.nil? || @access_token_expiry.nil? seconds_until_access_token_expires <= 0 end
api_client?()
click to toggle source
Check if user is a brandwatch-api-client type
@return [Boolean] Application client status
# File lib/bwapi/client.rb, line 98 def api_client? @client_id == 'brandwatch-api-client' ? true : false end
api_endpoint=(value)
click to toggle source
# File lib/bwapi/client.rb, line 114 def api_endpoint=(value) reset_connection @api_endpoint = value end
api_super_admin_client?()
click to toggle source
Check if user is a brandwatch-api-superadmin-client type
@return [Boolean] Application client status
# File lib/bwapi/client.rb, line 105 def api_super_admin_client? @client_id == 'brandwatch-api-superadmin-client' ? true : false end
application_client?()
click to toggle source
Check if user is a brandwatch-application-client type
@return [Boolean] Application client status
# File lib/bwapi/client.rb, line 91 def application_client? @client_id == 'brandwatch-application-client' ? true : false end
authenticated?()
click to toggle source
Check if user is authenicated
@return [Boolean] Authenticated status
# File lib/bwapi/client.rb, line 84 def authenticated? (@access_token && !access_token_expired?) ? true : false end
connection_options=(value)
click to toggle source
# File lib/bwapi/client.rb, line 119 def connection_options=(value) reset_connection @connection_options = value end
debug=(value)
click to toggle source
# File lib/bwapi/client.rb, line 124 def debug=(value) reset_connection @debug = value end
logger=(value)
click to toggle source
# File lib/bwapi/client.rb, line 129 def logger=(value) reset_connection @logger = value end
verify_ssl=(value)
click to toggle source
# File lib/bwapi/client.rb, line 134 def verify_ssl=(value) reset_connection @verify_ssl = value end
Private Instance Methods
seconds_until_access_token_expires()
click to toggle source
Returns the number of seconds until the access token expires
@return [Integer] seconds until expiry
# File lib/bwapi/client.rb, line 144 def seconds_until_access_token_expires DateTime.parse(@access_token_expiry).to_time.to_i - Time.now.to_i end