bwapi 10.0.0 → 11.0.0.pre.550

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +13 -5
  2. data/.editorconfig +1 -1
  3. data/.gitignore +1 -1
  4. data/lib/bwapi/client.rb +26 -3
  5. data/lib/bwapi/client/admin.rb +2 -0
  6. data/lib/bwapi/client/admin/demographics.rb +17 -0
  7. data/lib/bwapi/client/aggregates.rb +13 -0
  8. data/lib/bwapi/client/author.rb +56 -0
  9. data/lib/bwapi/client/brandwatch.rb +6 -0
  10. data/lib/bwapi/client/brandwatch/become.rb +0 -2
  11. data/lib/bwapi/client/brandwatch/clients.rb +2 -8
  12. data/lib/bwapi/client/brandwatch/clients/command_center.rb +20 -0
  13. data/lib/bwapi/client/brandwatch/clients/command_center/limits.rb +33 -0
  14. data/lib/bwapi/client/brandwatch/clients/command_center/scene_types.rb +26 -0
  15. data/lib/bwapi/client/brandwatch/clients/command_center/themes.rb +26 -0
  16. data/lib/bwapi/client/brandwatch/clients/command_center/users.rb +30 -0
  17. data/lib/bwapi/client/brandwatch/clients/command_center/users/access.rb +28 -0
  18. data/lib/bwapi/client/brandwatch/clients/users.rb +0 -2
  19. data/lib/bwapi/client/brandwatch/command_center.rb +14 -0
  20. data/lib/bwapi/client/brandwatch/command_center/scene_types.rb +31 -0
  21. data/lib/bwapi/client/brandwatch/command_center/themes.rb +17 -0
  22. data/lib/bwapi/client/brandwatch/log_level.rb +17 -0
  23. data/lib/bwapi/client/brandwatch/price_structures.rb +45 -0
  24. data/lib/bwapi/client/brandwatch/usage_report.rb +19 -0
  25. data/lib/bwapi/client/command_center.rb +12 -0
  26. data/lib/bwapi/client/command_center/category_colours.rb +15 -0
  27. data/lib/bwapi/client/command_center/colour_palette.rb +22 -0
  28. data/lib/bwapi/client/command_center/display_access.rb +12 -0
  29. data/lib/bwapi/client/command_center/display_access/users.rb +14 -0
  30. data/lib/bwapi/client/command_center/display_access/users/access.rb +21 -0
  31. data/lib/bwapi/client/command_center/displays/scenes.rb +1 -1
  32. data/lib/bwapi/client/command_center/projects.rb +16 -0
  33. data/lib/bwapi/client/command_center/projects/category_colours.rb +45 -0
  34. data/lib/bwapi/client/command_center/projects/data.rb +21 -0
  35. data/lib/bwapi/client/command_center/projects/tag_colours.rb +45 -0
  36. data/lib/bwapi/client/command_center/query_colours.rb +36 -0
  37. data/lib/bwapi/client/command_center/scene_types.rb +3 -3
  38. data/lib/bwapi/client/command_center/tag_colours.rb +15 -0
  39. data/lib/bwapi/client/dimensions.rb +13 -0
  40. data/lib/bwapi/client/oauth.rb +2 -1
  41. data/lib/bwapi/client/projects.rb +13 -11
  42. data/lib/bwapi/client/projects/{bulkactions.rb → bulk_actions.rb} +2 -2
  43. data/lib/bwapi/client/projects/{bulkactions → bulk_actions}/author.rb +0 -0
  44. data/lib/bwapi/client/projects/{bulkactions → bulk_actions}/mentions.rb +0 -0
  45. data/lib/bwapi/client/projects/data.rb +20 -0
  46. data/lib/bwapi/client/projects/data/audience.rb +21 -0
  47. data/lib/bwapi/client/projects/data/audience_activity.rb +21 -0
  48. data/lib/bwapi/client/projects/data/channel_metrics.rb +21 -0
  49. data/lib/bwapi/client/projects/data/emoticons.rb +23 -0
  50. data/lib/bwapi/client/projects/data/hashtags.rb +23 -0
  51. data/lib/bwapi/client/projects/data/headlines.rb +20 -0
  52. data/lib/bwapi/client/projects/data/impressions.rb +21 -0
  53. data/lib/bwapi/client/projects/data/mentioned_authors.rb +23 -0
  54. data/lib/bwapi/client/projects/data/mentions.rb +32 -2
  55. data/lib/bwapi/client/projects/data/owner_activity.rb +21 -0
  56. data/lib/bwapi/client/projects/data/urls.rb +23 -0
  57. data/lib/bwapi/client/projects/query/mentionfind.rb +21 -0
  58. data/lib/bwapi/client/projects/signals/groups.rb +18 -5
  59. data/lib/bwapi/client/user.rb +2 -0
  60. data/lib/bwapi/client/user/instagram_credentials.rb +32 -0
  61. data/lib/bwapi/configuration.rb +3 -2
  62. data/lib/bwapi/default.rb +7 -3
  63. data/lib/bwapi/error.rb +0 -2
  64. data/lib/bwapi/version.rb +1 -1
  65. data/spec/bwapi/client_spec.rb +29 -167
  66. data/spec/bwapi/configuration_spec.rb +499 -0
  67. data/spec/bwapi/default_spec.rb +242 -0
  68. metadata +72 -30
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6d9f016e4bc3be418b87ee218885361211367513
4
- data.tar.gz: 85912ea24c6d2f4de96252032a1a03af8abb1940
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmE0Zjc0MzMxYWQ3YTYxZjUxYTA3Njg0OGViNzQ4ZDc2YzEwYjRlYw==
5
+ data.tar.gz: !binary |-
6
+ ZWMwNjk4YzI5ZTViMzYzM2M1MmNhMGEzZjY0OTI1ODYyYWQ3OTE3ZA==
5
7
  SHA512:
