bwapi 10.0.0.pre.549 → 10.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +5 -13
  2. data/.editorconfig +1 -1
  3. data/.gitignore +1 -1
  4. data/lib/bwapi/client.rb +3 -26
  5. data/lib/bwapi/client/admin.rb +0 -2
  6. data/lib/bwapi/client/brandwatch.rb +0 -6
  7. data/lib/bwapi/client/brandwatch/become.rb +2 -0
  8. data/lib/bwapi/client/brandwatch/clients.rb +8 -2
  9. data/lib/bwapi/client/brandwatch/clients/users.rb +2 -0
  10. data/lib/bwapi/client/command_center.rb +0 -12
  11. data/lib/bwapi/client/command_center/displays/scenes.rb +1 -1
  12. data/lib/bwapi/client/command_center/scene_types.rb +3 -3
  13. data/lib/bwapi/client/oauth.rb +1 -2
  14. data/lib/bwapi/client/projects.rb +11 -13
  15. data/lib/bwapi/client/projects/{bulk_actions.rb → bulkactions.rb} +2 -2
  16. data/lib/bwapi/client/projects/{bulk_actions → bulkactions}/author.rb +0 -0
  17. data/lib/bwapi/client/projects/{bulk_actions → bulkactions}/mentions.rb +0 -0
  18. data/lib/bwapi/client/projects/data.rb +0 -20
  19. data/lib/bwapi/client/projects/data/mentions.rb +2 -32
  20. data/lib/bwapi/client/projects/signals/groups.rb +5 -18
  21. data/lib/bwapi/client/user.rb +0 -2
  22. data/lib/bwapi/configuration.rb +2 -3
  23. data/lib/bwapi/default.rb +3 -7
  24. data/lib/bwapi/error.rb +2 -0
  25. data/spec/bwapi/client_spec.rb +167 -29
  26. metadata +30 -72
  27. data/lib/bwapi/client/admin/demographics.rb +0 -17
  28. data/lib/bwapi/client/aggregates.rb +0 -13
  29. data/lib/bwapi/client/author.rb +0 -56
  30. data/lib/bwapi/client/brandwatch/clients/command_center.rb +0 -20
  31. data/lib/bwapi/client/brandwatch/clients/command_center/limits.rb +0 -33
  32. data/lib/bwapi/client/brandwatch/clients/command_center/scene_types.rb +0 -26
  33. data/lib/bwapi/client/brandwatch/clients/command_center/themes.rb +0 -26
  34. data/lib/bwapi/client/brandwatch/clients/command_center/users.rb +0 -30
  35. data/lib/bwapi/client/brandwatch/clients/command_center/users/access.rb +0 -28
  36. data/lib/bwapi/client/brandwatch/command_center.rb +0 -14
  37. data/lib/bwapi/client/brandwatch/command_center/scene_types.rb +0 -31
  38. data/lib/bwapi/client/brandwatch/command_center/themes.rb +0 -17
  39. data/lib/bwapi/client/brandwatch/log_level.rb +0 -17
  40. data/lib/bwapi/client/brandwatch/price_structures.rb +0 -45
  41. data/lib/bwapi/client/brandwatch/usage_report.rb +0 -19
  42. data/lib/bwapi/client/command_center/category_colours.rb +0 -15
  43. data/lib/bwapi/client/command_center/colour_palette.rb +0 -22
  44. data/lib/bwapi/client/command_center/display_access.rb +0 -12
  45. data/lib/bwapi/client/command_center/display_access/users.rb +0 -14
  46. data/lib/bwapi/client/command_center/display_access/users/access.rb +0 -21
  47. data/lib/bwapi/client/command_center/projects.rb +0 -16
  48. data/lib/bwapi/client/command_center/projects/category_colours.rb +0 -45
  49. data/lib/bwapi/client/command_center/projects/data.rb +0 -21
  50. data/lib/bwapi/client/command_center/projects/tag_colours.rb +0 -45
  51. data/lib/bwapi/client/command_center/query_colours.rb +0 -36
  52. data/lib/bwapi/client/command_center/tag_colours.rb +0 -15
  53. data/lib/bwapi/client/dimensions.rb +0 -13
  54. data/lib/bwapi/client/projects/data/audience.rb +0 -21
  55. data/lib/bwapi/client/projects/data/audience_activity.rb +0 -21
  56. data/lib/bwapi/client/projects/data/channel_metrics.rb +0 -21
  57. data/lib/bwapi/client/projects/data/emoticons.rb +0 -23
  58. data/lib/bwapi/client/projects/data/hashtags.rb +0 -23
  59. data/lib/bwapi/client/projects/data/headlines.rb +0 -20
  60. data/lib/bwapi/client/projects/data/impressions.rb +0 -21
  61. data/lib/bwapi/client/projects/data/mentioned_authors.rb +0 -23
  62. data/lib/bwapi/client/projects/data/owner_activity.rb +0 -21
  63. data/lib/bwapi/client/projects/data/urls.rb +0 -23
  64. data/lib/bwapi/client/projects/query/mentionfind.rb +0 -21
  65. data/lib/bwapi/client/user/instagram_credentials.rb +0 -32
  66. data/spec/bwapi/configuration_spec.rb +0 -499
  67. data/spec/bwapi/default_spec.rb +0 -242
