bwapi 6.5.0.pre.256 → 7.0.0.pre.271
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.editorconfig +11 -0
- data/.rubocop.yml +17 -0
- data/.travis.yml +7 -3
- data/bin/bwapi +2 -1
- data/bwapi.gemspec +13 -10
- data/lib/bwapi.rb +6 -6
- data/lib/bwapi/authentication.rb +9 -17
- data/lib/bwapi/client.rb +5 -4
- data/lib/bwapi/client/admin.rb +6 -6
- data/lib/bwapi/client/admin/become.rb +4 -4
- data/lib/bwapi/client/admin/search.rb +9 -12
- data/lib/bwapi/client/admin/sub_clients.rb +8 -13
- data/lib/bwapi/client/admin/users.rb +7 -7
- data/lib/bwapi/client/admin/users/sharing.rb +5 -7
- data/lib/bwapi/client/brandwatch.rb +4 -4
- data/lib/bwapi/client/brandwatch/become.rb +4 -4
- data/lib/bwapi/client/brandwatch/client_modules.rb +5 -6
- data/lib/bwapi/client/client.rb +5 -6
- data/lib/bwapi/client/command_center.rb +3 -3
- data/lib/bwapi/client/command_center/client.rb +4 -4
- data/lib/bwapi/client/command_center/displays.rb +9 -9
- data/lib/bwapi/client/command_center/displays/events.rb +8 -8
- data/lib/bwapi/client/command_center/displays/messages.rb +7 -8
- data/lib/bwapi/client/command_center/displays/scenes.rb +9 -9
- data/lib/bwapi/client/command_center/displays/screens.rb +9 -9
- data/lib/bwapi/client/command_center/displays/users.rb +7 -8
- data/lib/bwapi/client/command_center/displays/users/access.rb +4 -5
- data/lib/bwapi/client/command_center/scene_types.rb +6 -6
- data/lib/bwapi/client/command_center/themes.rb +4 -4
- data/lib/bwapi/client/command_center/users.rb +6 -6
- data/lib/bwapi/client/command_center/users/access.rb +5 -5
- data/lib/bwapi/client/error_codes.rb +4 -4
- data/lib/bwapi/client/filters.rb +4 -4
- data/lib/bwapi/client/languages.rb +3 -3
- data/lib/bwapi/client/location.rb +5 -5
- data/lib/bwapi/client/logout.rb +12 -14
- data/lib/bwapi/client/me.rb +3 -3
- data/lib/bwapi/client/metrics.rb +3 -3
- data/lib/bwapi/client/oauth.rb +8 -8
- data/lib/bwapi/client/ping.rb +8 -8
- data/lib/bwapi/client/projects.rb +10 -10
- data/lib/bwapi/client/projects/bulkactions.rb +4 -4
- data/lib/bwapi/client/projects/bulkactions/author.rb +4 -3
- data/lib/bwapi/client/projects/bulkactions/mentions.rb +4 -3
- data/lib/bwapi/client/projects/categories.rb +6 -20
- data/lib/bwapi/client/projects/data.rb +4 -5
- data/lib/bwapi/client/projects/data/mentions.rb +7 -7
- data/lib/bwapi/client/projects/data/volume.rb +11 -11
- data/lib/bwapi/client/projects/data_download.rb +6 -7
- data/lib/bwapi/client/projects/demographics.rb +3 -4
- data/lib/bwapi/client/projects/facebook_queries.rb +8 -9
- data/lib/bwapi/client/projects/group.rb +2 -2
- data/lib/bwapi/client/projects/group/author_group.rb +8 -7
- data/lib/bwapi/client/projects/group/location_group.rb +7 -7
- data/lib/bwapi/client/projects/group/site_group.rb +7 -7
- data/lib/bwapi/client/projects/queries.rb +9 -10
- data/lib/bwapi/client/projects/queries/backfill.rb +6 -8
- data/lib/bwapi/client/projects/queries/date_range.rb +9 -9
- data/lib/bwapi/client/projects/queries/mentions.rb +5 -8
- data/lib/bwapi/client/projects/query_groups.rb +7 -9
- data/lib/bwapi/client/projects/rules.rb +7 -9
- data/lib/bwapi/client/projects/rules/backfill.rb +4 -4
- data/lib/bwapi/client/projects/rules/copy.rb +4 -4
- data/lib/bwapi/client/projects/sharing.rb +8 -9
- data/lib/bwapi/client/projects/signals.rb +5 -5
- data/lib/bwapi/client/projects/stream_dashboards.rb +10 -10
- data/lib/bwapi/client/projects/stream_dashboards/streams.rb +6 -7
- data/lib/bwapi/client/projects/summary.rb +5 -6
- data/lib/bwapi/client/projects/tags.rb +8 -9
- data/lib/bwapi/client/projects/twitter_queries.rb +7 -8
- data/lib/bwapi/client/projects/users.rb +4 -4
- data/lib/bwapi/client/projects/workflow.rb +4 -4
- data/lib/bwapi/client/query_validation.rb +7 -7
- data/lib/bwapi/client/sso.rb +4 -4
- data/lib/bwapi/client/test_search.rb +9 -8
- data/lib/bwapi/client/user.rb +6 -6
- data/lib/bwapi/client/user/notifications.rb +8 -8
- data/lib/bwapi/configuration.rb +6 -6
- data/lib/bwapi/connection.rb +10 -19
- data/lib/bwapi/error.rb +43 -36
- data/lib/bwapi/request.rb +24 -27
- data/lib/bwapi/version.rb +5 -2
- data/lib/faraday/response/brandwatch_error.rb +21 -22
- data/spec/bwapi/authentication_spec.rb +7 -7
- data/spec/bwapi/client_spec.rb +17 -17
- data/spec/bwapi_spec.rb +3 -3
- data/spec/fixtures/.netrc +1 -1
- data/spec/helper.rb +4 -2
- metadata +61 -4
- data/lib/faraday/utils/utils.rb +0 -26
data/lib/bwapi/connection.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'faraday_middleware'
|
2
4
|
require 'faraday/response/brandwatch_error'
|
3
|
-
require 'faraday/utils/utils'
|
4
5
|
|
5
6
|
module BWAPI
|
6
7
|
# Connection module to handle requests
|
@@ -8,26 +9,16 @@ module BWAPI
|
|
8
9
|
private
|
9
10
|
|
10
11
|
# Create a connection to send request
|
11
|
-
def connection
|
12
|
-
connection = Faraday.new(opts) do |
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
conn.request :json
|
21
|
-
conn.use Faraday::Response::BrandwatchError
|
22
|
-
conn.use FaradayMiddleware::FollowRedirects
|
23
|
-
conn.use FaradayMiddleware::Mashify
|
24
|
-
conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
|
25
|
-
conn.adapter adapter
|
12
|
+
def connection(opts = {})
|
13
|
+
connection = Faraday.new(opts) do |c|
|
14
|
+
c.use FaradayMiddleware::FollowRedirects
|
15
|
+
c.use BrandwatchError
|
16
|
+
c.use FaradayMiddleware::Mashify
|
17
|
+
c.use FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
18
|
+
c.adapter adapter
|
26
19
|
end
|
27
|
-
|
28
20
|
connection.headers[:user_agent] = user_agent
|
29
21
|
connection
|
30
22
|
end
|
31
|
-
|
32
23
|
end
|
33
|
-
end
|
24
|
+
end
|
data/lib/bwapi/error.rb
CHANGED
@@ -1,68 +1,75 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
|
+
module BWAPI
|
3
4
|
# BW error class to capture BWAPI error responses
|
4
5
|
class BWError < StandardError
|
5
|
-
def initialize
|
6
|
-
|
7
|
-
|
8
|
-
super(
|
6
|
+
def initialize(response = nil)
|
7
|
+
@errors = []
|
8
|
+
valid_response?(response)
|
9
|
+
@errors.empty? ? super() : super(@errors.join(', '))
|
9
10
|
end
|
10
11
|
|
11
|
-
#
|
12
|
-
|
12
|
+
# Check if response is valid
|
13
|
+
#
|
14
|
+
# @param object [Object] response object to check for errors
|
15
|
+
def valid_response?(response)
|
13
16
|
return nil if response.nil?
|
14
|
-
return nil unless response.is_a?(
|
15
|
-
return nil unless response
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
return nil unless response.body.is_a?(Object) && response.respond_to?(:body)
|
18
|
+
return nil unless response.body.is_a?(Hashie::Mash)
|
19
|
+
body = errors_keys?(response.body)
|
20
|
+
parse_errors(body) unless body.nil?
|
21
|
+
end
|
22
|
+
|
23
|
+
# Check if response has known errors keys
|
24
|
+
#
|
25
|
+
# @param object [Object] response object to process for errors
|
26
|
+
def errors_keys?(body)
|
27
|
+
if body.error? && body.error_description?
|
28
|
+
body
|
29
|
+
elsif body.errors?
|
30
|
+
body.errors
|
22
31
|
else
|
23
|
-
|
32
|
+
nil
|
24
33
|
end
|
25
34
|
end
|
26
35
|
|
27
|
-
#
|
36
|
+
# Parses errors based on error body passed
|
28
37
|
#
|
29
|
-
# @param
|
30
|
-
def
|
31
|
-
|
32
|
-
verify_object_class errors_object
|
33
|
-
return @error_messages.join(', ')
|
38
|
+
# @param body [Hash] errors
|
39
|
+
def parse_errors(body)
|
40
|
+
verify_type body
|
34
41
|
end
|
35
42
|
|
36
|
-
# Verifies
|
43
|
+
# Verifies type
|
37
44
|
#
|
38
|
-
# @param object [Object]
|
39
|
-
def
|
40
|
-
case
|
45
|
+
# @param object [Object] type to determine
|
46
|
+
def verify_type(type)
|
47
|
+
case type
|
41
48
|
when Array
|
42
|
-
split_array_errors
|
49
|
+
split_array_errors type
|
43
50
|
when Hash, Hashie::Mash
|
44
|
-
split_hash_errors
|
51
|
+
split_hash_errors type
|
45
52
|
when String
|
46
|
-
@
|
53
|
+
@errors << type
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|
50
57
|
# Iterates through errors in array
|
51
58
|
#
|
52
59
|
# @param array [Array] array to iterate
|
53
|
-
def split_array_errors
|
54
|
-
array.each_with_index do |
|
55
|
-
|
60
|
+
def split_array_errors(array)
|
61
|
+
array.each_with_index do |_e, i|
|
62
|
+
verify_type array[i]
|
56
63
|
end
|
57
64
|
end
|
58
65
|
|
59
66
|
# Iterates through errors in hash
|
60
67
|
#
|
61
68
|
# @param hash [Hash] hash to iterate
|
62
|
-
def split_hash_errors
|
69
|
+
def split_hash_errors(hash)
|
63
70
|
message = []
|
64
|
-
hash.each {|k,v| message << "
|
65
|
-
@
|
71
|
+
hash.each { |k, v| message << "#{k}: #{v}" }
|
72
|
+
@errors << message.flatten.join(' with ')
|
66
73
|
end
|
67
74
|
end
|
68
75
|
|
@@ -98,4 +105,4 @@ module BWAPI
|
|
98
105
|
|
99
106
|
# Raised when Brandwatch returns a 503 HTTP status code
|
100
107
|
class ServiceUnavailable < BWError; end
|
101
|
-
end
|
108
|
+
end
|
data/lib/bwapi/request.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'multi_json'
|
2
4
|
|
3
5
|
module BWAPI
|
4
6
|
# Request module to handle all requests to API
|
5
7
|
module Request
|
6
|
-
|
7
8
|
# Perform a get request
|
8
9
|
#
|
9
10
|
# @param path [String] URL path to send request
|
10
11
|
# @param opts [Hash] Request parameters
|
11
12
|
# @return [Hashie::Mash] Response body
|
12
|
-
def get
|
13
|
+
def get(path, opts = {})
|
13
14
|
request(:get, path, opts).body
|
14
15
|
end
|
15
16
|
|
@@ -18,7 +19,7 @@ module BWAPI
|
|
18
19
|
# @param path [String] URL path to send request
|
19
20
|
# @param opts [Hash] Request parameters
|
20
21
|
# @return [Hashie::Mash] Response body
|
21
|
-
def delete
|
22
|
+
def delete(path, opts = {})
|
22
23
|
request(:delete, path, opts).body
|
23
24
|
end
|
24
25
|
|
@@ -27,7 +28,7 @@ module BWAPI
|
|
27
28
|
# @param path [String] URL path to send request
|
28
29
|
# @param opts [Hash] Request parameters
|
29
30
|
# @return [Hashie::Mash] Response body
|
30
|
-
def post
|
31
|
+
def post(path, opts = {})
|
31
32
|
request(:post, path, opts).body
|
32
33
|
end
|
33
34
|
|
@@ -36,7 +37,7 @@ module BWAPI
|
|
36
37
|
# @param path [String] URL path to send request
|
37
38
|
# @param opts [Hash] Request parameters
|
38
39
|
# @return [Hashie::Mash] Response body
|
39
|
-
def put
|
40
|
+
def put(path, opts = {})
|
40
41
|
request(:put, path, opts).body
|
41
42
|
end
|
42
43
|
|
@@ -45,25 +46,21 @@ module BWAPI
|
|
45
46
|
# @param path [String] URL path to send request
|
46
47
|
# @param opts [Hash] Request parameters
|
47
48
|
# @return [Hashie::Mash] Response body
|
48
|
-
def patch
|
49
|
+
def patch(path, opts = {})
|
49
50
|
request(:patch, path, opts).body
|
50
51
|
end
|
51
52
|
|
52
53
|
private
|
53
54
|
|
54
55
|
# Sets connection options
|
55
|
-
|
56
|
-
# @param opts [Hash] hash of opts passed
|
57
|
-
# @return [Hash] connection options
|
58
|
-
def connection_options opts
|
56
|
+
def connection_options
|
59
57
|
{
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
58
|
+
headers: {
|
59
|
+
authorization: access_token ? "bearer #{access_token}" : '',
|
60
|
+
user_agent: user_agent
|
63
61
|
},
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:ssl => {:verify => verify_ssl}
|
62
|
+
url: api_endpoint,
|
63
|
+
ssl: { verify: verify_ssl }
|
67
64
|
}
|
68
65
|
end
|
69
66
|
|
@@ -73,16 +70,16 @@ module BWAPI
|
|
73
70
|
# @param path [String] URL path to send request
|
74
71
|
# @param opts [Hash] Request parameters
|
75
72
|
# @return [Hashie::Mash] Response
|
76
|
-
def request
|
77
|
-
|
78
|
-
response = connection(conn_options).send(method) do |request|
|
73
|
+
def request(method, path, opts = {})
|
74
|
+
response = connection(connection_options).send(method) do |request|
|
79
75
|
case method
|
80
76
|
when :get
|
81
77
|
request.url path, opts
|
82
78
|
when :delete
|
83
79
|
request.url path, opts
|
84
80
|
when :patch, :post, :put
|
85
|
-
if
|
81
|
+
if opts.key? :force_urlencoded
|
82
|
+
opts.delete(:force_urlencoded)
|
86
83
|
request.url path, opts
|
87
84
|
else
|
88
85
|
request.path = path
|
@@ -92,15 +89,15 @@ module BWAPI
|
|
92
89
|
end
|
93
90
|
|
94
91
|
if debug
|
95
|
-
log.info
|
96
|
-
log.info
|
97
|
-
log.info
|
98
|
-
log.info
|
99
|
-
log.info
|
100
|
-
log.info
|
92
|
+
log.info "Connection options: #{conn_options}"
|
93
|
+
log.info "Sending request type: #{method}"
|
94
|
+
log.info "Request path: #{path}"
|
95
|
+
log.info "Request url: #{api_endpoint} / #{path}"
|
96
|
+
log.info "Request parameters: #{opts.to_json}" unless opts.nil?
|
97
|
+
log.info "Response body: #{response.env[:body].to_json}" unless response.env[:body].nil?
|
101
98
|
end
|
102
99
|
|
103
100
|
response
|
104
101
|
end
|
105
102
|
end
|
106
|
-
end
|
103
|
+
end
|
data/lib/bwapi/version.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
require 'multi_json'
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
}
|
20
|
-
|
21
|
-
def on_complete(response)
|
22
|
-
key = response[:status].to_i
|
23
|
-
raise ERROR_MAP[key].new(response) if ERROR_MAP.has_key? key
|
24
|
-
end
|
6
|
+
# Brandwatch response middleware to handle errors
|
7
|
+
class BrandwatchError < Faraday::Response::Middleware
|
8
|
+
ERROR_MAP = {
|
9
|
+
400 => BWAPI::BadRequest,
|
10
|
+
401 => BWAPI::Unauthorized,
|
11
|
+
403 => BWAPI::Forbidden,
|
12
|
+
404 => BWAPI::NotFound,
|
13
|
+
406 => BWAPI::NotAcceptable,
|
14
|
+
422 => BWAPI::UnprocessableEntity,
|
15
|
+
429 => BWAPI::TooManyRequests,
|
16
|
+
500 => BWAPI::InternalServerError,
|
17
|
+
501 => BWAPI::NotImplemented,
|
18
|
+
502 => BWAPI::BadGateway,
|
19
|
+
503 => BWAPI::ServiceUnavailable
|
20
|
+
}
|
25
21
|
|
22
|
+
def on_complete(response)
|
23
|
+
key = response[:status].to_i
|
24
|
+
fail ERROR_MAP[key].new(response) if ERROR_MAP.key? key
|
26
25
|
end
|
27
|
-
end
|
26
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
describe BWAPI::Authentication do
|
4
|
-
|
5
6
|
before do
|
6
7
|
BWAPI.reset
|
7
8
|
end
|
@@ -12,14 +13,14 @@ describe BWAPI::Authentication do
|
|
12
13
|
end
|
13
14
|
|
14
15
|
it 'returns false when not authenticated' do
|
15
|
-
bw = BWAPI::Client.new :
|
16
|
+
bw = BWAPI::Client.new access_token: 'abcdef-ghijkl-123456-789012'
|
16
17
|
expect(bw.authenticated?).to eql(true)
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
21
|
describe '.application_client?' do
|
21
22
|
it 'returns true when client is a brandwatch-application-client' do
|
22
|
-
bw = BWAPI::Client.new :
|
23
|
+
bw = BWAPI::Client.new client_id: 'brandwatch-application-client'
|
23
24
|
expect(bw.application_client?).to eql(true)
|
24
25
|
end
|
25
26
|
|
@@ -30,12 +31,12 @@ describe BWAPI::Authentication do
|
|
30
31
|
|
31
32
|
describe '.api_client?' do
|
32
33
|
it 'returns true when client is a brandwatch-api-client' do
|
33
|
-
bw = BWAPI::Client.new :
|
34
|
+
bw = BWAPI::Client.new client_id: 'brandwatch-api-client'
|
34
35
|
expect(bw.api_client?).to eql(true)
|
35
36
|
end
|
36
37
|
|
37
38
|
it 'returns false when a client is not a brandwatch-api-client' do
|
38
|
-
bw = BWAPI::Client.new :
|
39
|
+
bw = BWAPI::Client.new client_id: 'brandwatch-application-client'
|
39
40
|
expect(bw.api_client?).to eql(false)
|
40
41
|
end
|
41
42
|
end
|
@@ -47,11 +48,10 @@ describe BWAPI::Authentication do
|
|
47
48
|
end
|
48
49
|
|
49
50
|
it 'returns credentials when netrc is true' do
|
50
|
-
bw = BWAPI::Client.new :
|
51
|
+
bw = BWAPI::Client.new netrc: true, netrc_file: File.join(fixture_path, '.netrc')
|
51
52
|
bw.netrc_credentials
|
52
53
|
expect(bw.username).to eql('testuser@brandwatch.com')
|
53
54
|
expect(bw.password).to eql('password')
|
54
55
|
end
|
55
|
-
|
56
56
|
end
|
57
57
|
end
|
data/spec/bwapi/client_spec.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
describe BWAPI::Client do
|
4
|
-
|
5
6
|
before do
|
6
7
|
BWAPI.reset
|
7
8
|
end
|
@@ -74,7 +75,7 @@ describe BWAPI::Client do
|
|
74
75
|
end
|
75
76
|
|
76
77
|
it 'should allow a user to set a default_adapter value' do
|
77
|
-
bw = BWAPI::Client.new :
|
78
|
+
bw = BWAPI::Client.new adapter: 'custom_adapter'
|
78
79
|
expect(bw.adapter).to eql('custom_adapter')
|
79
80
|
end
|
80
81
|
end
|
@@ -85,29 +86,29 @@ describe BWAPI::Client do
|
|
85
86
|
end
|
86
87
|
|
87
88
|
it 'should allow a user to set a user_agent value' do
|
88
|
-
bw = BWAPI::Client.new :
|
89
|
+
bw = BWAPI::Client.new user_agent: 'custom_user_agent'
|
89
90
|
expect(bw.user_agent).to eql('custom_user_agent')
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
94
|
describe 'api_endpoint' do
|
94
95
|
it 'should have a default api_endpoint value' do
|
95
|
-
expect(BWAPI::Client.new.api_endpoint).to eql(
|
96
|
+
expect(BWAPI::Client.new.api_endpoint).to eql('https://newapi.brandwatch.com/')
|
96
97
|
end
|
97
98
|
|
98
99
|
it 'should allow a user to set a api_endpoint value' do
|
99
|
-
bw = BWAPI::Client.new :
|
100
|
+
bw = BWAPI::Client.new api_endpoint: 'http://newapi.custom.brandwatch.com'
|
100
101
|
expect(bw.api_endpoint).to eql('http://newapi.custom.brandwatch.com')
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
105
|
describe 'client_id' do
|
105
106
|
it 'should have a default client_id value' do
|
106
|
-
expect(BWAPI::Client.new.client_id).to eql(
|
107
|
+
expect(BWAPI::Client.new.client_id).to eql('brandwatch-api-client')
|
107
108
|
end
|
108
109
|
|
109
110
|
it 'should allow a user to set a client_id value' do
|
110
|
-
bw = BWAPI::Client.new :
|
111
|
+
bw = BWAPI::Client.new client_id: 'custom_client_id'
|
111
112
|
expect(bw.client_id).to eql('custom_client_id')
|
112
113
|
end
|
113
114
|
end
|
@@ -118,7 +119,7 @@ describe BWAPI::Client do
|
|
118
119
|
end
|
119
120
|
|
120
121
|
it 'should allow a user to set true for the netrc value' do
|
121
|
-
bw = BWAPI::Client.new :
|
122
|
+
bw = BWAPI::Client.new netrc: true, netrc_file: File.join(fixture_path, '.netrc')
|
122
123
|
expect(bw.netrc).to eql(true)
|
123
124
|
end
|
124
125
|
end
|
@@ -129,7 +130,7 @@ describe BWAPI::Client do
|
|
129
130
|
end
|
130
131
|
|
131
132
|
it 'should allow a user to set a netrc_file value' do
|
132
|
-
bw = BWAPI::Client.new :
|
133
|
+
bw = BWAPI::Client.new netrc_file: 'example/.netrc'
|
133
134
|
expect(bw.netrc_file).to eql('example/.netrc')
|
134
135
|
end
|
135
136
|
end
|
@@ -140,7 +141,7 @@ describe BWAPI::Client do
|
|
140
141
|
end
|
141
142
|
|
142
143
|
it 'should allow a user to set a username value' do
|
143
|
-
bw = BWAPI::Client.new :
|
144
|
+
bw = BWAPI::Client.new username: 'jonathan@brandwatch.com'
|
144
145
|
expect(bw.username).to eql('jonathan@brandwatch.com')
|
145
146
|
end
|
146
147
|
end
|
@@ -151,7 +152,7 @@ describe BWAPI::Client do
|
|
151
152
|
end
|
152
153
|
|
153
154
|
it 'should allow a user to set a password value' do
|
154
|
-
bw = BWAPI::Client.new :
|
155
|
+
bw = BWAPI::Client.new password: 'pa55w0rd'
|
155
156
|
expect(bw.password).to eql('pa55w0rd')
|
156
157
|
end
|
157
158
|
end
|
@@ -162,7 +163,7 @@ describe BWAPI::Client do
|
|
162
163
|
end
|
163
164
|
|
164
165
|
it 'should allow a user to set a grant_type value' do
|
165
|
-
bw = BWAPI::Client.new :
|
166
|
+
bw = BWAPI::Client.new grant_type: 'custom_grant_type'
|
166
167
|
expect(bw.grant_type).to eql('custom_grant_type')
|
167
168
|
end
|
168
169
|
end
|
@@ -173,7 +174,7 @@ describe BWAPI::Client do
|
|
173
174
|
end
|
174
175
|
|
175
176
|
it 'should allow a user to set a access_token value' do
|
176
|
-
bw = BWAPI::Client.new :
|
177
|
+
bw = BWAPI::Client.new access_token: 'abcdef-ghijkl-123456-789012'
|
177
178
|
expect(bw.access_token).to eql('abcdef-ghijkl-123456-789012')
|
178
179
|
end
|
179
180
|
end
|
@@ -184,7 +185,7 @@ describe BWAPI::Client do
|
|
184
185
|
end
|
185
186
|
|
186
187
|
it 'should allow a user to set a refresh_token value' do
|
187
|
-
bw = BWAPI::Client.new :
|
188
|
+
bw = BWAPI::Client.new refresh_token: 'abcdef-ghijkl-123456-789012'
|
188
189
|
expect(bw.refresh_token).to eql('abcdef-ghijkl-123456-789012')
|
189
190
|
end
|
190
191
|
end
|
@@ -195,11 +196,10 @@ describe BWAPI::Client do
|
|
195
196
|
end
|
196
197
|
|
197
198
|
it 'should allow a user to set a client_secret value' do
|
198
|
-
bw = BWAPI::Client.new :
|
199
|
+
bw = BWAPI::Client.new client_secret: 'custom_client_secret'
|
199
200
|
expect(bw.client_secret).to eql('custom_client_secret')
|
200
201
|
end
|
201
202
|
end
|
202
203
|
end
|
203
|
-
|
204
204
|
end
|
205
|
-
end
|
205
|
+
end
|