6
- metadata.gz: 0b5b7ef979fe845621032300dc9cb279875be0eb77c275c20ab353ed86dc767f088082d2eb8752d44c6a76448f4af17eea8eb12873a6e84132d894a6564725ae
7
- data.tar.gz: de0ca9c16a38db3acba187739fcc75d1c8d1b7a4a657eb333031a407db5bd914dbdc1924b3182df10189ec1d3a4eb967ab2e9f22f02502b0b066d787e7d5b583
8
+ metadata.gz: !binary |-
9
+ OWE2NDQ3YWI0YzY4NzYxMTc1MGNjMDM2ZDM0MTE2MDAwNmM0YjMzMTYwYjVm
10
+ OTc3Nzg2M2Y4ZWZmZmQwMTE4YzYyNjQ2MjIxZDgwMmZkY2JlMjIwZGE4ODMw
11
+ YTkyNGFmNDdhYTQxN2QyM2JhZjI1NTQ2N2Y4NzBjNzNhZDYzNjc=
12
+ data.tar.gz: !binary |-
13
+ NzZjM2MxYWZmNmJhYjlmN2RkMDU3NjdmZTYyNDI3Yzk5YzFhZDA4ZmFiODgw
14
+ ODQzZmNjNmMyZDE3MjcwODhmYTVlYjAxNDkyODU4ZmMyN2VkNDgyNTcwOTRi
15
+ ZGEyYWI1ZjA4NGVkY2Y0ZjMzNTZjYTE5NmFjZWFjMjE1MzNkYjU=
@@ -7,5 +7,5 @@ insert_final_newline = true
7
7
  trim_trailing_whitespace = true
8
8
 
9
9
  [*.rb]
10
- indent_style = spaces
10
+ indent_style = space
11
11
  indent_size = 2
data/.gitignore CHANGED
@@ -2,7 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
- .idea
5
+ .idea/
6
6
  coverage
7
7
  InstalledFiles
8
8
  lib/bundler/man
@@ -4,9 +4,12 @@ require 'bwapi/request'
4
4
  require 'bwapi/performance'
