bwapi 9.0.0.pre.349 → 9.0.0.pre.364
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -1
- data/.rubocop.yml +3 -0
- data/.travis.yml +0 -3
- data/Gemfile +3 -3
- data/README.md +0 -1
- data/bin/bwapi +0 -1
- data/bwapi.gemspec +6 -9
- data/lib/bwapi.rb +16 -14
- data/lib/bwapi/client.rb +65 -16
- data/lib/bwapi/client/admin.rb +0 -2
- data/lib/bwapi/client/admin/become.rb +0 -2
- data/lib/bwapi/client/admin/search.rb +0 -2
- data/lib/bwapi/client/admin/sub_clients.rb +0 -2
- data/lib/bwapi/client/admin/users.rb +0 -2
- data/lib/bwapi/client/admin/users/sharing.rb +0 -2
- data/lib/bwapi/client/brandwatch.rb +0 -2
- data/lib/bwapi/client/brandwatch/become.rb +0 -2
- data/lib/bwapi/client/brandwatch/client_modules.rb +0 -1
- data/lib/bwapi/client/client.rb +0 -2
- data/lib/bwapi/client/command_center.rb +0 -2
- data/lib/bwapi/client/command_center/client.rb +0 -2
- data/lib/bwapi/client/command_center/displays.rb +0 -2
- data/lib/bwapi/client/command_center/displays/events.rb +0 -2
- data/lib/bwapi/client/command_center/displays/messages.rb +0 -1
- data/lib/bwapi/client/command_center/displays/scenes.rb +0 -2
- data/lib/bwapi/client/command_center/displays/screens.rb +0 -2
- data/lib/bwapi/client/command_center/displays/users.rb +0 -2
- data/lib/bwapi/client/command_center/displays/users/access.rb +0 -1
- data/lib/bwapi/client/command_center/scene_types.rb +0 -2
- data/lib/bwapi/client/command_center/themes.rb +0 -2
- data/lib/bwapi/client/command_center/users.rb +0 -2
- data/lib/bwapi/client/command_center/users/access.rb +0 -2
- data/lib/bwapi/client/error_codes.rb +0 -2
- data/lib/bwapi/client/filters.rb +0 -2
- data/lib/bwapi/client/languages.rb +0 -2
- data/lib/bwapi/client/locations.rb +0 -2
- data/lib/bwapi/client/logout.rb +0 -3
- data/lib/bwapi/client/me.rb +2 -11
- data/lib/bwapi/client/metrics.rb +0 -2
- data/lib/bwapi/client/oauth.rb +0 -3
- data/lib/bwapi/client/ping.rb +0 -2
- data/lib/bwapi/client/projects.rb +0 -2
- data/lib/bwapi/client/projects/bulkactions.rb +0 -2
- data/lib/bwapi/client/projects/bulkactions/author.rb +0 -2
- data/lib/bwapi/client/projects/bulkactions/mentions.rb +0 -2
- data/lib/bwapi/client/projects/categories.rb +0 -2
- data/lib/bwapi/client/projects/categories/copy.rb +0 -2
- data/lib/bwapi/client/projects/data.rb +0 -1
- data/lib/bwapi/client/projects/data/mentions.rb +0 -1
- data/lib/bwapi/client/projects/data/mentions/notes.rb +0 -2
- data/lib/bwapi/client/projects/data/volume.rb +0 -2
- data/lib/bwapi/client/projects/data_download.rb +0 -2
- data/lib/bwapi/client/projects/demographics.rb +0 -1
- data/lib/bwapi/client/projects/facebook_queries.rb +0 -2
- data/lib/bwapi/client/projects/group.rb +0 -1
- data/lib/bwapi/client/projects/group/author_group.rb +0 -2
- data/lib/bwapi/client/projects/group/location_group.rb +0 -1
- data/lib/bwapi/client/projects/group/site_group.rb +0 -1
- data/lib/bwapi/client/projects/queries.rb +0 -2
- data/lib/bwapi/client/projects/queries/backfill.rb +0 -1
- data/lib/bwapi/client/projects/queries/date_range.rb +0 -2
- data/lib/bwapi/client/projects/queries/mentions.rb +0 -1
- data/lib/bwapi/client/projects/query_groups.rb +0 -1
- data/lib/bwapi/client/projects/rules.rb +0 -1
- data/lib/bwapi/client/projects/rules/backfill.rb +0 -2
- data/lib/bwapi/client/projects/rules/copy.rb +0 -2
- data/lib/bwapi/client/projects/sharing.rb +0 -2
- data/lib/bwapi/client/projects/signals.rb +0 -2
- data/lib/bwapi/client/projects/stream_dashboards.rb +0 -2
- data/lib/bwapi/client/projects/stream_dashboards/streams.rb +0 -1
- data/lib/bwapi/client/projects/summary.rb +0 -2
- data/lib/bwapi/client/projects/tags.rb +0 -2
- data/lib/bwapi/client/projects/twitter_queries.rb +0 -2
- data/lib/bwapi/client/projects/users.rb +0 -2
- data/lib/bwapi/client/projects/workflow.rb +0 -2
- data/lib/bwapi/client/query_validation.rb +0 -2
- data/lib/bwapi/client/sso.rb +0 -2
- data/lib/bwapi/client/test_search.rb +0 -2
- data/lib/bwapi/client/user.rb +0 -2
- data/lib/bwapi/client/user/notifications.rb +0 -2
- data/lib/bwapi/configuration.rb +40 -56
- data/lib/bwapi/connection.rb +32 -14
- data/lib/bwapi/default.rb +91 -0
- data/lib/bwapi/error.rb +1 -3
- data/lib/bwapi/performance.rb +39 -0
- data/lib/bwapi/request.rb +6 -33
- data/lib/bwapi/response/error.rb +28 -0
- data/lib/bwapi/response/logger.rb +35 -0
- data/lib/bwapi/response/performance.rb +31 -0
- data/lib/bwapi/version.rb +0 -2
- data/spec/bwapi/client_spec.rb +55 -49
- data/spec/bwapi_spec.rb +1 -3
- data/spec/helper.rb +1 -4
- metadata +32 -47
- data/lib/bwapi/authentication.rb +0 -48
- data/lib/faraday/response/brandwatch_error.rb +0 -25
- data/spec/bwapi/authentication_spec.rb +0 -57
- data/spec/fixtures/.netrc +0 -3
data/lib/bwapi/client/me.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module BWAPI
|
4
2
|
class Client
|
5
3
|
# Me module for me endpoint and helper methods
|
@@ -14,21 +12,14 @@ module BWAPI
|
|
14
12
|
# Get users client name
|
15
13
|
#
|
16
14
|
# @return [String] Users client name
|
17
|
-
def
|
15
|
+
def user_client_name
|
18
16
|
me.client.name
|
19
17
|
end
|
20
18
|
|
21
19
|
# Get users client id
|
22
20
|
#
|
23
21
|
# @return [String] Users client id
|
24
|
-
def
|
25
|
-
me.client.id
|
26
|
-
end
|
27
|
-
|
28
|
-
# Get users client id
|
29
|
-
#
|
30
|
-
# @return [String] Users client id
|
31
|
-
def client_id
|
22
|
+
def user_client_name
|
32
23
|
me.client.id
|
33
24
|
end
|
34
25
|
|
data/lib/bwapi/client/metrics.rb
CHANGED
data/lib/bwapi/client/oauth.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module BWAPI
|
4
2
|
class Client
|
5
3
|
# OAuth module for oauth/token endpoint
|
@@ -64,7 +62,6 @@ module BWAPI
|
|
64
62
|
def oauth_request(opts = {})
|
65
63
|
creds = post 'oauth/token', opts
|
66
64
|
self.access_token = creds.access_token
|
67
|
-
self.expires_in = creds.expires_in
|
68
65
|
self.refresh_token = creds.refresh_token if application_client?
|
69
66
|
creds
|
70
67
|
end
|
data/lib/bwapi/client/ping.rb
CHANGED
data/lib/bwapi/client/sso.rb
CHANGED
data/lib/bwapi/client/user.rb
CHANGED
data/lib/bwapi/configuration.rb
CHANGED
@@ -1,42 +1,32 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
require 'faraday'
|
5
|
-
|
6
1
|
module BWAPI
|
7
2
|
# Configuration module to set default and custom client credentials
|
8
3
|
module Configuration
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
attr_accessor(*OPTION_KEYS)
|
36
|
-
|
37
|
-
# Extend hook
|
38
|
-
def self.extended(base)
|
39
|
-
base.reset
|
4
|
+
attr_accessor :access_token, :adapter, :api_endpoint, :client_id, :debug, :grant_type,
|
5
|
+
:logger, :performance, :refresh_token, :user_agent, :username, :verify_ssl
|
6
|
+
|
7
|
+
attr_writer :client_secret, :password
|
8
|
+
|
9
|
+
class << self
|
10
|
+
# Configuration keys
|
11
|
+
def keys
|
12
|
+
@keys ||= [
|
13
|
+
:access_token,
|
14
|
+
:adapter,
|
15
|
+
:api_endpoint,
|
16
|
+
:client_id,
|
17
|
+
:client_secret,
|
18
|
+
:connection_options,
|
19
|
+
:debug,
|
20
|
+
:grant_type,
|
21
|
+
:logger,
|
22
|
+
:password,
|
23
|
+
:performance,
|
24
|
+
:refresh_token,
|
25
|
+
:user_agent,
|
26
|
+
:username,
|
27
|
+
:verify_ssl
|
28
|
+
]
|
29
|
+
end
|
40
30
|
end
|
41
31
|
|
42
32
|
# Set configuration options using a block
|
@@ -44,28 +34,22 @@ module BWAPI
|
|
44
34
|
yield self
|
45
35
|
end
|
46
36
|
|
47
|
-
|
48
|
-
|
49
|
-
|
37
|
+
def reset
|
38
|
+
BWAPI::Configuration.keys.each { |key| instance_variable_set(:"@#{key}", BWAPI::Default.options[key]) }
|
39
|
+
self
|
50
40
|
end
|
51
41
|
|
52
|
-
|
53
|
-
|
54
|
-
self
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
self.client_secret = nil
|
64
|
-
self.verify_ssl = true
|
65
|
-
self.netrc = false
|
66
|
-
self.netrc_file = DEFAULT_NETRC_FILE
|
67
|
-
self.debug = false
|
68
|
-
self.log = DEFAULT_LOGGER_FILE
|
42
|
+
def destroy
|
43
|
+
BWAPI::Configuration.keys.each { |key| instance_variable_set(:"@#{key}", nil) }
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
attr_reader :client_secret, :password
|
50
|
+
|
51
|
+
def options
|
52
|
+
Hash[BWAPI::Configuration.keys.map { |key| [key, instance_variable_get(:"@#{key}")] }]
|
69
53
|
end
|
70
54
|
end
|
71
55
|
end
|
data/lib/bwapi/connection.rb
CHANGED
@@ -1,27 +1,45 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'bwapi/response/error'
|
2
|
+
require 'bwapi/response/logger'
|
3
|
+
require 'bwapi/response/performance'
|
3
4
|
require 'faraday_middleware'
|
4
|
-
require 'faraday/response/brandwatch_error'
|
5
5
|
|
6
6
|
module BWAPI
|
7
|
-
#
|
7
|
+
# Configuration module to set default and custom client credentials
|
8
8
|
module Connection
|
9
|
+
RACK_BUILDER_CLASS = defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
|
10
|
+
|
9
11
|
private
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def connection
|
14
|
+
@connection ||= Faraday.new(faraday_options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def reset_connection
|
18
|
+
@connection = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def faraday_options
|
22
|
+
opts = @connection_options
|
23
|
+
opts[:headers][:authorization] = "bearer #{@access_token}" if @access_token
|
24
|
+
opts[:builder] = middleware
|
25
|
+
opts[:ssl] = { verify: @verify_ssl }
|
26
|
+
opts[:url] = @api_endpoint
|
27
|
+
opts
|
28
|
+
end
|
29
|
+
|
30
|
+
def middleware
|
31
|
+
RACK_BUILDER_CLASS.new do |builder|
|
32
|
+
builder.use FaradayMiddleware::Mashify
|
15
33
|
|
16
|
-
|
34
|
+
builder.use BWAPI::Response::Performance, self if debug
|
35
|
+
builder.use BWAPI::Response::Error
|
36
|
+
builder.use BWAPI::Response::Logger, self if debug
|
17
37
|
|
18
|
-
|
19
|
-
|
20
|
-
c.response :json, content_type: /\bjson$/
|
38
|
+
builder.use FaradayMiddleware::FollowRedirects
|
39
|
+
builder.use FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
21
40
|
|
22
|
-
|
41
|
+
builder.adapter Faraday.default_adapter
|
23
42
|
end
|
24
|
-
connection
|
25
43
|
end
|
26
44
|
end
|
27
45
|
end
|