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.
Files changed (91) hide show
  1. checksums.yaml +8 -8
  2. data/.editorconfig +11 -0
  3. data/.rubocop.yml +17 -0
  4. data/.travis.yml +7 -3
  5. data/bin/bwapi +2 -1
  6. data/bwapi.gemspec +13 -10
  7. data/lib/bwapi.rb +6 -6
  8. data/lib/bwapi/authentication.rb +9 -17
  9. data/lib/bwapi/client.rb +5 -4
  10. data/lib/bwapi/client/admin.rb +6 -6
  11. data/lib/bwapi/client/admin/become.rb +4 -4
  12. data/lib/bwapi/client/admin/search.rb +9 -12
  13. data/lib/bwapi/client/admin/sub_clients.rb +8 -13
  14. data/lib/bwapi/client/admin/users.rb +7 -7
  15. data/lib/bwapi/client/admin/users/sharing.rb +5 -7
  16. data/lib/bwapi/client/brandwatch.rb +4 -4
  17. data/lib/bwapi/client/brandwatch/become.rb +4 -4
  18. data/lib/bwapi/client/brandwatch/client_modules.rb +5 -6
  19. data/lib/bwapi/client/client.rb +5 -6
  20. data/lib/bwapi/client/command_center.rb +3 -3
  21. data/lib/bwapi/client/command_center/client.rb +4 -4
  22. data/lib/bwapi/client/command_center/displays.rb +9 -9
  23. data/lib/bwapi/client/command_center/displays/events.rb +8 -8
  24. data/lib/bwapi/client/command_center/displays/messages.rb +7 -8
  25. data/lib/bwapi/client/command_center/displays/scenes.rb +9 -9
  26. data/lib/bwapi/client/command_center/displays/screens.rb +9 -9
  27. data/lib/bwapi/client/command_center/displays/users.rb +7 -8
  28. data/lib/bwapi/client/command_center/displays/users/access.rb +4 -5
  29. data/lib/bwapi/client/command_center/scene_types.rb +6 -6
  30. data/lib/bwapi/client/command_center/themes.rb +4 -4
  31. data/lib/bwapi/client/command_center/users.rb +6 -6
  32. data/lib/bwapi/client/command_center/users/access.rb +5 -5
  33. data/lib/bwapi/client/error_codes.rb +4 -4
  34. data/lib/bwapi/client/filters.rb +4 -4
  35. data/lib/bwapi/client/languages.rb +3 -3
  36. data/lib/bwapi/client/location.rb +5 -5
  37. data/lib/bwapi/client/logout.rb +12 -14
  38. data/lib/bwapi/client/me.rb +3 -3
  39. data/lib/bwapi/client/metrics.rb +3 -3
  40. data/lib/bwapi/client/oauth.rb +8 -8
  41. data/lib/bwapi/client/ping.rb +8 -8
  42. data/lib/bwapi/client/projects.rb +10 -10
  43. data/lib/bwapi/client/projects/bulkactions.rb +4 -4
  44. data/lib/bwapi/client/projects/bulkactions/author.rb +4 -3
  45. data/lib/bwapi/client/projects/bulkactions/mentions.rb +4 -3
  46. data/lib/bwapi/client/projects/categories.rb +6 -20
  47. data/lib/bwapi/client/projects/data.rb +4 -5
  48. data/lib/bwapi/client/projects/data/mentions.rb +7 -7
  49. data/lib/bwapi/client/projects/data/volume.rb +11 -11
  50. data/lib/bwapi/client/projects/data_download.rb +6 -7
  51. data/lib/bwapi/client/projects/demographics.rb +3 -4
  52. data/lib/bwapi/client/projects/facebook_queries.rb +8 -9
  53. data/lib/bwapi/client/projects/group.rb +2 -2
  54. data/lib/bwapi/client/projects/group/author_group.rb +8 -7
  55. data/lib/bwapi/client/projects/group/location_group.rb +7 -7
  56. data/lib/bwapi/client/projects/group/site_group.rb +7 -7
  57. data/lib/bwapi/client/projects/queries.rb +9 -10
  58. data/lib/bwapi/client/projects/queries/backfill.rb +6 -8
  59. data/lib/bwapi/client/projects/queries/date_range.rb +9 -9
  60. data/lib/bwapi/client/projects/queries/mentions.rb +5 -8
  61. data/lib/bwapi/client/projects/query_groups.rb +7 -9
  62. data/lib/bwapi/client/projects/rules.rb +7 -9
  63. data/lib/bwapi/client/projects/rules/backfill.rb +4 -4
  64. data/lib/bwapi/client/projects/rules/copy.rb +4 -4
  65. data/lib/bwapi/client/projects/sharing.rb +8 -9
  66. data/lib/bwapi/client/projects/signals.rb +5 -5
  67. data/lib/bwapi/client/projects/stream_dashboards.rb +10 -10
  68. data/lib/bwapi/client/projects/stream_dashboards/streams.rb +6 -7
  69. data/lib/bwapi/client/projects/summary.rb +5 -6
  70. data/lib/bwapi/client/projects/tags.rb +8 -9
  71. data/lib/bwapi/client/projects/twitter_queries.rb +7 -8
  72. data/lib/bwapi/client/projects/users.rb +4 -4
  73. data/lib/bwapi/client/projects/workflow.rb +4 -4
  74. data/lib/bwapi/client/query_validation.rb +7 -7
  75. data/lib/bwapi/client/sso.rb +4 -4
  76. data/lib/bwapi/client/test_search.rb +9 -8
  77. data/lib/bwapi/client/user.rb +6 -6
  78. data/lib/bwapi/client/user/notifications.rb +8 -8
  79. data/lib/bwapi/configuration.rb +6 -6
  80. data/lib/bwapi/connection.rb +10 -19
  81. data/lib/bwapi/error.rb +43 -36
  82. data/lib/bwapi/request.rb +24 -27
  83. data/lib/bwapi/version.rb +5 -2
  84. data/lib/faraday/response/brandwatch_error.rb +21 -22
  85. data/spec/bwapi/authentication_spec.rb +7 -7
  86. data/spec/bwapi/client_spec.rb +17 -17
  87. data/spec/bwapi_spec.rb +3 -3
  88. data/spec/fixtures/.netrc +1 -1
  89. data/spec/helper.rb +4 -2
  90. metadata +61 -4
  91. data/lib/faraday/utils/utils.rb +0 -26
