bwapi 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.travis.yml +10 -0
- data/Gemfile +6 -0
- data/LICENCE.md +20 -0
- data/README.md +15 -0
- data/bin/bwapi +2 -0
- data/bwapi.gemspec +26 -0
- data/lib/bwapi.rb +28 -0
- data/lib/bwapi/authentication.rb +42 -0
- data/lib/bwapi/client.rb +54 -0
- data/lib/bwapi/client/admin.rb +35 -0
- data/lib/bwapi/client/admin/become.rb +21 -0
- data/lib/bwapi/client/admin/search.rb +41 -0
- data/lib/bwapi/client/admin/sub_clients.rb +109 -0
- data/lib/bwapi/client/admin/users.rb +95 -0
- data/lib/bwapi/client/admin/users/sharing.rb +35 -0
- data/lib/bwapi/client/brandwatch.rb +33 -0
- data/lib/bwapi/client/brandwatch/become.rb +19 -0
- data/lib/bwapi/client/brandwatch/client_modules.rb +26 -0
- data/lib/bwapi/client/client.rb +22 -0
- data/lib/bwapi/client/error_codes.rb +14 -0
- data/lib/bwapi/client/filters.rb +14 -0
- data/lib/bwapi/client/logout.rb +24 -0
- data/lib/bwapi/client/me.rb +42 -0
- data/lib/bwapi/client/oauth.rb +78 -0
- data/lib/bwapi/client/ping.rb +42 -0
- data/lib/bwapi/client/projects.rb +94 -0
- data/lib/bwapi/client/projects/categories.rb +70 -0
- data/lib/bwapi/client/projects/data.rb +62 -0
- data/lib/bwapi/client/projects/data_download.rb +49 -0
- data/lib/bwapi/client/projects/facebook_queries.rb +55 -0
- data/lib/bwapi/client/projects/queries.rb +99 -0
- data/lib/bwapi/client/projects/queries/backfill.rb +63 -0
- data/lib/bwapi/client/projects/queries/date_range.rb +67 -0
- data/lib/bwapi/client/projects/queries/mentions.rb +53 -0
- data/lib/bwapi/client/projects/query_groups.rb +70 -0
- data/lib/bwapi/client/projects/sharing.rb +57 -0
- data/lib/bwapi/client/projects/signals.rb +39 -0
- data/lib/bwapi/client/projects/summary.rb +21 -0
- data/lib/bwapi/client/projects/tags.rb +61 -0
- data/lib/bwapi/client/projects/users.rb +17 -0
- data/lib/bwapi/client/projects/workflow.rb +17 -0
- data/lib/bwapi/client/query_validation.rb +27 -0
- data/lib/bwapi/client/sso.rb +18 -0
- data/lib/bwapi/client/test_search.rb +14 -0
- data/lib/bwapi/client/user.rb +58 -0
- data/lib/bwapi/client/user/notifications.rb +36 -0
- data/lib/bwapi/configuration.rb +59 -0
- data/lib/bwapi/connection.rb +33 -0
- data/lib/bwapi/error.rb +42 -0
- data/lib/bwapi/request.rb +93 -0
- data/lib/bwapi/version.rb +3 -0
- data/lib/faraday/response/brandwatch_error.rb +25 -0
- data/lib/faraday/utils/utils.rb +25 -0
- data/spec/bwapi/authentication_spec.rb +57 -0
- data/spec/bwapi/client_spec.rb +205 -0
- data/spec/bwapi_spec.rb +23 -0
- data/spec/fixtures/.netrc +3 -0
- data/spec/helper.rb +12 -0
- metadata +178 -0
@@ -0,0 +1,205 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe BWAPI::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
BWAPI.reset
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'when called' do
|
10
|
+
it 'should be a client class instance' do
|
11
|
+
BWAPI::Client.new.should be_an_instance_of BWAPI::Client
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'configuration' do
|
16
|
+
describe 'instance variables' do
|
17
|
+
it 'should create a api_endpoint instance variable' do
|
18
|
+
expect(BWAPI::Client.new.respond_to?(:api_endpoint)).to eq(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should create a user_agent instance variable' do
|
22
|
+
expect(BWAPI::Client.new.respond_to?(:user_agent)).to eq(true)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should create a adapter instance variable' do
|
26
|
+
expect(BWAPI::Client.new.respond_to?(:adapter)).to eq(true)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should create a username instance variable' do
|
30
|
+
expect(BWAPI::Client.new.respond_to?(:username)).to eq(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should create a password instance variable' do
|
34
|
+
expect(BWAPI::Client.new.respond_to?(:password)).to eq(true)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should create a grant_type instance variable' do
|
38
|
+
expect(BWAPI::Client.new.respond_to?(:grant_type)).to eq(true)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should create a access_token instance variable' do
|
42
|
+
expect(BWAPI::Client.new.respond_to?(:access_token)).to eq(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should create a refresh_token instance variable' do
|
46
|
+
expect(BWAPI::Client.new.respond_to?(:refresh_token)).to eq(true)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should create a expires_in instance variable' do
|
50
|
+
expect(BWAPI::Client.new.respond_to?(:expires_in)).to eq(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should create a client_id instance variable' do
|
54
|
+
expect(BWAPI::Client.new.respond_to?(:client_id)).to eq(true)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should create a client_secret instance variable' do
|
58
|
+
expect(BWAPI::Client.new.respond_to?(:client_secret)).to eq(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should create a netrc instance variable' do
|
62
|
+
expect(BWAPI::Client.new.respond_to?(:netrc)).to eq(true)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should create a netrc_file instance variable' do
|
66
|
+
expect(BWAPI::Client.new.respond_to?(:netrc_file)).to eq(true)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'configuration values' do
|
71
|
+
describe 'default_adapter' do
|
72
|
+
it 'should have a default default_adapter value' do
|
73
|
+
expect(BWAPI::Client.new.adapter).to eql(:net_http)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should allow a user to set a default_adapter value' do
|
77
|
+
bw = BWAPI::Client.new :adapter => 'custom_adapter'
|
78
|
+
expect(bw.adapter).to eql('custom_adapter')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'user_agent' do
|
83
|
+
it 'should have a default user_agent value' do
|
84
|
+
expect(BWAPI::Client.new.user_agent).to eql("BWAPI Ruby Gem #{BWAPI::VERSION}")
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should allow a user to set a user_agent value' do
|
88
|
+
bw = BWAPI::Client.new :user_agent => 'custom_user_agent'
|
89
|
+
expect(bw.user_agent).to eql('custom_user_agent')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'api_endpoint' do
|
94
|
+
it 'should have a default api_endpoint value' do
|
95
|
+
expect(BWAPI::Client.new.api_endpoint).to eql("http://newapi.brandwatch.com/")
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should allow a user to set a api_endpoint value' do
|
99
|
+
bw = BWAPI::Client.new :api_endpoint => 'http://newapi.custom.brandwatch.com'
|
100
|
+
expect(bw.api_endpoint).to eql('http://newapi.custom.brandwatch.com')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'client_id' do
|
105
|
+
it 'should have a default client_id value' do
|
106
|
+
expect(BWAPI::Client.new.client_id).to eql("brandwatch-api-client")
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should allow a user to set a client_id value' do
|
110
|
+
bw = BWAPI::Client.new :client_id => 'custom_client_id'
|
111
|
+
expect(bw.client_id).to eql('custom_client_id')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe 'netrc' do
|
116
|
+
it 'should have a default netrc value' do
|
117
|
+
expect(BWAPI::Client.new.netrc).to eql(false)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should allow a user to set a netrc value' do
|
121
|
+
bw = BWAPI::Client.new :netrc => true
|
122
|
+
expect(bw.netrc).to eql(true)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe 'netrc_file' do
|
127
|
+
it 'should have a default netrc value' do
|
128
|
+
expect(BWAPI::Client.new.netrc_file).to eql("#{ENV['HOME'] + '/' + '.netrc'}")
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should allow a user to set a netrc_file value' do
|
132
|
+
bw = BWAPI::Client.new :netrc_file => 'example/.netrc'
|
133
|
+
expect(bw.netrc_file).to eql('example/.netrc')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe 'username' do
|
138
|
+
it 'should have a default value of nil for username' do
|
139
|
+
expect(BWAPI::Client.new.username).to eql(nil)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should allow a user to set a username value' do
|
143
|
+
bw = BWAPI::Client.new :username => 'jonathan@brandwatch.com'
|
144
|
+
expect(bw.username).to eql('jonathan@brandwatch.com')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe 'password' do
|
149
|
+
it 'should have a default value of nil for password' do
|
150
|
+
expect(BWAPI::Client.new.password).to eql(nil)
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should allow a user to set a password value' do
|
154
|
+
bw = BWAPI::Client.new :password => 'pa55w0rd'
|
155
|
+
expect(bw.password).to eql('pa55w0rd')
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe 'grant_type' do
|
160
|
+
it 'should have a default value of nil for grant_type' do
|
161
|
+
expect(BWAPI::Client.new.grant_type).to eql(nil)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should allow a user to set a grant_type value' do
|
165
|
+
bw = BWAPI::Client.new :grant_type => 'custom_grant_type'
|
166
|
+
expect(bw.grant_type).to eql('custom_grant_type')
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe 'access_token' do
|
171
|
+
it 'should have a default value of nil for access_token' do
|
172
|
+
expect(BWAPI::Client.new.access_token).to eql(nil)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should allow a user to set a access_token value' do
|
176
|
+
bw = BWAPI::Client.new :access_token => 'abcdef-ghijkl-123456-789012'
|
177
|
+
expect(bw.access_token).to eql('abcdef-ghijkl-123456-789012')
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe 'refresh_token' do
|
182
|
+
it 'should have a default value of nil for refresh_token' do
|
183
|
+
expect(BWAPI::Client.new.refresh_token).to eql(nil)
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should allow a user to set a refresh_token value' do
|
187
|
+
bw = BWAPI::Client.new :refresh_token => 'abcdef-ghijkl-123456-789012'
|
188
|
+
expect(bw.refresh_token).to eql('abcdef-ghijkl-123456-789012')
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe 'client_secret' do
|
193
|
+
it 'should have a default value of nil for client_secret' do
|
194
|
+
expect(BWAPI::Client.new.client_secret).to eql(nil)
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should allow a user to set a client_secret value' do
|
198
|
+
bw = BWAPI::Client.new :client_secret => 'custom_client_secret'
|
199
|
+
expect(bw.client_secret).to eql('custom_client_secret')
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
end
|
data/spec/bwapi_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe BWAPI do
|
4
|
+
|
5
|
+
describe 'when called' do
|
6
|
+
it 'should be an instance of Module' do
|
7
|
+
BWAPI.should be_an_instance_of Module
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
it 'is a BWAPI::Client' do
|
13
|
+
expect(BWAPI.new).to be_a BWAPI::Client
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.respond_to?' do
|
18
|
+
it 'returns true if new method exists' do
|
19
|
+
expect(BWAPI.respond_to?(:new, true)).to eq(true)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bwapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Chrisp
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.13.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.13.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.12.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.9.12.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday_middleware
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: netrc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.7.7
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.7.7
|
83
|
+
description: A Ruby wrapper for the Brandwatch v2 API
|
84
|
+
email: jonathan@brandwatch.com
|
85
|
+
executables:
|
86
|
+
- bwapi
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .travis.yml
|
92
|
+
- Gemfile
|
93
|
+
- LICENCE.md
|
94
|
+
- README.md
|
95
|
+
- bin/bwapi
|
96
|
+
- bwapi.gemspec
|
97
|
+
- lib/bwapi.rb
|
98
|
+
- lib/bwapi/authentication.rb
|
99
|
+
- lib/bwapi/client.rb
|
100
|
+
- lib/bwapi/client/admin.rb
|
101
|
+
- lib/bwapi/client/admin/become.rb
|
102
|
+
- lib/bwapi/client/admin/search.rb
|
103
|
+
- lib/bwapi/client/admin/sub_clients.rb
|
104
|
+
- lib/bwapi/client/admin/users.rb
|
105
|
+
- lib/bwapi/client/admin/users/sharing.rb
|
106
|
+
- lib/bwapi/client/brandwatch.rb
|
107
|
+
- lib/bwapi/client/brandwatch/become.rb
|
108
|
+
- lib/bwapi/client/brandwatch/client_modules.rb
|
109
|
+
- lib/bwapi/client/client.rb
|
110
|
+
- lib/bwapi/client/error_codes.rb
|
111
|
+
- lib/bwapi/client/filters.rb
|
112
|
+
- lib/bwapi/client/logout.rb
|
113
|
+
- lib/bwapi/client/me.rb
|
114
|
+
- lib/bwapi/client/oauth.rb
|
115
|
+
- lib/bwapi/client/ping.rb
|
116
|
+
- lib/bwapi/client/projects.rb
|
117
|
+
- lib/bwapi/client/projects/categories.rb
|
118
|
+
- lib/bwapi/client/projects/data.rb
|
119
|
+
- lib/bwapi/client/projects/data_download.rb
|
120
|
+
- lib/bwapi/client/projects/facebook_queries.rb
|
121
|
+
- lib/bwapi/client/projects/queries.rb
|
122
|
+
- lib/bwapi/client/projects/queries/backfill.rb
|
123
|
+
- lib/bwapi/client/projects/queries/date_range.rb
|
124
|
+
- lib/bwapi/client/projects/queries/mentions.rb
|
125
|
+
- lib/bwapi/client/projects/query_groups.rb
|
126
|
+
- lib/bwapi/client/projects/sharing.rb
|
127
|
+
- lib/bwapi/client/projects/signals.rb
|
128
|
+
- lib/bwapi/client/projects/summary.rb
|
129
|
+
- lib/bwapi/client/projects/tags.rb
|
130
|
+
- lib/bwapi/client/projects/users.rb
|
131
|
+
- lib/bwapi/client/projects/workflow.rb
|
132
|
+
- lib/bwapi/client/query_validation.rb
|
133
|
+
- lib/bwapi/client/sso.rb
|
134
|
+
- lib/bwapi/client/test_search.rb
|
135
|
+
- lib/bwapi/client/user.rb
|
136
|
+
- lib/bwapi/client/user/notifications.rb
|
137
|
+
- lib/bwapi/configuration.rb
|
138
|
+
- lib/bwapi/connection.rb
|
139
|
+
- lib/bwapi/error.rb
|
140
|
+
- lib/bwapi/request.rb
|
141
|
+
- lib/bwapi/version.rb
|
142
|
+
- lib/faraday/response/brandwatch_error.rb
|
143
|
+
- lib/faraday/utils/utils.rb
|
144
|
+
- spec/bwapi/authentication_spec.rb
|
145
|
+
- spec/bwapi/client_spec.rb
|
146
|
+
- spec/bwapi_spec.rb
|
147
|
+
- spec/fixtures/.netrc
|
148
|
+
- spec/helper.rb
|
149
|
+
homepage: https://github.com/jonathanchrisp/bwapi
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 1.9.2
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.0.5
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Brandwatch v2 API Wrapper
|
173
|
+
test_files:
|
174
|
+
- spec/bwapi/authentication_spec.rb
|
175
|
+
- spec/bwapi/client_spec.rb
|
176
|
+
- spec/bwapi_spec.rb
|
177
|
+
- spec/fixtures/.netrc
|
178
|
+
- spec/helper.rb
|