5
5
 
6
6
  require 'bwapi/client/admin'
7
+ require 'bwapi/client/aggregates'
8
+ require 'bwapi/client/author'
7
9
  require 'bwapi/client/brandwatch'
8
10
  require 'bwapi/client/client'
9
11
  require 'bwapi/client/command_center'
12
+ require 'bwapi/client/dimensions'
10
13
  require 'bwapi/client/error_codes'
11
14
  require 'bwapi/client/filters'
12
15
  require 'bwapi/client/languages'
@@ -16,9 +19,9 @@ require 'bwapi/client/me'
16
19
  require 'bwapi/client/metrics'
17
20
  require 'bwapi/client/oauth'
18
21
  require 'bwapi/client/ping'
19
- require 'bwapi/client/sso'
20
22
  require 'bwapi/client/projects'
21
23
  require 'bwapi/client/query_validation'
24
+ require 'bwapi/client/sso'
22
25
  require 'bwapi/client/test_search'
23
26
  require 'bwapi/client/user'
24
27
  require 'faraday'
@@ -32,9 +35,12 @@ module BWAPI
32
35
  include BWAPI::Performance
33
36
 
34
37
  include BWAPI::Client::Admin
38
+ include BWAPI::Client::Aggregates
39
+ include BWAPI::Client::Author
35
40
  include BWAPI::Client::Brandwatch
36
41
  include BWAPI::Client::Client
37
42
  include BWAPI::Client::CommandCenter
43
+ include BWAPI::Client::Dimensions
38
44
  include BWAPI::Client::ErrorCodes
39
45
  include BWAPI::Client::Filters
40
46
  include BWAPI::Client::Languages
@@ -45,8 +51,8 @@ module BWAPI
45
51
  include BWAPI::Client::OAuth
46
52
  include BWAPI::Client::Ping
47
53
  include BWAPI::Client::Projects
48
- include BWAPI::Client::SSO
49
54
  include BWAPI::Client::QueryValidation
55
+ include BWAPI::Client::SSO
50
56
  include BWAPI::Client::TestSearch
51
57
  include BWAPI::Client::User
52
58
 
@@ -59,11 +65,19 @@ module BWAPI
59
65
  end
60
66
  end
61
67
 
68
+ # Check is access token has expired
69
+ #
70
+ # @return [Boolean] access token expiry status
71
+ def access_token_expired?
72
+ return true if @access_token.nil? || @access_token_expiry.nil?
73
+ seconds_until_access_token_expires <= 0
74
+ end
75
+
62
76
  # Check if user is authenicated
63
77
  #
64
78
  # @return [Boolean] Authenticated status
65
79
  def authenticated?
66
- @access_token ? true : false
80
+ (@access_token && !access_token_expired?) ? true : false
67
81
  end
68
82
 
69
83
  # Check if user is a brandwatch-application-client type
@@ -109,5 +123,14 @@ module BWAPI
109
123
  reset_connection
110
124
  @verify_ssl = value
111
125
  end
126
+
127
+ private
128
+
129
+ # Returns the number of seconds until the access token expires
130
+ #
131
+ # @return [Integer] seconds until expiry
132
+ def seconds_until_access_token_expires
133
+ DateTime.parse(@access_token_expiry).to_time.to_i - Time.now.to_i
134
+ end
112
135
  end
113
136
  end
@@ -1,4 +1,5 @@
1
1
  require 'bwapi/client/admin/become'
2
+ require 'bwapi/client/admin/demographics'
2
3
  require 'bwapi/client/admin/search'
3
4
  require 'bwapi/client/admin/clients/sub_clients'
4
5
  require 'bwapi/client/admin/clients/users'
@@ -27,6 +28,7 @@ module BWAPI
27
28
  end
28
29
 
29
30
  include BWAPI::Client::Admin::Become
31
+ include BWAPI::Client::Admin::Demographics
30
32
  include BWAPI::Client::Admin::Search
31
33
  include BWAPI::Client::Admin::Clients::SubClients