@@ -1,10 +1,10 @@
1
+ # encoding: utf-8
1
2
  module BWAPI
2
3
  class Client
3
4
  module Projects
4
5
  module StreamDashboards
5
6
  # Streams module for projects/stream_dashboards/streams endpoints
6
7
  module Streams
7
-
8
8
  # Get all streams in a stream dashboard
9
9
  #
10
10
  # @param project_id [Integer] Id of project
@@ -12,7 +12,7 @@ module BWAPI
12
12
  # @option opts [Integer] page Page of results to retrieve
13
13
  # @option opts [Integer] pageSize Results per page of results
14
14
  # @return [Hashie::Mash] All stream dashboards for project
15
- def get_streams project_id, stream_dashboard_id
15
+ def get_streams(project_id, stream_dashboard_id)
16
16
  get "projects/#{project_id}/streamDashboards/#{stream_dashboard_id}/streams"
17
17
  end
18
18
 
@@ -22,7 +22,7 @@ module BWAPI
22
22
  # @param stream_dashboard_id [Integer] Id of stream dashboard
23
23
  # @param stream_id [Integer] Id of the stream
24
24
  # @return [Hashie::Mash] Specific stream
25
- def get_stream project_id, stream_dashboard_id, stream_id
25
+ def get_stream(project_id, stream_dashboard_id, stream_id)
26
26
  get "projects/#{project_id}/streamDashboards/#{stream_dashboard_id}/streams/#{stream_id}"
27
27
  end
28
28
 
@@ -38,7 +38,7 @@ module BWAPI
38
38
  # @option opts [String] settings Settings of the stream
39
39
  # @option opts [String] lastModified Last modification date of stream
40
40
  # @return [Hashie::Mash] Specific stream
41
- def create_stream project_id, stream_dashboard_id, opts={}
41
+ def create_stream(project_id, stream_dashboard_id, opts = {})
42
42
  post "projects/#{project_id}/streamDashboards/#{stream_dashboard_id}/streams", opts
43
43
  end
44
44
 
@@ -55,7 +55,7 @@ module BWAPI
55
55
  # @option opts [String] settings Settings of the stream
56
56
  # @option opts [String] lastModified Last modification date of stream
57
57
  # @return [Hashie::Mash] Updated stream
58
- def update_stream project_id, stream_dashboard_id, stream_id, opts={}
58
+ def update_stream(project_id, stream_dashboard_id, stream_id, opts = {})
59
59
  put "projects/#{project_id}/streamDashboards/#{stream_dashboard_id}/streams/#{stream_id}", opts
60
60
  end
61
61
 
