pingboard 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 187e7f10439900d992e6039ed5170364bca739fb
4
- data.tar.gz: 712674cb12a728c694c435f4a5d636457eb1659a
3
+ metadata.gz: c3b969ab807311476df36a6804141dfc4b2f7f66
4
+ data.tar.gz: ec03d39b5b31c5739745d377b53471df09d95a2c
5
5
  SHA512:
6
- metadata.gz: c2b57635f5a6c337200c1e3823f04f45146f1f4b6e25e16fffdae471b285eb0f23bcba437dfc8f1150c2ece6b46035fd7796499aa82c59f892d22c1b5f3a3b4e
7
- data.tar.gz: 74ebfcdbfc14584e059ea19963ba02afe370e39abae03267e7e0e0002e97e6dac113685b78b3824a430d32d609f95e18c499867d7dd080bc655be72f97e8a994
6
+ metadata.gz: da1c270d59d4d5134468af64cc53df26c138bb6d7d7fde97fb795fb49c30fbf3f9e193a033c4018074076cf6c5f17de88c0fd143f304f9032faf258e0944c494
7
+ data.tar.gz: ca2c407572a28b3a9415d1112094d9df0d9ed3314c57c24ddbf692a87e817ae036ea74c35fb4524fe88b2794eafc83fc0713a8d97170fc0a6faca4d69f62e7ea
data/README.md CHANGED
@@ -22,7 +22,7 @@ gem install pingboard
22
22
 
23
23
  ### Gemfile
24
24
  ```
25
- gem 'pingboard', '~> 0.0.7'
25
+ gem 'pingboard', '~> 0.0.9'
26
26
  ```
27
27
 
28
28
  ## Documentation
@@ -23,61 +23,61 @@ module Pingboard
23
23
 
24
24
  def search(query, options={})
25
25
  options.merge!(q: query)
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
26
+ response = build_request(
27
+ self,
28
+ :get,
29
+ URL_API_VERSION_PATH + URL_SEARCH_USERS_PATH,
30
+ {'Authorization' => "Bearer #{access_token}" },
31
+ nil,
32
+ options
33
33
  ).do
34
34
  JSON.parse(response.body)
35
35
  end
36
36
 
37
37
  def users(options={})
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
38
+ response = build_request(
39
+ self,
40
+ :get,
41
+ URL_API_VERSION_PATH + URL_USERS_PATH,
42
+ {'Authorization' => "Bearer #{access_token}" },
43
+ nil,
44
+ options
45
45
  ).do
46
46
  JSON.parse(response.body)
47
47
  end
48
48
 
49
49
  def user(user_id, options={})
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
50
+ response = build_request(
51
+ self,
52
+ :get,
53
+ URL_API_VERSION_PATH + URL_USERS_PATH + "/#{user_id}",
54
+ {'Authorization' => "Bearer #{access_token}" },
55
+ nil,
56
+ options
57
57
  ).do
58
58
  JSON.parse(response.body)
59
59
  end
60
60
 
61
61
  def status(status_id, options={})
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
62
+ response = build_request(
63
+ self,
64
+ :get,
65
+ URL_API_VERSION_PATH + URL_STATUSES_PATH + "/#{status_id}",
66
+ {'Authorization' => "Bearer #{access_token}" },
67
+ nil,
68
+ options
69
69
  ).do
70
70
  JSON.parse(response.body)
71
71
  end
72
72
 
73
73
  def status_types
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
74
+ response = build_request(
75
+ self,
76
+ :get,
77
+ URL_API_VERSION_PATH + URL_STATUS_TYPES_PATH,
78
+ {'Authorization' => "Bearer #{access_token}" },
79
+ nil,
80
+ nil
81
81
  ).do
82
82
  JSON.parse(response.body)
83
83
  end
@@ -93,6 +93,17 @@ module Pingboard
93
93
 
94
94
  private
95
95
 
96
+ def build_request(client, http_verb, path, headers, body, params)
97
+ @request.new(
98
+ client: client,
99
+ http_verb: http_verb,
100
+ path: path,
101
+ headers: headers,
102
+ body: body,
103
+ params: params
104
+ )
105
+ end
106
+
96
107
  def access_token_expired?
97
108
  Time.now > token_expiration_time
98
109
  end
@@ -105,13 +116,13 @@ module Pingboard
105
116
  end
106
117
 
107
118
  def access_token_request
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' }
119
+ @access_token_request = build_request(
120
+ self,
121
+ :post,
122
+ URL_OAUTH_TOKEN_PATH,
123
+ { 'Content-Type' => 'application/x-www-form-urlencoded' },
124
+ { 'client_id' => "#{service_app_id}", 'client_secret' => "#{service_app_secret}" },
125
+ { 'grant_type' => 'client_credentials' }
115
126
  ).do
116
127
  end
117
128
 
@@ -13,13 +13,12 @@ module Pingboard
13
13
  end
14
14
 
15
15
  def do
16
- @test = @client.connection.public_send(@http_verb) do |request|
16
+ @client.connection.public_send(@http_verb) do |request|
17
17
  request.url "#{@path}"
18
18
  set_headers!(request) if headers
19
19
  set_body!(request) if body
20
20
  set_params!(request) if params
21
21
  end
22
- @test
23
22
  end
24
23
 
25
24
  private
@@ -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.8'
7
- s.date = '2017-08-05'
6
+ s.version = '0.0.9'
7
+ s.date = '2017-08-06'
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.8
4
+ version: 0.0.9
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-08-05 00:00:00.000000000 Z
11
+ date: 2017-08-06 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