32
34
  include BWAPI::Client::Admin::Clients::Users
@@ -0,0 +1,17 @@
1
+ module BWAPI
2
+ class Client
3
+ module Admin
4
+ # Demographics module for admin/demographics endpoints
5
+ module Demographics
6
+ # Get the classification of an author by author description
7
+ #
8
+ # @param opts [Hash] options hash of parameters
9
+ # @option opts [String] description of the author
10
+ # @return [Hash] Classification of an author
11
+ def classify_author(opts = {})
12
+ get 'admin/demographics/classify', opts
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module BWAPI
2
+ class Client
3
+ # Aggregates module for aggregates endpoints
4
+ module Aggregates
5
+ # Get the list of current aggregate dimensions
6
+ #
7
+ # @return [Array] All aggregates
8
+ def aggregates
9
+ get 'aggregates'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,56 @@
1
+ module BWAPI
2
+ class Client
3
+ # Author module for author endpoints
4
+ module Author
5
+ # Gets all author professions
6
+ #
7
+ # @param opts [Hash] options hash of parameters
8
+ # @option opts [Integer] page Page of results to retrieve
9
+ # @option opts [Integer] pageSize Results per page of results
10
+ # @return [Hash] All author professions
11
+ def author_professions(opts = {})
12
+ get 'authors/professions', opts
13
+ end
14
+
15
+ # Gets all author interests
16
+ #
17
+ # @param opts [Hash] options hash of parameters
18
+ # @option opts [Integer] page Page of results to retrieve
19
+ # @option opts [Integer] pageSize Results per page of results
20
+ # @return [Hash] All author interests
21
+ def author_interests(opts = {})
22
+ get 'authors/interests', opts
23
+ end
24
+
25
+ # Get an Author with its associated accounts using an account name/domain tuple
26
+ #
27
+ # @param name [String] Account username
28
+ # @param opts [Hash] options hash of parameters
29
+ # @option opts [String] domain Account domain
30
+ # @return [Hash] Author
31
+ def get_author(name, opts = {})
32
+ get "authors/#{name}", opts
33
+ end
34
+
35
+ # Update an Author using an account name/domain tuple
36
+ #
37
+ # @param name [String] Account username
38
+ # @param opts [Hash] options hash of parameters
39
+ # @option opts [String] accountType Account type of Author Patch
40
+ # @option opts [Array] addInterests Interests to add of Author Patch
41
+ # @option opts [Array] addProfessions Professions to add of Author Patch
42
+ # @option opts [String] domain Domain of Author Patch
43
+ # @option opts [String] gender Gender of Author Patch
44
+ # @option opts [Integer] projectId Project ID of Author Patch
45
+ # @option opts [Integer] queryId Query ID of Author Patch
46
+ # @option opts [Array] removeInterests Interests to remove of Author Patch
47
+ # @option opts [Array] removeProfessions Professions to remove of Author Patch
48
+ # @option opts [Integer] resourceId Resource ID of Author Patch
49
+ # @option opts [String] username Username of Author to be patched
50
+ # @return [Hash] Updated author
51
+ def update_author(name, opts = {})
52
+ patch "authors/#{name}", opts
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,5 +1,8 @@
1
1
  require 'bwapi/client/brandwatch/become'
2
2
  require 'bwapi/client/brandwatch/clients'
3
+ require 'bwapi/client/brandwatch/log_level'
4
+ require 'bwapi/client/brandwatch/price_structures'
5
+ require 'bwapi/client/brandwatch/usage_report'
3
6
 
4
7
  module BWAPI
5
8
  class Client
@@ -26,6 +29,9 @@ module BWAPI
26
29
 
27
30
  include BWAPI::Client::Brandwatch::Become
28
31
  include BWAPI::Client::Brandwatch::Clients
32
+ include BWAPI::Client::Brandwatch::LogLevel
33
+ include BWAPI::Client::Brandwatch::PriceStructures
34
+ include BWAPI::Client::Brandwatch::UsageReport
29
35
  end