@@ -65,10 +65,9 @@ module BWAPI
65
65
  # @param stream_dashboard_id [Integer] Id of stream dashboard
66
66
  # @param stream_id [Integer] Id of the stream
67
67
  # @return [Hashie::Mash] Deleted stream
68
- def delete_stream project_id, stream_dashboard_id, stream_id
68
+ def delete_stream(project_id, stream_dashboard_id, stream_id)
69
69
  delete "projects/#{project_id}/streamDashboards/#{stream_dashboard_id}/streams/#{stream_id}"
70
70
  end
71
-
72
71
  end
73
72
  end
74
73
  end
@@ -1,9 +1,10 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  module Projects
4
6
  # Summary module for projects/summary endpoints
5
7
  module Summary
6
-
7
8
  # Summary of projects
8
9
  #
9
10
  # @param opts [Hash] options hash of parameters
@@ -11,12 +12,10 @@ module BWAPI
11
12
  # @option opts [Integer] pageSize Results per page of results
12
13
  # @option opts [String] :filter Filter to apply to the query
13
14
  # @return [Hashie::Mash] Project summary information
14
- def projects_summary opts={}
15
- get "projects/summary", opts
15
+ def projects_summary(opts = {})
16
+ get 'projects/summary', opts
16
17
  end
17
- alias :summary :projects_summary
18
-
19
18
  end
20
19
  end
21
20
  end
22
- end
21
+ end
@@ -1,16 +1,17 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  module Projects
4
6
  # Tags module for projects/tags endpoints
5
7
  module Tags
6
-
7
8
  # Get all tags in project
8
9
  #
9
10
  # @param project_id [Integer] Id of project
10
11
  # @option opts [Integer] page Page of projects to retrieve
11
12
  # @option opts [Integer] pageSize Results per page of results
12
13
  # @return [Hashie::Mash] All tags in project
13
- def tags project_id, opts={}
14
+ def tags(project_id, opts = {})
14
15
  get "projects/#{project_id}/tags", opts
15
16
  end
16
17
 
@@ -19,10 +20,9 @@ module BWAPI
19
20
  # @param project_id [Integer] Id of project
20
21
  # @param tag_id [Integer] Id of tag
21
22
  # @return [Hashie::Mash] Specific tag
22
- def get_tag project_id, tag_id
23
+ def get_tag(project_id, tag_id)
23
24
  get "projects/#{project_id}/tags/#{tag_id}"
24
25
  end
25
- alias :tag :get_tag
26
26
 
27
27
  # Create a new tag in project
28
28
  #
@@ -31,7 +31,7 @@ module BWAPI
31
31
  # @option opts [Integer] id Id of the tag
32
32
  # @option opts [String] name Name of the tag
33
33
  # @return [Hashie::Mash] New tag
34
- def create_tag project_id, opts={}
34
+ def create_tag(project_id, opts = {})
35
35
  post "projects/#{project_id}/tags", opts
36
36
  end
37
37
 
@@ -43,7 +43,7 @@ module BWAPI
43
43
  # @option opts [Integer] id Id of the tag
44
44
  # @option opts [String] name Name of the tag
45
45
  # @return [Hashie::Mash] Updated tag
46
- def update_tag project_id, tag_id, opts={}
46
+ def update_tag(project_id, tag_id, opts = {})
47
47
  put "projects/#{project_id}/tags/#{tag_id}", opts
48
48
  end
49
49
 
@@ -52,11 +52,10 @@ module BWAPI
52
52
  # @param project_id [Integer] Id of project
53
53
  # @param tag_id [Integer] Id of tag
54
54
  # @return [Hashie::Mash] Deleted tag
55
- def delete_tag project_id, tag_id
55
+ def delete_tag(project_id, tag_id)
56
56
  delete "projects/#{project_id}/tags/#{tag_id}"
57
57
  end
58
-
59
58
  end
60
59
  end
61
60
  end
62
- end
61
+ end
@@ -1,14 +1,15 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  module Projects
4
6
  # TwitterQueries module for projects/twitterqueries endpoints
5
7
  module TwitterQueries
6
-
7
8
  # Get all twitter queries in a project
8
9
  #
9
10
  # @param project_id [Integer] Id of project
10
11
  # @return [Hashie::Mash] All twitter queries in project
11
- def twitter_queries project_id
12
+ def twitter_queries(project_id)
12
13
  get "projects/#{project_id}/twitterqueries"
13
14
  end
14
15
 
@@ -17,10 +18,9 @@ module BWAPI
17
18
  # @param project_id [Integer] Id of project
