bwapi 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bwapi/client/logout.rb +3 -3
- data/lib/bwapi/client/oauth.rb +13 -19
- data/lib/bwapi/client/projects.rb +1 -1
- data/lib/bwapi/request.rb +17 -14
- data/lib/bwapi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c2e256ae41a00031f7d4c5f62d2cab076b34e80
|
4
|
+
data.tar.gz: d07297df0f274cbe15e42f07492382a3d5b691e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e6ed60c84b9354250f1e9dead2923020f7b64690d1eada936b9d7acfd590dd006d9e51ad6158abc8f9eee3d9311c3b9b39d3d5c9892b9c676a55ad3b54a8930
|
7
|
+
data.tar.gz: 752d23785c294481eae8e43eeab66ad6089f74dd7bfbca75a6b97ab858c7128237ea0e9c056f1a58c17ef9015601ab979fd4f090c84bb6fe7bf0d6523ce9f1e2
|
data/lib/bwapi/client/logout.rb
CHANGED
@@ -9,12 +9,12 @@ module BWAPI
|
|
9
9
|
begin
|
10
10
|
get "logout"
|
11
11
|
ensure
|
12
|
+
self.access_token = nil
|
13
|
+
self.refresh_token = nil
|
12
14
|
self.username = nil
|
13
15
|
self.password = nil
|
14
|
-
self.access_token = nil
|
15
16
|
self.client_id = nil
|
16
|
-
self.
|
17
|
-
self.refresh_token = nil
|
17
|
+
self.grant_type = nil
|
18
18
|
self.expires_in = nil
|
19
19
|
end
|
20
20
|
end
|
data/lib/bwapi/client/oauth.rb
CHANGED
@@ -21,20 +21,7 @@ module BWAPI
|
|
21
21
|
force_urlencoded: true
|
22
22
|
}.merge opts
|
23
23
|
|
24
|
-
|
25
|
-
creds = post 'oauth/token', opts
|
26
|
-
rescue BWAPI::BWError
|
27
|
-
return false
|
28
|
-
else
|
29
|
-
self.access_token = creds.access_token
|
30
|
-
self.expires_in = creds.expires_in
|
31
|
-
|
32
|
-
if application_client?
|
33
|
-
self.refresh_token = creds.refresh_token
|
34
|
-
end
|
35
|
-
|
36
|
-
return true
|
37
|
-
end
|
24
|
+
oauth_request opts
|
38
25
|
end
|
39
26
|
alias :login :oauth_token
|
40
27
|
|
@@ -46,7 +33,7 @@ module BWAPI
|
|
46
33
|
# @option opts [String] grant_type Grant type of user
|
47
34
|
# @option opts [String] client_id Client id
|
48
35
|
# @option opts [String] force_urlencoded Force urlencoded
|
49
|
-
def oauth_refresh_token opts={}
|
36
|
+
def oauth_refresh_token opts={}, refresh_token = nil
|
50
37
|
opts = {
|
51
38
|
username: username,
|
52
39
|
password: password,
|
@@ -56,22 +43,29 @@ module BWAPI
|
|
56
43
|
force_urlencoded: true
|
57
44
|
}.merge opts
|
58
45
|
|
46
|
+
oauth_request opts
|
47
|
+
end
|
48
|
+
alias :refresh :oauth_refresh_token
|
49
|
+
|
50
|
+
# Sends a oauth request
|
51
|
+
#
|
52
|
+
# @param opts [Hash] options hash of parameters
|
53
|
+
def oauth_request opts
|
59
54
|
begin
|
60
55
|
creds = post 'oauth/token', opts
|
61
56
|
rescue BWAPI::BWError
|
62
|
-
|
57
|
+
false
|
63
58
|
else
|
64
59
|
self.access_token = creds.access_token
|
65
60
|
self.expires_in = creds.expires_in
|
66
61
|
|
67
62
|
if application_client?
|
68
|
-
self.
|
63
|
+
self.refresh_token = creds.refresh_token
|
69
64
|
end
|
70
65
|
|
71
|
-
|
66
|
+
true
|
72
67
|
end
|
73
68
|
end
|
74
|
-
alias :refresh :oauth_refresh_token
|
75
69
|
|
76
70
|
end
|
77
71
|
end
|
@@ -18,7 +18,7 @@ module BWAPI
|
|
18
18
|
# Get all projects
|
19
19
|
#
|
20
20
|
# @param opts [Hash] options hash of parameters
|
21
|
-
# @option opts [Integer]
|
21
|
+
# @option opts [Integer] pagePage of projects to retrieve
|
22
22
|
# @option opts [Integer] pageSize Results per page of results
|
23
23
|
# @return [Hashie::Mash] All projects
|
24
24
|
def projects opts={}
|
data/lib/bwapi/request.rb
CHANGED
@@ -50,35 +50,38 @@ module BWAPI
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
#
|
53
|
+
# Sets connection options
|
54
54
|
#
|
55
|
-
# @param
|
56
|
-
# @
|
57
|
-
|
58
|
-
|
59
|
-
def request method, path, opts={}
|
60
|
-
conn_opts = {
|
55
|
+
# @param opts [Hash] hash of opts passed
|
56
|
+
# @return [Hash] connection options
|
57
|
+
def connection_options opts
|
58
|
+
{
|
61
59
|
:headers => {
|
60
|
+
:authorization => access_token ? "bearer #{access_token}" : "",
|
62
61
|
:user_agent => user_agent
|
63
62
|
},
|
64
63
|
:force_urlencoded => opts.delete(:force_urlencoded) || false,
|
65
64
|
:url => api_endpoint,
|
66
65
|
:ssl => {:verify => verify_ssl}
|
67
66
|
}
|
67
|
+
end
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
# Perform a request
|
70
|
+
#
|
71
|
+
# @param method [String] Type of request path
|
72
|
+
# @param path [String] URL path to send request
|
73
|
+
# @param opts [Hash] Request parameters
|
74
|
+
# @return [Hashie::Mash] Response
|
75
|
+
def request method, path, opts={}
|
76
|
+
conn_options = connection_options opts
|
77
|
+
response = connection(conn_options).send(method) do |request|
|
75
78
|
case method
|
76
79
|
when :get
|
77
80
|
request.url path, opts
|
78
81
|
when :delete
|
79
82
|
request.url path, opts
|
80
83
|
when :patch, :post, :put
|
81
|
-
if
|
84
|
+
if conn_options[:force_urlencoded]
|
82
85
|
request.url path, opts
|
83
86
|
else
|
84
87
|
request.path = path
|
data/lib/bwapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bwapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Chrisp
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.0.
|
197
|
+
rubygems_version: 2.0.7
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Brandwatch v2 API Wrapper
|