bwapi 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,67 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module Queries
|
5
|
+
module DateRange
|
6
|
+
|
7
|
+
# Get all date ranges for query
|
8
|
+
#
|
9
|
+
# @param project_id [Integer] Id of project
|
10
|
+
# @param query_id [Integer] Id of query
|
11
|
+
# @return [Hashie::Mash] All date ranges for query
|
12
|
+
def date_ranges project_id, query_id
|
13
|
+
get "projects/#{project_id}/#{query_id}/date-range"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get specific date range for query
|
17
|
+
#
|
18
|
+
# @param project_id [Integer] Id of project
|
19
|
+
# @param query_id [Integer] Id of query
|
20
|
+
# @param date_range_id [Integer] Id of date range
|
21
|
+
# @return [Hashie::Mash] Specific date range for query
|
22
|
+
def date_range project_id, query_id, date_range_id
|
23
|
+
get "projects/#{project_id}/#{query_id}/date-range/#{date_range_id}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create a new date range for query
|
27
|
+
#
|
28
|
+
# @param project_id [Integer] Id of project
|
29
|
+
# @param query_id [Integer] Id of query
|
30
|
+
# @param opts [Hash] options hash of parameters
|
31
|
+
# @option opts [Integer] projectId Id of the project
|
32
|
+
# @option opts [Integer] queryId Id of the query
|
33
|
+
# @option opts [Array] StoredDateRangeDTO Date ranges to be stored
|
34
|
+
# @return [Hashie::Mash] New date range
|
35
|
+
def create_date_range project_id, query_id, opts
|
36
|
+
post "projects/#{project_id}/#{query_id}/date-range", opts
|
37
|
+
end
|
38
|
+
|
39
|
+
# Update an existing date range for query
|
40
|
+
#
|
41
|
+
# @param project_id [Integer] Id of project
|
42
|
+
# @param query_id [Integer] Id of query
|
43
|
+
# @param opts [Hash] options hash of parameters
|
44
|
+
# @option opts [Integer] projectId Id of the project
|
45
|
+
# @option opts [Integer] queryId Id of the query
|
46
|
+
# @option opts [Integer] dateRangeId Id of the date range
|
47
|
+
# @option opts [Array] StoredDateRangeDTO Date ranges to be edited
|
48
|
+
# @return [Hashie::Mash] Update date range
|
49
|
+
def update_date_range project_id, query_id, opts
|
50
|
+
put "projects/#{project_id}/#{query_id}/date-range/#{date_range_id}", opts
|
51
|
+
end
|
52
|
+
|
53
|
+
# Delete an existing date range for query
|
54
|
+
#
|
55
|
+
# @param project_id [Integer] Id of project
|
56
|
+
# @param query_id [Integer] Id of query
|
57
|
+
# @param date_range_id [Integer] Id of date range
|
58
|
+
# @return [Hashie::Mash] Deleted date range
|
59
|
+
def delete_date_range project_id, query_id, date_range_id
|
60
|
+
delete "projects/#{project_id}/#{query_id}/date-range/#{date_range_id}"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module Queries
|
5
|
+
module Mentions
|
6
|
+
|
7
|
+
# Get the full text of query mention
|
8
|
+
#
|
9
|
+
# @param project_id [Integer] Id of project
|
10
|
+
# @param query_id [Integer] Id of query
|
11
|
+
# @param mention_id [Integer] Id of mention
|
12
|
+
# @return [Hashie::Mash] Content of query mention
|
13
|
+
def get_query_mention_content project_id, query_id, mention_id
|
14
|
+
get "projects/#{project_id}/queries/#{query_id}/mentions/#{mention_id}/content"
|
15
|
+
end
|
16
|
+
alias :query_mention_content :get_query_mention_content
|
17
|
+
alias :mention_content :get_query_mention_content
|
18
|
+
|
19
|
+
# Update query mention
|
20
|
+
#
|
21
|
+
# @param project_id [Integer] Id of project
|
22
|
+
# @param query_id [Integer] Id of query
|
23
|
+
# @param mention_id [Integer] Id of mention
|
24
|
+
# @param opts [Hash] options hash of parameters
|
25
|
+
# @option opts [Integer] projectId Id of the project
|
26
|
+
# @option opts [Integer] queryId Id of the query
|
27
|
+
# @option opts [Integer] id Id of the mention
|
28
|
+
# @option opts [Hash] MentionPatchDTO patch to be applied
|
29
|
+
# @return [Hashie::Mash] Updated query mention
|
30
|
+
def update_query_mention project_id, query_id, mention_id, opts
|
31
|
+
patch "projects/#{project_id}/queries/#{query_id}/mentions/#{mention_id}", opts
|
32
|
+
end
|
33
|
+
|
34
|
+
# Delete query mention
|
35
|
+
#
|
36
|
+
# @param project_id [Integer] Id of project
|
37
|
+
# @param query_id [Integer] Id of query
|
38
|
+
# @param mention_id [Integer] Id of mention
|
39
|
+
# @param opts [Hash] options hash of parameters
|
40
|
+
# @option opts [Integer] projectId Id of the project
|
41
|
+
# @option opts [Integer] queryId Id of the query
|
42
|
+
# @option opts [Integer] id Id of the mention
|
43
|
+
# @option opts [Hash] Map patch to be applied
|
44
|
+
# @return [Hashie::Mash] Deleted query mention
|
45
|
+
def delete_query_mention project_id, query_id, mention_id, opts
|
46
|
+
delete "projects/#{project_id}/queries/#{query_id}/mentions/#{mention_id}", opts
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module QueryGroups
|
5
|
+
|
6
|
+
# Get all query groups in project
|
7
|
+
#
|
8
|
+
# @param id [Integer] Id of project
|
9
|
+
# @option opts [Integer] page Page of projects to retrieve
|
10
|
+
# @option opts [Integer] pageSize Results per page of results
|
11
|
+
# @return [Hashie::Mash] All query groups in project
|
12
|
+
def query_groups id, opts={}
|
13
|
+
get "projects/#{id}/querygroups", opts
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get a specific query group in project
|
17
|
+
#
|
18
|
+
# @param project_id [Integer] Id of project
|
19
|
+
# @param query_group_id [Integer] Id of query group
|
20
|
+
# @return [Hashie::Mash] Specific query group
|
21
|
+
def get_query_group project_id, query_group_id
|
22
|
+
get "projects/#{project_id}/querygroups/#{query_group_id}"
|
23
|
+
end
|
24
|
+
alias :query_group :get_query_group
|
25
|
+
|
26
|
+
# Create a new query group in project
|
27
|
+
#
|
28
|
+
# @param id [Integer] Id of project
|
29
|
+
# @param opts [Hash] options hash of parameters
|
30
|
+
# @option opts [Integer] id Id of the query group
|
31
|
+
# @option opts [String] name Name of the query group
|
32
|
+
# @option opts [String] shared Shared mode of query group
|
33
|
+
# @option opts [Array] users Users which this query group belongs to
|
34
|
+
# @option opts [Array] queries Queries within the query group
|
35
|
+
# @option opts [Hash] sharedProjectIds Projects which this query group belongs to
|
36
|
+
# @return [Hashie::Mash] New query group
|
37
|
+
def create_query_group id
|
38
|
+
post "projects/#{project_id}/querygroups"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Update an existing query group in project
|
42
|
+
#
|
43
|
+
# @param project_id [Integer] Id of project
|
44
|
+
# @param query_group_id [Integer] Id of query group
|
45
|
+
# @param opts [Hash] options hash of parameters
|
46
|
+
# @option opts [Integer] projectId Id of the project
|
47
|
+
# @option opts [Integer] queryGroupId of the query group
|
48
|
+
# @option opts [String] name Name of the query group
|
49
|
+
# @option opts [String] shared Shared mode of query group
|
50
|
+
# @option opts [Array] users Users which this query group belongs to
|
51
|
+
# @option opts [Array] queries Queries within the query group
|
52
|
+
# @option opts [Hash] sharedProjectIds Projects which this query group belongs to
|
53
|
+
# @return [Hashie::Mash] New query group
|
54
|
+
def update_query_group project_id, query_group_id, opts={}
|
55
|
+
put "projects/#{project_id}/querygroups/#{query_group_id}", opts
|
56
|
+
end
|
57
|
+
|
58
|
+
# Delete an existing query group in project
|
59
|
+
#
|
60
|
+
# @param project_id [Integer] Id of project
|
61
|
+
# @param query_group_id [Integer] Id of query group
|
62
|
+
# @return [Hashie::Mash] Deleted query group
|
63
|
+
def delete_query_group project_id, query_group_id
|
64
|
+
delete "projects/#{project_id}/querygroups/#{query_group_id}"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module Sharing
|
5
|
+
|
6
|
+
# Default shares of a project
|
7
|
+
#
|
8
|
+
# @return [Hashie::Mash] Default project shares information
|
9
|
+
def default_project_sharing
|
10
|
+
get "projects/sharing"
|
11
|
+
end
|
12
|
+
alias :sharing :default_project_sharing
|
13
|
+
|
14
|
+
# Shares of a project
|
15
|
+
#
|
16
|
+
# @param id [Integer] Id of project
|
17
|
+
# @param opts [Hash] options hash of parameters
|
18
|
+
# @options opt [Integer] id Id of the project
|
19
|
+
# @options opt [Boolean] sharedOnly Boolean flag to return only shared shares (default: false)
|
20
|
+
# @return [Hashie::Mash] Specific project shares
|
21
|
+
def project_sharing id, opts={}
|
22
|
+
get "projects/#{id}/sharing", opts
|
23
|
+
end
|
24
|
+
|
25
|
+
# Update shares of a project
|
26
|
+
#
|
27
|
+
# @param id [Integer] Id of project
|
28
|
+
# @param opts [Hash] options hash of parameters
|
29
|
+
# @options opt [Integer] id Id of the project
|
30
|
+
# @options opt [Array] ProjectShareDTO Shares to be edited
|
31
|
+
# @return [Hashie::Mash] Updated project shares
|
32
|
+
def update_project_sharing id, opts={}
|
33
|
+
put "projects/#{id}/sharing", opts
|
34
|
+
end
|
35
|
+
|
36
|
+
# User share of a project
|
37
|
+
#
|
38
|
+
# @param project_id [Integer] Id of project
|
39
|
+
# @param user_id [Integer] Id of user
|
40
|
+
# @return [Hashie::Mash] Share of project for user
|
41
|
+
def project_sharing_user project_id, user_id
|
42
|
+
get "projects/#{project_id}/sharing/#{user_id}"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Edit user share of a project
|
46
|
+
#
|
47
|
+
# @param project_id [Integer] Id of project
|
48
|
+
# @param user_id [Integer] Id of user
|
49
|
+
# @return [Hashie::Mash] Updated share of project for user
|
50
|
+
def update_project_sharing_user project_id, user_id
|
51
|
+
put "projects/#{project_id}/sharing/#{user_id}"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module Signals
|
5
|
+
|
6
|
+
# Get all signals belonging to user in project
|
7
|
+
#
|
8
|
+
# @param id [Integer] Id of project
|
9
|
+
# @param opts [Hash] options hash of parameters
|
10
|
+
# @option opts [Integer] id Id of the query
|
11
|
+
# @option opts [Integer] page Page of projects to retrieve
|
12
|
+
# @option opts [Integer] pageSize Results per page of results
|
13
|
+
# @option opts [Integer] importance Importance of signal
|
14
|
+
# @option opts [String] type Type of signal
|
15
|
+
# @option opts [Integer] projectId Project id of the signal
|
16
|
+
# @option opts [Hash] filter The filter(s) to apply
|
17
|
+
# @return [Hashie::Mash] All signals for user in project
|
18
|
+
def signals id, opts
|
19
|
+
get "projects/#{id}/signals", opts
|
20
|
+
end
|
21
|
+
|
22
|
+
# Set the vote type and comment of a signal for a given user
|
23
|
+
#
|
24
|
+
# @param id [Integer] Id of project
|
25
|
+
# @param opts [Hash] options hash of parameters
|
26
|
+
# @option opts [Integer] userId Id of the user
|
27
|
+
# @option opts [Integer] voteType Type of vote
|
28
|
+
# @option opts [String] comment User comment
|
29
|
+
# @option opts [Integer] signalId Id of signal
|
30
|
+
# @option opts [Integer] projectId Project id of the signal
|
31
|
+
# @return [Hashie::Mash] Update signal for given user
|
32
|
+
def set_signal_vote id, opts
|
33
|
+
post "projects/#{project_id}/signals/vote", opts
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module Summary
|
5
|
+
|
6
|
+
# Summary of projects
|
7
|
+
#
|
8
|
+
# @param opts [Hash] options hash of parameters
|
9
|
+
# @option opts [Integer] page Page of projects to retrieve
|
10
|
+
# @option opts [Integer] pageSize Results per page of results
|
11
|
+
# @option opts [String] :filter Filter to apply to the query
|
12
|
+
# @return [Hashie::Mash] Project summary information
|
13
|
+
def projects_summary opts={}
|
14
|
+
get "projects/summary", opts
|
15
|
+
end
|
16
|
+
alias :summary :projects_summary
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module Tags
|
5
|
+
|
6
|
+
# Get all tags in project
|
7
|
+
#
|
8
|
+
# @param id [Integer] Id of project
|
9
|
+
# @option opts [Integer] page Page of projects to retrieve
|
10
|
+
# @option opts [Integer] pageSize Results per page of results
|
11
|
+
# @return [Hashie::Mash] All tags in project
|
12
|
+
def tags id, opts={}
|
13
|
+
get "projects/#{id}/tags", opts
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get a specific tag in project
|
17
|
+
#
|
18
|
+
# @param project_id [Integer] Id of project
|
19
|
+
# @param tag_id [Integer] Id of tag
|
20
|
+
# @return [Hashie::Mash] Specific tag
|
21
|
+
def get_tag project_id, tag_id
|
22
|
+
get "projects/#{project_id}/tags/#{tag_id}"
|
23
|
+
end
|
24
|
+
alias :tag :get_tag
|
25
|
+
|
26
|
+
# Create a new tag in project
|
27
|
+
#
|
28
|
+
# @param id [Integer] Id of project
|
29
|
+
# @param opts [Hash] options hash of parameters
|
30
|
+
# @option opts [Integer] id Id of the tag
|
31
|
+
# @option opts [String] name Name of the tag
|
32
|
+
# @return [Hashie::Mash] New tag
|
33
|
+
def create_tag id, opts
|
34
|
+
post "projects/#{id}/tags", opts
|
35
|
+
end
|
36
|
+
|
37
|
+
# Update an existing tag in project
|
38
|
+
#
|
39
|
+
# @param project_id [Integer] Id of project
|
40
|
+
# @param tag_id [Integer] Id of tag
|
41
|
+
# @param opts [Hash] options hash of parameters
|
42
|
+
# @option opts [Integer] id Id of the tag
|
43
|
+
# @option opts [String] name Name of the tag
|
44
|
+
# @return [Hashie::Mash] Updated tag
|
45
|
+
def update_tag project_id, tag_id, opts
|
46
|
+
put "projects/#{project_id}/tags/#{tag_id}", opts
|
47
|
+
end
|
48
|
+
|
49
|
+
# Delete an existing tag in project
|
50
|
+
#
|
51
|
+
# @param project_id [Integer] Id of project
|
52
|
+
# @param tag_id [Integer] Id of tag
|
53
|
+
# @return [Hashie::Mash] Deleted tag
|
54
|
+
def delete_tag project_id, tag_id
|
55
|
+
delete "projects/#{project_id}/tags/#{tag_id}"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module Users
|
5
|
+
|
6
|
+
# Get all users shared with project
|
7
|
+
#
|
8
|
+
# @param id [Integer] Id of project
|
9
|
+
# @return [Hashie::Mash] All users shared to project
|
10
|
+
def project_users id
|
11
|
+
get "projects/#{id}/users"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module Projects
|
4
|
+
module Workflow
|
5
|
+
|
6
|
+
# Get all workflow categories for project
|
7
|
+
#
|
8
|
+
# @param id [Integer] Id of project
|
9
|
+
# @return [Hashie::Mash] Workflow categories for project
|
10
|
+
def workflow id
|
11
|
+
get "projects/#{id}/workflow"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module QueryValidation
|
4
|
+
|
5
|
+
# Check to see if a query string is valid
|
6
|
+
#
|
7
|
+
# @param opts [Hash] options hash of parameters
|
8
|
+
# @option opts [String] query Query string
|
9
|
+
# @option opts [Array] language Languages for query string
|
10
|
+
# @return [Hashie::Mash] Query string validation results
|
11
|
+
def query_validation opts
|
12
|
+
get "query-validation", opts
|
13
|
+
end
|
14
|
+
|
15
|
+
# Check to see if a search within query string is valid
|
16
|
+
#
|
17
|
+
# @param opts [Hash] options hash of parameters
|
18
|
+
# @option opts [String] query Query string
|
19
|
+
# @option opts [Array] language Languages for query string
|
20
|
+
# @return [Hashie::Mash] Query string validation results
|
21
|
+
def search_within opts
|
22
|
+
get "query-validation/searchwithin", opts
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BWAPI
|
2
|
+
class Client
|
3
|
+
module SSO
|
4
|
+
|
5
|
+
# Authorize another user for access
|
6
|
+
#
|
7
|
+
# @note must have sso oauth_token
|
8
|
+
# @see oauth_token
|
9
|
+
#
|
10
|
+
# @param user_id [Integer] The user id
|
11
|
+
# @return [Hashie::Mash] User authorization
|
12
|
+
def sso id
|
13
|
+
get "sso/#{id}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|