18
19
  # @param query_id [Integer] Id of twitter query
19
20
  # @return [Hashie::Mash] Specific twitter query
20
- def get_twitter_query project_id, query_id
21
+ def get_twitter_query(project_id, query_id)
21
22
  get "projects/#{project_id}/twitterqueries/#{query_id}"
22
23
  end
23
- alias :twitter_query :get_twitter_query
24
24
 
25
25
  # Create a twitter query in a project
26
26
  #
@@ -46,7 +46,7 @@ module BWAPI
46
46
  # @option opts [String] twitterLimit Twitter limit
47
47
  # @option opts [String] twitterScreenName Twitter screen name
48
48
  # @return [Hashie::Mash] New twitter query
49
- def create_twitter_query project_id, opts={}
49
+ def create_twitter_query(project_id, opts = {})
50
50
  post "projects/#{project_id}/twitterqueries", opts
51
51
  end
52
52
 
@@ -75,11 +75,10 @@ module BWAPI
75
75
  # @option opts [String] twitterLimit Twitter limit
76
76
  # @option opts [String] twitterScreenName Twitter screen name
77
77
  # @return [Hashie::Mash] Updated twitter query
78
- def update_twitter_query project_id, query_id, opts={}
78
+ def update_twitter_query(project_id, query_id, opts = {})
79
79
  put "projects/#{project_id}/twitterqueries/#{query_id}", opts
80
80
  end
81
-
82
81
  end
83
82
  end
84
83
  end
85
- end
84
+ end
@@ -1,18 +1,18 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  module Projects
4
6
  # Users module for projects/users endpoint
5
7
  module Users
6
-
7
8
  # Get all users shared with project
8
9
  #
9
10
  # @param project_id [Integer] Id of project
10
11
  # @return [Hashie::Mash] All users shared to project
11
- def project_users project_id
12
+ def project_users(project_id)
12
13
  get "projects/#{project_id}/users"
13
14
  end
14
-
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -1,18 +1,18 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  module Projects
4
6
  # Workflow module for projects/workflow endpoint
5
7
  module Workflow
6
-
7
8
  # Get all workflow categories for project
8
9
  #
9
10
  # @param project_id [Integer] Id of project
10
11
  # @return [Hashie::Mash] Workflow categories for project
11
- def workflow project_id
12
+ def workflow(project_id)
12
13
  get "projects/#{project_id}/workflow"
13
14
  end
14
-
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -1,16 +1,17 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  # QueryValidation module for queryValidation endpoints
4
6
  module QueryValidation
5
-
6
7
  # Check to see if a query string is valid
7
8
  #
8
9
  # @param opts [Hash] options hash of parameters
9
10
  # @option opts [String] query Query string
10
11
  # @option opts [Array] language Languages for query string
11
12
  # @return [Hashie::Mash] Query string validation results
12
- def query_validation opts={}
13
- get "query-validation", opts
13
+ def query_validation(opts = {})
14
+ get 'query-validation', opts
14
15
  end
15
16
 
16
17
  # Check to see if a search within query string is valid
@@ -19,10 +20,9 @@ module BWAPI
19
20
  # @option opts [String] query Query string
20
21
  # @option opts [Array] language Languages for query string
21
22
  # @return [Hashie::Mash] Query string validation results
22
- def search_within opts={}
23
- get "query-validation/searchwithin", opts
23
+ def search_within(opts = {})
24
+ get 'query-validation/searchwithin', opts
24
25
  end
25
-
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -1,8 +1,9 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  # SSO module for sso endpoint
4
6
  module SSO
5
-
6
7
  # Authorize another user for access
7
8
  #
8
9
  # @note must have sso oauth_token
@@ -10,10 +11,9 @@ module BWAPI
10
11
  #
11
12
  # @param user_id [Integer] The user id
12
13
  # @return [Hashie::Mash] User authorization
13
- def sso user_id
14
+ def sso(user_id)
14
15
  get "sso/#{user_id}"
15
16
  end
16
-
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -1,15 +1,16 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  # TestSearch module for testSearch endpoint
4
6
  module TestSearch
5
-
6
- # TODO: Uncomment once the endpoint has been fixed
7
7
  # Retrieve full text for a given url
8
- #def test_search_content opts
9
- # get "testsearch/content", opts
10
- #end
11
- #alias :test_search :test_search_content
12
-
8
+ # @param opts [Hash] options hash of parameters
9
+ # @option opts [String] url the url to test search
10
+ # @return [Hashie::Mash] full text of the url
11
+ def test_search_content(opts = {})
12
+ get 'testsearch/content', opts
13
+ end
13
14
  end
