pingboard 0.0.7 → 0.0.8
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 +4 -4
- data/lib/pingboard/client.rb +48 -13
- data/lib/pingboard/request.rb +25 -9
- data/pingboard.gemspec +2 -2
- 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: 187e7f10439900d992e6039ed5170364bca739fb
|
4
|
+
data.tar.gz: 712674cb12a728c694c435f4a5d636457eb1659a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2b57635f5a6c337200c1e3823f04f45146f1f4b6e25e16fffdae471b285eb0f23bcba437dfc8f1150c2ece6b46035fd7796499aa82c59f892d22c1b5f3a3b4e
|
7
|
+
data.tar.gz: 74ebfcdbfc14584e059ea19963ba02afe370e39abae03267e7e0e0002e97e6dac113685b78b3824a430d32d609f95e18c499867d7dd080bc655be72f97e8a994
|
data/lib/pingboard/client.rb
CHANGED
@@ -23,27 +23,62 @@ module Pingboard
|
|
23
23
|
|
24
24
|
def search(query, options={})
|
25
25
|
options.merge!(q: query)
|
26
|
-
response = @request.new(
|
26
|
+
response = @request.new(
|
27
|
+
client: self,
|
28
|
+
http_verb: :get,
|
29
|
+
path: URL_API_VERSION_PATH + URL_SEARCH_USERS_PATH,
|
30
|
+
headers: {'Authorization' => "Bearer #{access_token}" },
|
31
|
+
body: nil,
|
32
|
+
params: options
|
33
|
+
).do
|
27
34
|
JSON.parse(response.body)
|
28
35
|
end
|
29
36
|
|
30
37
|
def users(options={})
|
31
|
-
response = @request.new(
|
38
|
+
response = @request.new(
|
39
|
+
client: self,
|
40
|
+
http_verb: :get,
|
41
|
+
path: URL_API_VERSION_PATH + URL_USERS_PATH,
|
42
|
+
headers: {'Authorization' => "Bearer #{access_token}" },
|
43
|
+
body: nil,
|
44
|
+
params: options
|
45
|
+
).do
|
32
46
|
JSON.parse(response.body)
|
33
47
|
end
|
34
48
|
|
35
49
|
def user(user_id, options={})
|
36
|
-
response = @request.new(
|
50
|
+
response = @request.new(
|
51
|
+
client: self,
|
52
|
+
http_verb: :get,
|
53
|
+
path: URL_API_VERSION_PATH + URL_USERS_PATH + "/#{user_id}",
|
54
|
+
headers: {'Authorization' => "Bearer #{access_token}" },
|
55
|
+
body: nil,
|
56
|
+
params: options
|
57
|
+
).do
|
37
58
|
JSON.parse(response.body)
|
38
59
|
end
|
39
60
|
|
40
61
|
def status(status_id, options={})
|
41
|
-
response = @request.new(
|
62
|
+
response = @request.new(
|
63
|
+
client: self,
|
64
|
+
http_verb: :get,
|
65
|
+
path: URL_API_VERSION_PATH + URL_STATUSES_PATH + "/#{status_id}",
|
66
|
+
headers: {'Authorization' => "Bearer #{access_token}" },
|
67
|
+
body: nil,
|
68
|
+
params: options
|
69
|
+
).do
|
42
70
|
JSON.parse(response.body)
|
43
71
|
end
|
44
72
|
|
45
73
|
def status_types
|
46
|
-
response = @request.new(
|
74
|
+
response = @request.new(
|
75
|
+
client: self,
|
76
|
+
http_verb: :get,
|
77
|
+
path: URL_API_VERSION_PATH + URL_STATUS_TYPES_PATH,
|
78
|
+
headers: {'Authorization' => "Bearer #{access_token}" },
|
79
|
+
body: nil,
|
80
|
+
params: nil
|
81
|
+
).do
|
47
82
|
JSON.parse(response.body)
|
48
83
|
end
|
49
84
|
|
@@ -70,14 +105,14 @@ module Pingboard
|
|
70
105
|
end
|
71
106
|
|
72
107
|
def access_token_request
|
73
|
-
@access_token_request =
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
}
|
80
|
-
|
108
|
+
@access_token_request = @request.new(
|
109
|
+
client: self,
|
110
|
+
http_verb: :post,
|
111
|
+
path: URL_OAUTH_TOKEN_PATH,
|
112
|
+
headers: { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
113
|
+
body: { 'client_id' => "#{service_app_id}", 'client_secret' => "#{service_app_secret}" },
|
114
|
+
params: { 'grant_type' => 'client_credentials' }
|
115
|
+
).do
|
81
116
|
end
|
82
117
|
|
83
118
|
end
|
data/lib/pingboard/request.rb
CHANGED
@@ -1,23 +1,39 @@
|
|
1
1
|
module Pingboard
|
2
2
|
class Request
|
3
3
|
|
4
|
-
attr_accessor :client, :path, :http_verb
|
4
|
+
attr_accessor :client, :path, :http_verb, :headers, :body, :params
|
5
5
|
|
6
|
-
def initialize(client
|
6
|
+
def initialize(client:, http_verb:, path:, headers:, body:, params: {})
|
7
7
|
@client = client
|
8
8
|
@http_verb = http_verb
|
9
9
|
@path = path
|
10
|
-
@
|
10
|
+
@headers = headers
|
11
|
+
@body = body
|
12
|
+
@params = params
|
11
13
|
end
|
12
14
|
|
13
15
|
def do
|
14
|
-
@client.connection.public_send(@http_verb) do |
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
16
|
+
@test = @client.connection.public_send(@http_verb) do |request|
|
17
|
+
request.url "#{@path}"
|
18
|
+
set_headers!(request) if headers
|
19
|
+
set_body!(request) if body
|
20
|
+
set_params!(request) if params
|
20
21
|
end
|
22
|
+
@test
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def set_body!(request)
|
28
|
+
request.body = body
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_headers!(request)
|
32
|
+
headers.each { |key, value| request.headers["#{key}"] = value }
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_params!(request)
|
36
|
+
params.each { |key, value| request.params["#{key}"] = value }
|
21
37
|
end
|
22
38
|
|
23
39
|
end
|
data/pingboard.gemspec
CHANGED
@@ -3,8 +3,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'pingboard'
|
6
|
-
s.version = '0.0.
|
7
|
-
s.date = '2017-
|
6
|
+
s.version = '0.0.8'
|
7
|
+
s.date = '2017-08-05'
|
8
8
|
s.summary = "The Pingboard API Ruby Client"
|
9
9
|
s.description = "A Ruby client interface for the Pingboard API"
|
10
10
|
s.authors = ["Bryan B. Cabalo"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan B. Cabalo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby client interface for the Pingboard API
|
14
14
|
email: bcabalo@gmail.com
|