@@ -1,23 +0,0 @@
1
- module BWAPI
2
- class Client
3
- module Projects
4
- module Data
5
- # Urls module for the /projects/{project_id}/data/urls endpoint
6
- module Urls
7
- # Get top n urls
8
- #
9
- # @param project_id [Integer] Id of project
10
- # @param opts [Hash] options hash of parameters
11
- # @option opts [Hash] filter The filters to apply
12
- # @option opts [Integer] limit The limit to return
13
- # @option opts [String] orderBy Parameter to sort by
14
- # @option opts [String] orderDirection Direction of sort
15
- # @return [array] top n twitter urls based on parameter passed
16
- def data_urls(project_id, opts = {})
17
- get "/projects/#{project_id}/data/urls", opts
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- module BWAPI
2
- class Client
3
- module Projects
4
- module Query
5
- # mentionfind module for projects/project_id/query/query_id/mentionfind endpoint
6
- module MentionFind
7
- # Returns the mention for a specific URL
8
- #
9
- # @param project_id [Integer] Id of project
10
- # @param query id [Integer] Id of the query
11
- # @param opts [hash] options Hash of parameters
12
- # @option opts [string] URL of the mention
13
- # @return [Hash] Returns whether a URL is in a query
14
- def mention_find(project_id, query_id, opts = {})
15
- get "projects/#{project_id}/query/#{query_id}/mentionfind", opts
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,32 +0,0 @@
1
- module BWAPI
2
- class Client
3
- module User
4
- # InstagramCredentials module for user/instagramcredentials endpoints
5
- module InstagramCredentials
6
- # Get current user Instagram credentials
7
- #
8
- # @return [Hash] Current user Instagram credentials
9
- def instagram_credentials
10
- get '/user/instagramcredentials'
11
- end
12
-
13
- # Delete current user Instagram credentials
14
- #
15
- # @return [Hash] Current users deleted Instagram credentials
16
- def delete_instagram_credentials
17
- delete '/user/instagramcredentials'
18
- end
19
-
20
- # Store the current user's Instagram credentials
21
- #
22
- # @param opts [Hash] options Hash of parameters
23
- # @option opts [String] accessToken Instagram API access token
24
- # @option opts [String] clientId Instagram API client id
25
- # @return [Hash] Current user Instagram credentials
26
- def update_instagram_credentials(opts = {})
27
- put '/user/instagramcredentials', opts
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,499 +0,0 @@
1
- require 'helper'
2
- require 'logger'
3
-
4
- describe BWAPI::Configuration do
5
- let(:bwapi) { BWAPI::Client.new }
6
-
7
- describe 'instance variables' do
8
- it 'should create a access_token instance variable' do
9
- expect(bwapi.respond_to?(:access_token)).to eq(true)
10
- end
11
-
12
- it 'should create a access_token_expiry instance variable' do
13
- expect(bwapi.respond_to?(:access_token_expiry)).to eq(true)
14
- end
15
-
16
- it 'should create a adapter instance variable' do
17
- expect(bwapi.respond_to?(:adapter)).to eq(true)
18
- end
19
-
20
- it 'should create a api_endpoint instance variable' do
21
- expect(bwapi.respond_to?(:api_endpoint)).to eq(true)
22
- end
23
-
24
- it 'should create a client_id instance variable' do
25
- expect(bwapi.respond_to?(:client_id)).to eq(true)
26
- end
27
-
28
- it 'should create a client_secret instance variable which cannot accessed' do
29
- expect(bwapi.respond_to?(:client_secret)).to eq(false)
30
- end
31
-
32
- it 'should create a debug instance variable' do
33
- expect(bwapi.respond_to?(:debug)).to eq(true)
34
- end
35
-
36
- it 'should create a grant_type instance variable' do
37
- expect(bwapi.respond_to?(:grant_type)).to eq(true)
38
- end
39
-
40
- it 'should create a logger instance variable' do
41
- expect(bwapi.respond_to?(:logger)).to eq(true)
42
- end
43
-
44
- it 'should create a password instance variable which cannot be accessed' do
45
- expect(bwapi.respond_to?(:password)).to eq(false)
46
- end
47
-
48
- it 'should create a performance instance variable' do
49
- expect(bwapi.respond_to?(:performance)).to eq(true)
50
- end
51
-
52
- it 'should create a refresh_token instance variable' do
53
- expect(bwapi.respond_to?(:refresh_token)).to eq(true)
54
- end
55
-
56
- it 'should create a user_agent instance variable' do
57
- expect(bwapi.respond_to?(:user_agent)).to eq(true)
58
- end
59
-
60
- it 'should create a username instance variable' do
61
- expect(bwapi.respond_to?(:username)).to eq(true)
62
- end
63
-
64
- it 'should create a logger instance variable' do
65
- expect(bwapi.respond_to?(:logger)).to eq(true)
66
- end
67
-
68
- it 'should create a verify_ssl instance variable' do
69
- expect(bwapi.respond_to?(:verify_ssl)).to eq(true)
70
- end
71
- end
72
-
73
- describe 'default and custom values' do
74
- before { bwapi.reset }
75
-
76
- describe 'access_token' do
77
- it 'should have a default value of nil for access_token' do
78
- expect(bwapi.access_token).to eql(nil)
79
- end
80
-
81
- it 'should allow a user to set a access_token value' do
82
- bwapi.access_token = 'abcdef-ghijkl-123456-789012'
83
- expect(bwapi.access_token).to eql('abcdef-ghijkl-123456-789012')
84
- end
85
- end
86
-
87
- describe 'access_token_expiry' do
88
- it 'should have a default value of nil for access_token_expiry' do
89
- expect(bwapi.access_token_expiry).to eql(nil)
90
- end
91
-
92
- it 'should allow a user to set a access_token_expiry value' do
93
- bwapi.access_token_expiry = '2015-01-08T16:13:03-08:00'
94
- expect(bwapi.access_token_expiry).to eql('2015-01-08T16:13:03-08:00')
95
- end
96
- end
97
-
98
- describe 'adapter' do
99
- it 'should have a default adapter value' do
100
- expect(bwapi.adapter).to eql(:net_http)
101
- end
102
-
103
- it 'should allow a user to set a default_adapter value' do
104
- bwapi.adapter = 'custom_adapter'
105
- expect(bwapi.adapter).to eql('custom_adapter')
106
- end
107
- end
108
-
109
- describe 'api_endpoint' do
110
- it 'should have a default api_endpoint value' do
111
- expect(bwapi.api_endpoint).to eql('https://newapi.brandwatch.com/')
112
- end
113
-
114
- it 'should allow a user to set a api_endpoint value' do
115
- bwapi.api_endpoint = 'http://newapi.custom.brandwatch.com'
116
- expect(bwapi.api_endpoint).to eql('http://newapi.custom.brandwatch.com')
117
- end
118
- end
119
-
120
- describe 'client_id' do
121
- it 'should have a default client_id value' do
122
- expect(bwapi.client_id).to eql('brandwatch-api-client')
123
- end
124
-
125
- it 'should allow a user to set a client_id value' do
126
- bwapi.client_id = 'custom_client_id'
127
- expect(bwapi.client_id).to eql('custom_client_id')
128
- end
129
- end
130
-
131
- describe 'client_secret' do
132
- it 'should allow a user to set a client_secret value' do
133
- bwapi.client_secret = 'custom_client_secret'
134
- expect(bwapi.instance_eval { @client_secret }).to eql('custom_client_secret')
135
- end
136
- end
137
-
138
- describe 'debug' do
139
- it 'should have a default debug value' do
140
- expect(bwapi.debug).to eql(false)
141
- end
142
-
143
- it 'should allow a user to set a debug value' do
144
- bwapi.debug = true
145
- expect(bwapi.debug).to eql(true)
146
- end
147
- end
148
-
149
- describe 'grant_type' do
150
- it 'should have a default value of api-password for grant_type' do
151
- expect(bwapi.grant_type).to eql('api-password')
152
- end
153
-
154
- it 'should allow a user to set a grant_type value' do
155
- bwapi.grant_type = 'custom_grant_type'
156
- expect(bwapi.grant_type).to eql('custom_grant_type')
157
- end
158
- end
159
-
160
- describe 'logger' do
161
- it 'should have a default value of nil for logger' do
162
- expect(bwapi.logger).to eql(nil)
163
- end
164
-
165
- it 'should allow a user to set a logger value' do
166
- logger = Logger.new(STDOUT)
167
- bwapi.logger = logger
168
- expect(bwapi.logger).to eql(logger)
169
- end
170
- end
171
-
172
- describe 'password' do
173
- it 'should allow a user to set a password value' do
174
- bwapi.password = 'pa55w0rd'
175
- expect(bwapi.instance_eval { @password }).to eql('pa55w0rd')
176
- end
177
- end
178
-
179
- describe 'performance' do
180
- it 'should have a default performance value' do
181
- expect(bwapi.performance).to eql({})
182
- end
183
- end
184
-
185
- describe 'refresh_token' do
186
- it 'should have a default value of nil for refresh_token' do
187
- expect(bwapi.refresh_token).to eql(nil)
188
- end
189
-
190
- it 'should allow a user to set a refresh_token value' do
191
- bwapi.refresh_token = 'abcdef-ghijkl-123456-789012'
192
- expect(bwapi.refresh_token).to eql('abcdef-ghijkl-123456-789012')
193
- end
194
- end
195
-
196
- describe 'user_agent' do
197
- it 'should have a default user_agent value' do
198
- expect(bwapi.user_agent).to eql("BWAPI Ruby Gem #{BWAPI::VERSION}")
199
- end
200
-
201
- it 'should allow a user to set a user_agent value' do
202
- bwapi.user_agent = 'custom_user_agent'
203
- expect(bwapi.user_agent).to eql('custom_user_agent')
204
- end
205
- end
206
-
207
- describe 'username' do
208
- it 'should have a default value of nil for username' do
209
- expect(bwapi.username).to eql(nil)
210
- end
211
-
212
- it 'should allow a user to set a username value' do
213
- bwapi.username = 'jonathan@brandwatch.com'
214
- expect(bwapi.username).to eql('jonathan@brandwatch.com')
215
- end
216
- end
217
-
218
- describe 'verify_ssl' do
219
- it 'should have a default verify_ssl value' do
220
- expect(bwapi.verify_ssl).to eql(false)
221
- end
222
-
223
- it 'should allow a user to set a verify_ssl value' do
224
- bwapi.verify_ssl = true
225
- expect(bwapi.verify_ssl).to eql(true)
226
- end
227
- end
228
- end
229
-
230
- describe '.keys' do
231
- it 'should return the correct list of keys' do
232
- expect(BWAPI::Configuration.keys).to eql([
233
- :access_token,
234
- :access_token_expiry,
235
- :adapter,
236
- :api_endpoint,
237
- :client_id,
238
- :client_secret,
239
- :connection_options,
240
- :debug,
241
- :grant_type,
242
- :logger,
243
- :password,
244
- :performance,
245
- :refresh_token,
246
- :user_agent,
247
- :username,
248
- :verify_ssl
249
- ])
250
- end
251
- end
252
-
253
- describe '.configure' do
254
- before do
255
- bwapi.configure do |c|
256
- c.access_token = '1234-5678-9010-1112'
257
- c.access_token_expiry = '2015-01-08 14:09:16 -0800'
258
- c.adapter = :test
259
- c.api_endpoint = 'http://newapi.test.brandwatch.com'
260
- c.client_id = 'brandwatch-test-client'
261
- c.client_secret = 'test'
262
- c.debug = true
263
- c.grant_type = 'test-grant'
264
- c.logger = Logger.new(STDOUT)
265
- c.password = 'password123'
266
- c.refresh_token = '1234-5678-9010-1112'
267
- c.user_agent = 'Test User Agent'
268
- c.username = 'testing@brandwatch.com'
269
- c.verify_ssl = true
270
- end
271
- end
272
-
273
- after { bwapi.reset }
274
-
275
- it 'should set the configured access_token' do
276
- expect(bwapi.access_token).to eql('1234-5678-9010-1112')
277
- end
278
-
279
- it 'should set the configured access_token_expiry' do
280
- expect(bwapi.access_token_expiry).to eql('2015-01-08 14:09:16 -0800')
281
- end
282
-
283
- it 'should set the configured adapter' do
284
- expect(bwapi.adapter).to eql(:test)
285
- end
286
-
287
- it 'should set the configured api_endpoint' do
288
- expect(bwapi.api_endpoint).to eql('http://newapi.test.brandwatch.com')
289
- end
290
-
291
- it 'should set the configured client_id' do
292
- expect(bwapi.client_id).to eql('brandwatch-test-client')
293
- end
294
-
295
- it 'should set the configured client_secret' do
296
- expect(bwapi.instance_variable_get(:@client_secret)).to eql('test')
297
- end
298
-
299
- it 'should set the configured debug flag' do
300
- expect(bwapi.debug).to eql(true)
301
- end
302
-
303
- it 'should set the configured grant type' do
304
- expect(bwapi.grant_type).to eql('test-grant')
305
- end
306
-
307
- it 'should set the configured logger' do
308
- expect(bwapi.logger).to be_an_instance_of Logger
309
- end
310
-
311
- it 'should set the configured password' do
312
- expect(bwapi.instance_variable_get(:@password)).to eql('password123')
313
- end
314
-
315
- it 'should set the configured refresh_token' do
316
- expect(bwapi.refresh_token).to eql('1234-5678-9010-1112')
317
- end
318
-
319
- it 'should set the configured user agent' do
320
- expect(bwapi.user_agent).to eql('Test User Agent')
321
- end
322
-
323
- it 'should set the configured username' do
324
- expect(bwapi.username).to eql('testing@brandwatch.com')
325
- end
326
-
327
- it 'should set the configured verify_ssl flag' do
328
- expect(bwapi.verify_ssl).to eql(true)
329
- end
330
- end
331
-
332
- describe '.reset' do
333
- before { bwapi.reset }
334
-
335
- it 'should reset the access token value' do
336
- expect(bwapi.access_token).to eql(nil)
337
- end
338
-
339
- it 'should reset the access token expiry value' do
340
- expect(bwapi.access_token_expiry).to eql(nil)
341
- end
342
-
343
- it 'should reset the adapter value' do
344
- expect(bwapi.adapter).to eql(:net_http)
345
- end
346
-
347
- it 'should reset the api_endpoint value' do
348
- expect(bwapi.api_endpoint).to eql('https://newapi.brandwatch.com/')
349
- end
350
-
351
- it 'should reset the client_id value' do
352
- expect(bwapi.client_id).to eql('brandwatch-api-client')
353
- end
354
-
355
- it 'should reset the client_secret value' do
356
- expect(bwapi.instance_variable_get(:@client_secret)).to eql(nil)
357
- end
358
-
359
- it 'should reset the connection value' do
360
- expect(bwapi.instance_variable_get(:@connection)).to eql(nil)
361
- end
362
-
363
- it 'should reset the debug value' do
364
- expect(bwapi.debug).to eql(false)
365
- end
366
-
367
- it 'should reset the grant_type value' do
368
- expect(bwapi.grant_type).to eql('api-password')
369
- end
370
-
371
- it 'should reset the logger value' do
372
- expect(bwapi.logger).to eql(nil)
373
- end
374
-
375
- it 'should reset the password value' do
376
- expect(bwapi.instance_variable_get(:@password)).to eql(nil)
377
- end
378
-
379
- it 'should reset the performance value' do
380
- expect(bwapi.performance).to eql({})
381
- end
382
-
383
- it 'should reset the refresh_token value' do
384
- expect(bwapi.refresh_token).to eql(nil)
385
- end
386
-
387
- it 'should reset the user_agent value' do
388
- expect(bwapi.user_agent).to eql('BWAPI Ruby Gem 10.0.0')
389
- end
390
-
391
- it 'should reset the username value' do
392
- expect(bwapi.username).to eql(nil)
393
- end
394
-
395
- it 'should reset the verify_ssl value' do
396
- expect(bwapi.verify_ssl).to eql(false)
397
- end
398
- end
399
-
400
- describe '.destroy' do
401
- before { bwapi.destroy }
402
-
403
- it 'should reset the access token value' do
404
- expect(bwapi.access_token).to eql(nil)
405
- end
406
-
407
- it 'should reset the access token expiry value' do
408
- expect(bwapi.access_token_expiry).to eql(nil)
409
- end
410
-
411
- it 'should reset the adapter value' do
412
- expect(bwapi.adapter).to eql(nil)
413
- end
414
-
415
- it 'should reset the api_endpoint value' do
416
- expect(bwapi.api_endpoint).to eql(nil)
417
- end
418
-
419
- it 'should reset the client_id value' do
420
- expect(bwapi.client_id).to eql(nil)
421
- end
422
-
423
- it 'should reset the client_secret value' do
424
- expect(bwapi.instance_variable_get(:@client_secret)).to eql(nil)
425
- end
426
-
427
- it 'should reset the connection value' do
428
- expect(bwapi.instance_variable_get(:@connection)).to eql(nil)
429
- end
430
-
431
- it 'should reset the debug value' do
432
- expect(bwapi.debug).to eql(nil)
433
- end
434
-
435
- it 'should reset the grant_type value' do
436
- expect(bwapi.grant_type).to eql(nil)
437
- end
438
-
439
- it 'should reset the logger value' do
440
- expect(bwapi.logger).to eql(nil)
441
- end
442
-
443
- it 'should reset the password value' do
444
- expect(bwapi.instance_variable_get(:@password)).to eql(nil)
445
- end
446
-
447
- it 'should reset the performance value' do
448
- expect(bwapi.performance).to eql(nil)
449
- end
450
-
451
- it 'should reset the refresh_token value' do
452
- expect(bwapi.refresh_token).to eql(nil)
453
- end
454
-
455
- it 'should reset the user_agent value' do
456
- expect(bwapi.user_agent).to eql(nil)
457
- end
458
-
459
- it 'should reset the username value' do
460
- expect(bwapi.username).to eql(nil)
461
- end
462
-
463
- it 'should reset the verify_ssl value' do
464
- expect(bwapi.verify_ssl).to eql(nil)
465
- end
466
- end
467
-
468
- describe '.options' do
469
- before { bwapi.reset }
470
-
471
- it 'should return the current configuration set' do
472
- expect(bwapi.send(:options)).to eql(
473
- access_token: nil,
474
- access_token_expiry: nil,
475
- adapter: :net_http,
476
- api_endpoint: 'https://newapi.brandwatch.com/',
477
- client_id: 'brandwatch-api-client',
478
- client_secret: nil,
479
- connection_options: {
480
- headers: {
481
- user_agent: 'BWAPI Ruby Gem 10.0.0'
482
- },
483
- request: {
484
- params_encoder: Faraday::FlatParamsEncoder
485
- }
486
- },
487
- debug: false,
488
- grant_type: 'api-password',
489
- logger: nil,
490
- password: nil,
491
- performance: {},
492
- refresh_token: nil,
493
- user_agent: 'BWAPI Ruby Gem 10.0.0',
494
- username: nil,
495
- verify_ssl: false
496
- )
497
- end
498
- end
499
- end