14
15
  end
15
- end
16
+ end
@@ -1,15 +1,16 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'bwapi/client/user/notifications'
2
4
 
3
5
  module BWAPI
4
6
  class Client
5
7
  # User module for user endpoints and helper methods
6
8
  module User
7
-
8
9
  # Get the current user
9
10
  #
10
11
  # @return [Hashie::Mash] User information
11
12
  def user
12
- get "user"
13
+ get 'user'
13
14
  end
14
15
 
15
16
  # Update the current user
@@ -34,8 +35,8 @@ module BWAPI
34
35
  # @option opts [String] mobile The users mobile number
35
36
  # @option opts [Date] creationDate Date the user was created on
36
37
  # @return [Hashie::Mash] Updated user information
37
- def update_user opts={}
38
- put "user", opts
38
+ def update_user(opts = {})
39
+ put 'user', opts
39
40
  end
40
41
 
41
42
  # Get users api role
@@ -53,7 +54,6 @@ module BWAPI
53
54
  end
54
55
 
55
56
  include BWAPI::Client::User::Notifications
56
-
57
57
  end
58
58
  end
59
- end
59
+ end
@@ -1,17 +1,18 @@
1
+ # encoding: utf-8
2
+
1
3
  module BWAPI
2
4
  class Client
3
5
  module User
4
6
  # Notifications module for projects/notifications endpoints
5
7
  module Notifications
6
-
7
8
  # Get the current user notifications
8
9
  #
9
10
  # @param opts [Hash] options hash of parameters
10
11
  # @option opts [Integer] page Page of projects to retrieve
11
12
  # @option opts [Integer] pageSize Results per page of results
12
13
  # @return [Hashie::Mash] User notifications
13
- def notifications opts={}
14
- get "user/notifications", opts
14
+ def notifications(opts = {})
15
+ get 'user/notifications', opts
15
16
  end
16
17
 
17
18
  # Update users existing notifications
@@ -19,19 +20,18 @@ module BWAPI
19
20
  # @param opts [Hash] options Hash of parameters
20
21
  # @option opts [Array] list User notifications to be edited
21
22
  # @return [Hashie::Mash] Updated user notifications
22
- def update_notification opts={}
23
- put "user/notifications", opts
23
+ def update_notification(opts = {})
24
+ put 'user/notifications', opts
24
25
  end
25
26
 
26
27
  # Delete a users existing notification
27
28
  #
28
29
  # @param notification_id [Integer] Id of notification
29
30
  # @return [Hashie::Mash] Deleted user notifications
30
- def delete_notification notification_id
31
+ def delete_notification(notification_id)
31
32
  delete "user/notifications/#{notification_id}"
32
33
  end
33
-
34
34
  end
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -1,10 +1,11 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'logger'
2
4
  require 'faraday'
3
5
 
4
6
  module BWAPI
5
7
  # Configuration module to set default and custom client credentials
6
8
  module Configuration
7
-
8
9
  OPTION_KEYS = [
9
10
  :api_endpoint,
10
11
  :user_agent,
@@ -29,9 +30,9 @@ module BWAPI
29
30
  DEFAULT_CLIENT_ID = 'brandwatch-api-client'
30
31
  DEFAULT_USER_AGENT = "BWAPI Ruby Gem #{BWAPI::VERSION}".freeze
31
32
  DEFAULT_NETRC_FILE = File.join(ENV['HOME'], '.netrc')
32
- DEFAULT_LOGGER_FILE = Logger.new("#{Dir::pwd}/bwapi.log")
33
+ DEFAULT_LOGGER_FILE = Logger.new("#{Dir.pwd}/bwapi.log")
33
34
 
34
- attr_accessor *OPTION_KEYS
35
+ attr_accessor(*OPTION_KEYS)
35
36
 
36
37
  # Extend hook
37
38
  def self.extended(base)
@@ -45,7 +46,7 @@ module BWAPI
45
46
 
46
47
  # Convert option_keys to hash and return
47
48
  def options
48
- OPTION_KEYS.inject({}){|o,k|o.merge!(k => send(k))}
49
+ OPTION_KEYS.reduce({}) { |a, e| a.merge!(e => send(e)) }
49
50
  end
50
51
 
51
52
  # Reset the configuration options
@@ -66,6 +67,5 @@ module BWAPI
66
67
  self.debug = false
67
68
  self.log = DEFAULT_LOGGER_FILE
68
69
  end
69
-
70
70
  end
71
- end
71
+ end