30
36
  end
31
37
  end
@@ -5,8 +5,6 @@ module BWAPI
5
5
  module Become
6
6
  # Become user
7
7
  #
8
- # @note must be a super admin user
9
- #
10
8
  # @param user_id [Integer] The user id
11
9
  # @return [Hash] User credentials
12
10
  def brandwatch_become(user_id)
@@ -1,3 +1,4 @@
1
+ require 'bwapi/client/brandwatch/clients/command_center'
1
2
  require 'bwapi/client/brandwatch/clients/users'
2
3
  require 'bwapi/client/brandwatch/clients/modules'
3
4
 
@@ -8,8 +9,6 @@ module BWAPI
8
9
  module Clients
9
10
  # Get specific clients
10
11
  #
11
- # @note must be a super admin user
12
- #
13
12
  # @param opts [Hash] options Hash of parameters
14
13
  # @options opts [String] nameContains Client name search (case insensitive)
15
14
  # @return [Hash] List of filtered clients
@@ -19,8 +18,6 @@ module BWAPI
19
18
 
20
19
  # Create a new parent client
21
20
  #
22
- # @note must be a super admin user
23
- #
24
21
  # @param opts [Hash] options Hash of parameters
25
22
  # @option opts [String] address1 Address line one of the client
26
23
  # @option opts [String] address2 Address line two of the client
@@ -56,8 +53,6 @@ module BWAPI
56
53
 
57
54
  # Get specific client
58
55
  #
59
- # @note must be a super admin user
60
- #
61
56
  # @param client_id [Integer] Id of the client
62
57
  # @return [Hash] Specific client
63
58
  def brandwatch_get_client(client_id)
@@ -66,8 +61,6 @@ module BWAPI
66
61
 
67
62
  # Update an existing parent client
68
63
  #
69
- # @note must be a super admin user
70
- #
71
64
  # @param client_id [Integer] Id of the client
72
65
  # @param opts [Hash] options Hash of parameters
73
66
  # @option opts [String] address1 Address line one of the client
@@ -102,6 +95,7 @@ module BWAPI
102
95
  put "brandwatch/clients/#{client_id}", opts
103
96
  end
104
97
 
98
+ include BWAPI::Client::Brandwatch::Clients::CommandCenter
105
99
  include BWAPI::Client::Brandwatch::Clients::Users
106
100
  include BWAPI::Client::Brandwatch::Clients::Modules
107
101
  end
