Module: BWAPI::Default

Defined in:
lib/bwapi/default.rb

Overview

Default module

Constant Summary collapse

ADAPTER =
Faraday.default_adapter
API_ENDPOINT =
'https://newapi.brandwatch.com/'
CLIENT_ID =
'brandwatch-api-client'
GRANT_TYPE =
'api-password'
USER_AGENT =
"BWAPI Ruby Gem #{BWAPI::VERSION}".freeze

Class Method Summary collapse

Class Method Details

.access_tokenObject



25
26
27
# File 'lib/bwapi/default.rb', line 25

def access_token
  ENV['BWAPI_ACCESS_TOKEN']
end

.access_token_expiryObject



29
30
31
# File 'lib/bwapi/default.rb', line 29

def access_token_expiry
  nil
end

.adapterObject



33
34
35
# File 'lib/bwapi/default.rb', line 33

def adapter
  ENV['BWAPI_ADAPTER'].is_a?(String) ? ENV['BWAPI_ADAPTER'].to_sym : ADAPTER
end

.api_endpointObject



37
38
39
# File 'lib/bwapi/default.rb', line 37

def api_endpoint
  ENV['BWAPI_API_ENDPOINT'] || API_ENDPOINT
end

.client_idObject



41
42
43
# File 'lib/bwapi/default.rb', line 41

def client_id
  ENV['BWAPI_CLIENT_ID'] || CLIENT_ID
end

.client_secretObject



45
46
47
# File 'lib/bwapi/default.rb', line 45

def client_secret
  ENV['BWAPI_CLIENT_SECRET']
end

.connection_optionsObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/bwapi/default.rb', line 49

def connection_options
  {
    headers: {
      user_agent: user_agent
    },
    request: {
      params_encoder: Faraday::FlatParamsEncoder
    }
  }
end

.debugObject



60
61
62
# File 'lib/bwapi/default.rb', line 60

def debug
  ENV['BWAPI_DEBUG'] == 'true' ? true : false
end

.grant_typeObject



64
65
66
# File 'lib/bwapi/default.rb', line 64

def grant_type
  ENV['BWAPI_GRANT_TYPE'] || GRANT_TYPE
end

.loggerObject



68
69
70
# File 'lib/bwapi/default.rb', line 68

def logger
  nil
end

.optionsObject



21
22
23
# File 'lib/bwapi/default.rb', line 21

def options
  Hash[BWAPI::Configuration.keys.map { |key| [key, send(key)] }]
end

.passwordObject



72
73
74
# File 'lib/bwapi/default.rb', line 72

def password
  ENV['BWAPI_PASSWORD']
end

.performanceObject



76
77
78
# File 'lib/bwapi/default.rb', line 76

def performance
  Allotment.results
end

.refresh_tokenObject



80
81
82
# File 'lib/bwapi/default.rb', line 80

def refresh_token
  ENV['BWAPI_REFRESH_TOKEN']
end

.user_agentObject



84
85
86
# File 'lib/bwapi/default.rb', line 84

def user_agent
  ENV['BWAPI_USER_AGENT'] || USER_AGENT
end

.usernameObject



88
89
90
# File 'lib/bwapi/default.rb', line 88

def username
  ENV['BWAPI_USERNAME']
end

.verify_sslObject



92
93
94
# File 'lib/bwapi/default.rb', line 92

def verify_ssl
  ENV['BWAPI_VERIFY_SSL'] == 'true' ? true : false
end