@@ -0,0 +1,20 @@
1
+ require 'bwapi/client/brandwatch/clients/command_center/limits'
2
+ require 'bwapi/client/brandwatch/clients/command_center/scene_types'
3
+ require 'bwapi/client/brandwatch/clients/command_center/themes'
4
+ require 'bwapi/client/brandwatch/clients/command_center/users'
5
+
6
+ module BWAPI
7
+ class Client
8
+ module Brandwatch
9
+ module Clients
10
+ # CommandCenter module for brandwatch/client/{client_id}/commandcenter endpoints
11
+ module CommandCenter
12
+ include BWAPI::Client::Brandwatch::Clients::CommandCenter::Limits
13
+ include BWAPI::Client::Brandwatch::Clients::CommandCenter::SceneTypes
14
+ include BWAPI::Client::Brandwatch::Clients::CommandCenter::Themes
15
+ include BWAPI::Client::Brandwatch::Clients::CommandCenter::Users
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ module BWAPI
2
+ class Client
3
+ module Brandwatch
4
+ module Clients
5
+ module CommandCenter
6
+ # Limits module for brandwatch/client/{client_id}/commandcenter/limits endpoints
7
+ module Limits
8
+ # Fetch configured limits for a Vizia client
9
+ #
10
+ # TODO: Add parameters documentation
11
+ def brandwatch_vizia_limits(client_id)
12
+ get "/brandwatch/clients/#{client_id}/commandcenter/limits"
13
+ end
14
+
15
+ # Create limits for a Vizia client
16
+ #
17
+ # TODO: Add parameters documentation
18
+ def brandwatch_create_vizia_limits(client_id, opts = {})
19
+ post "/brandwatch/clients/#{client_id}/commandcenter/limits", opts
20
+ end
21
+
22
+ # Update limits for a Vizia client
23
+ #
24
+ # TODO: Add parameters documentation
25
+ def brandwatch_update_vizia_limits(client_id, opts = {})
26
+ put "/brandwatch/clients/#{client_id}/commandcenter/limits", opts
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ module BWAPI
2
+ class Client
3
+ module Brandwatch
4
+ module Clients
5
+ module CommandCenter
6
+ # SceneTypes module for brandwatch/client/{client_id}/commandcenter/scenetypes endpoints
7
+ module SceneTypes
8
+ # Fetch all scene types enabled for given client
9
+ #
10
+ # TODO: Add parameters documentation
11
+ def brandwatch_scene_types(client_id)
12
+ get "/brandwatch/clients/#{client_id}/commandcenter/scenetypes"
13
+ end
14
+
15
+ # Alter Vizia scene types enabled for client
16
+ #
17
+ # TODO: Add parameters documentation
18
+ def brandwatch_update_scene_type(client_id, opts = {})
19
+ put "/brandwatch/clients/#{client_id}/commandcenter/scenetypes", opts
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module BWAPI
2
+ class Client
3
+ module Brandwatch
4
+ module Clients
5
+ module CommandCenter
6
+ # Themes module for brandwatch/client/{client_id}/commandcenter/themes endpoints
7
+ module Themes
8
+ # Get Vizia themes enabled for client
9
+ #
10
+ # TODO: Add parameters documentation
11
+ def brandwatch_themes(client_id)
12
+ get "brandwatch/client/#{client_id}/commandcenter/themes"
13
+ end
14
+
15
+ # Alter Vizia themes enabled for client
16
+ #
17
+ # TODO: Add parameters documentation
18
+ def brandwatch_update_themes(client_id, opts = {})
19
+ get "brandwatch/client/#{client_id}/commandcenter/themes", opts
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ require 'bwapi/client/brandwatch/clients/command_center/users/access'
2
+
3
+ module BWAPI
4
+ class Client
5
+ module Brandwatch
6
+ module Clients
7
+ module CommandCenter
8
+ # Users module for brandwatch/client/{client_id}/commandcenter/users endpoints
9
+ module Users
10
+ # Fetch Vizia access levels for all users in client
11
+ #
12
+ # TODO: Add parameters documentation
13
+ def brandwatch_users_access_levels(client_id)
14
+ get "brandwatch/client/#{client_id}/commandcenter/users"
15
+ end
16
+
17
+ # Fetch a single user's Vizia access level
18
+ #
19
+ # TODO: Add parameters documentation
20
+ def brandwatch_user_access_level(client_id, user_id)
21
+ get "brandwatch/client/#{client_id}/commandcenter/users/#{user_id}"
22
+ end
23
+
24
+ include BWAPI::Client::Brandwatch::Clients::CommandCenter::Users::Access
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ module BWAPI
2
+ class Client
3
+ module Brandwatch
4
+ module Clients
5
+ module CommandCenter
6
+ module Users
7
+ # Access module for brandwatch/client/{client_id}/commandcenter/users/{user_id}/access endpoints
8
+ module Access
9
+ # Update a user's Vizia access level
10
+ #
11
+ # TODO: Add parameters documentation
12
+ def brandwatch_update_user_access_level(client_id, user_id, access_level)
13
+ put "brandwatch/client/#{client_id}/commandcenter/users/#{user_id}/access/#{access_level}"
14
+ end
15
+
16
+ # Revoke a user's Vizia access
17
+ #
18
+ # TODO: Add parameters documentation
19
+ def brandwatch_delete_user_access_level(client_id, user_id, access_level)
20
+ delete "brandwatch/client/#{client_id}/commandcenter/users/#{user_id}/access/#{access_level}"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end