uptimerobot 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -18
- data/lib/uptimerobot/client.rb +14 -12
- data/lib/uptimerobot/version.rb +2 -1
- data/spec/spec_helper.rb +6 -2
- data/spec/uptimerobot_spec.rb +133 -131
- data/uptimerobot.gemspec +1 -1
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1993c46b627fd5689996d88ea4d3e8de1da5448c
|
4
|
+
data.tar.gz: 4d4b5a3be56bbbf98826517bc3406adf36d93892
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 337ade622bc9b4d61de52b342245c37cc1bc0f3e4b1b7fe92857ab937bb3015cbef207ed0fa4e604c10fd67a120a2cf8f0a79ec2a051815fbd8636b812852359
|
7
|
+
data.tar.gz: 71790ccf81cc7ccf177efcd53704026db016f14bcdffd155fd1b9e90665e10cad609785bdb7e09c500b601f871b1114d0e3719366ebc29d13c9b2f99b805c3b7
|
data/README.md
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
# UptimeRobot
|
2
2
|
|
3
|
-
[Uptime Robot](https://uptimerobot.com/)
|
3
|
+
[Uptime Robot](https://uptimerobot.com/) APIv2 client for Ruby.
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/uptimerobot.svg)](http://badge.fury.io/rb/uptimerobot)
|
6
6
|
[![Build Status](https://travis-ci.org/winebarrel/uptimerobot.svg?branch=master)](https://travis-ci.org/winebarrel/uptimerobot)
|
7
7
|
|
8
|
+
### Notice
|
9
|
+
|
10
|
+
Currently, this library uses APIv2.
|
11
|
+
|
12
|
+
If you want to use APIv1, please specify it as follows:
|
13
|
+
|
14
|
+
```
|
15
|
+
gem 'uptimerobot', '~> 0.1.6'
|
16
|
+
```
|
17
|
+
|
8
18
|
## Installation
|
9
19
|
|
10
20
|
Add this line to your application's Gemfile:
|
@@ -26,27 +36,38 @@ Or install it yourself as:
|
|
26
36
|
```ruby
|
27
37
|
require 'uptimerobot'
|
28
38
|
|
29
|
-
client = UptimeRobot::Client.new(
|
39
|
+
client = UptimeRobot::Client.new(api_key: 'u956-afus321g565fghr519')
|
30
40
|
|
31
41
|
client.getMonitors
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
# "
|
36
|
-
# "
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
42
|
+
# {
|
43
|
+
# "stat": "ok",
|
44
|
+
# "pagination": {
|
45
|
+
# "offset": 0,
|
46
|
+
# "limit": 50,
|
47
|
+
# "total": 2
|
48
|
+
# },
|
49
|
+
# "monitors": [
|
50
|
+
# {
|
51
|
+
# "id": 777749809,
|
52
|
+
# "friendly_name": "Google",
|
53
|
+
# "url": "http://www.google.com",
|
54
|
+
# "type": 1,
|
55
|
+
# ...
|
56
|
+
# },
|
57
|
+
# {
|
58
|
+
# "id": 777712827,
|
59
|
+
# "friendly_name": "My Web Page",
|
60
|
+
# "url": "http://mywebpage.com/",
|
61
|
+
# "type": 1,
|
62
|
+
# ...
|
63
|
+
# },
|
64
|
+
# ...
|
44
65
|
|
45
66
|
client.newMonitor(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
67
|
+
friendly_name: 'Google',
|
68
|
+
url: 'http://www.google.com',
|
69
|
+
type: UptimeRobot::Monitor::Type::HTTP,
|
70
|
+
alert_contacts: '448,716'
|
50
71
|
)
|
51
72
|
```
|
52
73
|
|
data/lib/uptimerobot/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class UptimeRobot::Client
|
2
|
-
ENDPOINT =
|
3
|
-
USER_AGENT = "Ruby UptimeRobot Client #{UptimeRobot::
|
2
|
+
ENDPOINT = "https://api.uptimerobot.com/"
|
3
|
+
USER_AGENT = "Ruby UptimeRobot Client #{UptimeRobot::GEM_VERSION}"
|
4
4
|
|
5
5
|
METHODS = [
|
6
6
|
:getAccountDetails,
|
@@ -19,9 +19,10 @@ class UptimeRobot::Client
|
|
19
19
|
]
|
20
20
|
|
21
21
|
OPTIONS = [
|
22
|
-
:
|
22
|
+
:api_key,
|
23
23
|
:raise_no_monitors_error,
|
24
|
-
:skip_unescape_monitor
|
24
|
+
:skip_unescape_monitor,
|
25
|
+
:debug
|
25
26
|
]
|
26
27
|
|
27
28
|
def initialize(options)
|
@@ -31,7 +32,7 @@ class UptimeRobot::Client
|
|
31
32
|
@options[key] = options.delete(key)
|
32
33
|
end
|
33
34
|
|
34
|
-
raise ArgumentError, ':
|
35
|
+
raise ArgumentError, ':api_key is required' unless @options[:api_key]
|
35
36
|
|
36
37
|
options[:url] ||= ENDPOINT
|
37
38
|
|
@@ -39,6 +40,7 @@ class UptimeRobot::Client
|
|
39
40
|
faraday.request :url_encoded
|
40
41
|
faraday.response :json, :content_type => /\bjson$/
|
41
42
|
faraday.response :raise_error
|
43
|
+
faraday.response :logger, ::Logger.new(STDOUT), bodies: true if @options[:debug]
|
42
44
|
|
43
45
|
yield(faraday) if block_given?
|
44
46
|
|
@@ -69,14 +71,14 @@ class UptimeRobot::Client
|
|
69
71
|
|
70
72
|
def request(method_name, params = {})
|
71
73
|
params.update(
|
72
|
-
:
|
74
|
+
:api_key => @options[:api_key],
|
73
75
|
:format => 'json',
|
74
76
|
:noJsonCallback => 1
|
75
77
|
)
|
76
78
|
|
77
|
-
response = @conn.
|
78
|
-
req.url "/#{method_name}"
|
79
|
-
req.
|
79
|
+
response = @conn.post do |req|
|
80
|
+
req.url "/#{UptimeRobot::API_VERSION}/#{method_name}"
|
81
|
+
req.body = URI.encode_www_form(params)
|
80
82
|
yield(req) if block_given?
|
81
83
|
end
|
82
84
|
|
@@ -98,7 +100,7 @@ class UptimeRobot::Client
|
|
98
100
|
else
|
99
101
|
json.update(
|
100
102
|
'total' => '0',
|
101
|
-
'monitors' =>
|
103
|
+
'monitors' => []
|
102
104
|
)
|
103
105
|
end
|
104
106
|
else
|
@@ -108,8 +110,8 @@ class UptimeRobot::Client
|
|
108
110
|
end
|
109
111
|
|
110
112
|
def unescape_monitor!(json)
|
111
|
-
json['monitors']
|
112
|
-
%w(
|
113
|
+
json['monitors'].each do |monitor|
|
114
|
+
%w(friendly_name keyword_value http_username http_password).each do |key|
|
113
115
|
value = monitor[key] || ''
|
114
116
|
next if value.empty?
|
115
117
|
monitor[key] = CGI.unescapeHTML(value)
|
data/lib/uptimerobot/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
require 'uptimerobot'
|
2
2
|
|
3
3
|
DEFAULT_PARAMS = {
|
4
|
-
'
|
4
|
+
'api_key' => 'ZAPZAPZAP',
|
5
5
|
'format' => 'json',
|
6
6
|
'noJsonCallback' => '1'
|
7
7
|
}
|
8
8
|
|
9
|
+
def decoded_request_body(body)
|
10
|
+
Hash[URI.decode_www_form(body)]
|
11
|
+
end
|
12
|
+
|
9
13
|
def uptime_robot(options = {})
|
10
|
-
options = {
|
14
|
+
options = {api_key: 'ZAPZAPZAP'}.merge(options)
|
11
15
|
|
12
16
|
stubs = Faraday::Adapter::Test::Stubs.new
|
13
17
|
|
data/spec/uptimerobot_spec.rb
CHANGED
@@ -11,12 +11,13 @@ describe UptimeRobot::Client do
|
|
11
11
|
|
12
12
|
it do
|
13
13
|
client = uptime_robot do |stub|
|
14
|
-
stub.
|
15
|
-
expect(env.
|
16
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
14
|
+
stub.post('/v2/getAccountDetails') do |env|
|
15
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS
|
16
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
|
20
21
|
expect(client.getAccountDetails).to eq response
|
21
22
|
end
|
22
23
|
end
|
@@ -25,89 +26,90 @@ describe UptimeRobot::Client do
|
|
25
26
|
let(:params) do
|
26
27
|
{
|
27
28
|
:logs => 1,
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
29
|
+
:alert_contacts => 1,
|
30
|
+
:response_times => 1,
|
31
|
+
:response_times_average => 180,
|
31
32
|
:monitors => '15830-32696'
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
35
36
|
let(:response) do
|
36
37
|
{"stat"=>"ok",
|
37
|
-
"
|
38
|
-
|
39
|
-
|
38
|
+
"pagination"=>{
|
39
|
+
"offset"=>"0",
|
40
|
+
"limit"=>"50",
|
41
|
+
"total"=>"2"
|
42
|
+
},
|
40
43
|
"monitors"=>
|
41
|
-
{"
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
{"datetime"=>"02/04/2014 12:48:41", "value"=>"780"}]}]}}
|
44
|
+
[{"id"=>"128795",
|
45
|
+
"friendlyname"=>"Yahoo",
|
46
|
+
"url"=>"http://www.yahoo.com/",
|
47
|
+
"type"=>"1",
|
48
|
+
"subtype"=>"",
|
49
|
+
"keywordtype"=>"0",
|
50
|
+
"keywordvalue"=>"",
|
51
|
+
"httpusername"=>"",
|
52
|
+
"httppassword"=>"",
|
53
|
+
"port"=>"",
|
54
|
+
"interval"=>"300",
|
55
|
+
"status"=>"2",
|
56
|
+
"alltimeuptimeratio"=>"99.98",
|
57
|
+
"customuptimeratio"=>"100.00",
|
58
|
+
"alertcontact"=>
|
59
|
+
[{"id"=>"4631", "type"=>"2", "value"=>"uptime@webresourcesdepot.com"},
|
60
|
+
{"id"=>"2420", "type"=>"3", "value"=>"umutm"}],
|
61
|
+
"log"=>
|
62
|
+
[{"type"=>"2",
|
63
|
+
"datetime"=>"09/25/2011 16:12:44",
|
64
|
+
"alertcontact"=>
|
65
|
+
[{"type"=>"0", "value"=>"uptime@webresourcesdepot.com"},
|
66
|
+
{"type"=>"3", "value"=>"umutm"}]},
|
67
|
+
{"type"=>"1",
|
68
|
+
"datetime"=>"09/25/2011 16:11:44",
|
69
|
+
"alertcontact"=>
|
70
|
+
[{"type"=>"0", "value"=>"uptime@webresourcesdepot.com"},
|
71
|
+
{"type"=>"3", "value"=>"umutm"}]}],
|
72
|
+
"responsetime"=>
|
73
|
+
[{"datetime"=>"02/04/2014 11:30:41", "value"=>"405"},
|
74
|
+
{"datetime"=>"02/04/2014 12:00:41", "value"=>"516"},
|
75
|
+
{"datetime"=>"02/04/2014 12:30:41", "value"=>"780"}]},
|
76
|
+
{"id"=>"128796",
|
77
|
+
"friendlyname"=>"WebResourcesDepot",
|
78
|
+
"url"=>"http://www.webresourcesdepot.com/",
|
79
|
+
"type"=>"1",
|
80
|
+
"subtype"=>"",
|
81
|
+
"keywordtype"=>"0",
|
82
|
+
"keywordvalue"=>"",
|
83
|
+
"httpusername"=>"",
|
84
|
+
"httppassword"=>"",
|
85
|
+
"port"=>"",
|
86
|
+
"interval"=>"300",
|
87
|
+
"status"=>"2",
|
88
|
+
"alltimeuptimeratio"=>"99.94",
|
89
|
+
"customtimeuptimeratio"=>"89.51",
|
90
|
+
"alertcontact"=>[{"id"=>"2420", "type"=>"3", "value"=>"umutm"}],
|
91
|
+
"log"=>
|
92
|
+
[{"type"=>"2",
|
93
|
+
"datetime"=>"08/30/2011 16:11:15",
|
94
|
+
"alertcontact"=>
|
95
|
+
[{"type"=>"0", "value"=>"uptime@webresourcesdepot.com"},
|
96
|
+
{"type"=>"3", "value"=>"umutm"}]},
|
97
|
+
{"type"=>"1",
|
98
|
+
"datetime"=>"08/30/2011 16:09:30",
|
99
|
+
"alertcontact"=>
|
100
|
+
[{"type"=>"0", "value"=>"uptime@webresourcesdepot.com"},
|
101
|
+
{"type"=>"3", "value"=>"umutm"}]}],
|
102
|
+
"responsetime"=>
|
103
|
+
[{"datetime"=>"02/04/2014 11:48:41", "value"=>"405"},
|
104
|
+
{"datetime"=>"02/04/2014 12:18:41", "value"=>"516"},
|
105
|
+
{"datetime"=>"02/04/2014 12:48:41", "value"=>"780"}]}]}
|
104
106
|
end
|
105
107
|
|
106
108
|
it do
|
107
109
|
client = uptime_robot do |stub|
|
108
|
-
stub.
|
109
|
-
expect(env.
|
110
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
110
|
+
stub.post('/v2/getMonitors') do |env|
|
111
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
112
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
@@ -117,29 +119,29 @@ describe UptimeRobot::Client do
|
|
117
119
|
context 'when include escaped string' do
|
118
120
|
let(:response_with_escaped_string) do
|
119
121
|
res = response.dup
|
120
|
-
monitor = res['monitors'][
|
121
|
-
monitor['
|
122
|
-
monitor['
|
123
|
-
monitor['
|
124
|
-
monitor['
|
122
|
+
monitor = res['monitors'][0]
|
123
|
+
monitor['friendly_name'] = 'http monitor (basic auth)'
|
124
|
+
monitor['keyword_value'] = '(keyword_value)'
|
125
|
+
monitor['http_username'] = '(http_username)'
|
126
|
+
monitor['http_password'] = '(http_password)'
|
125
127
|
res
|
126
128
|
end
|
127
129
|
|
128
130
|
let(:response_with_unescaped_string) do
|
129
131
|
res = response.dup
|
130
|
-
monitor = res['monitors'][
|
131
|
-
monitor['
|
132
|
-
monitor['
|
133
|
-
monitor['
|
134
|
-
monitor['
|
132
|
+
monitor = res['monitors'][0]
|
133
|
+
monitor['friendly_name'] = 'http monitor (basic auth)'
|
134
|
+
monitor['keyword_value'] = '(keyword_value)'
|
135
|
+
monitor['http_username'] = '(http_username)'
|
136
|
+
monitor['http_password'] = '(http_password)'
|
135
137
|
res
|
136
138
|
end
|
137
139
|
|
138
140
|
it do
|
139
141
|
client = uptime_robot do |stub|
|
140
|
-
stub.
|
141
|
-
expect(env.
|
142
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response_with_escaped_string)]
|
142
|
+
stub.post('/v2/getMonitors') do |env|
|
143
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
144
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response_with_escaped_string)]
|
143
145
|
end
|
144
146
|
end
|
145
147
|
|
@@ -148,9 +150,9 @@ describe UptimeRobot::Client do
|
|
148
150
|
|
149
151
|
it do
|
150
152
|
client = uptime_robot(:skip_unescape_monitor => true) do |stub|
|
151
|
-
stub.
|
152
|
-
expect(env.
|
153
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response_with_escaped_string)]
|
153
|
+
stub.post('/v2/getMonitors') do |env|
|
154
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
155
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response_with_escaped_string)]
|
154
156
|
end
|
155
157
|
end
|
156
158
|
|
@@ -162,10 +164,10 @@ describe UptimeRobot::Client do
|
|
162
164
|
describe '#newMonitor' do
|
163
165
|
let(:params) do
|
164
166
|
{
|
165
|
-
:
|
166
|
-
:
|
167
|
-
:
|
168
|
-
:
|
167
|
+
:friendly_name => 'Google',
|
168
|
+
:url => 'http://www.google.com',
|
169
|
+
:type => UptimeRobot::Monitor::Type::HTTP,
|
170
|
+
:alert_contacts => '448-716'
|
169
171
|
}
|
170
172
|
end
|
171
173
|
|
@@ -175,9 +177,9 @@ describe UptimeRobot::Client do
|
|
175
177
|
|
176
178
|
it do
|
177
179
|
client = uptime_robot do |stub|
|
178
|
-
stub.
|
179
|
-
expect(env.
|
180
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
180
|
+
stub.post('/v2/newMonitor') do |env|
|
181
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
182
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
181
183
|
end
|
182
184
|
end
|
183
185
|
|
@@ -188,8 +190,8 @@ describe UptimeRobot::Client do
|
|
188
190
|
describe '#editMonitor' do
|
189
191
|
let(:params) do
|
190
192
|
{
|
191
|
-
:
|
192
|
-
:
|
193
|
+
:id => 128798,
|
194
|
+
:friendly_name => 'GoogleHomepage'
|
193
195
|
}
|
194
196
|
end
|
195
197
|
|
@@ -199,9 +201,9 @@ describe UptimeRobot::Client do
|
|
199
201
|
|
200
202
|
it do
|
201
203
|
client = uptime_robot do |stub|
|
202
|
-
stub.
|
203
|
-
expect(env.
|
204
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
204
|
+
stub.post('/v2/editMonitor') do |env|
|
205
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
206
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
205
207
|
end
|
206
208
|
end
|
207
209
|
|
@@ -222,9 +224,9 @@ describe UptimeRobot::Client do
|
|
222
224
|
|
223
225
|
it do
|
224
226
|
client = uptime_robot do |stub|
|
225
|
-
stub.
|
226
|
-
expect(env.
|
227
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
227
|
+
stub.post('/v2/deleteMonitor') do |env|
|
228
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
229
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
228
230
|
end
|
229
231
|
end
|
230
232
|
|
@@ -254,9 +256,9 @@ describe UptimeRobot::Client do
|
|
254
256
|
|
255
257
|
it do
|
256
258
|
client = uptime_robot do |stub|
|
257
|
-
stub.
|
258
|
-
expect(env.
|
259
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
259
|
+
stub.post('/v2/getAlertContacts') do |env|
|
260
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
261
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
260
262
|
end
|
261
263
|
end
|
262
264
|
|
@@ -278,9 +280,9 @@ describe UptimeRobot::Client do
|
|
278
280
|
|
279
281
|
it do
|
280
282
|
client = uptime_robot do |stub|
|
281
|
-
stub.
|
282
|
-
expect(env.
|
283
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
283
|
+
stub.post('/v2/newAlertContact') do |env|
|
284
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
285
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
284
286
|
end
|
285
287
|
end
|
286
288
|
|
@@ -301,9 +303,9 @@ describe UptimeRobot::Client do
|
|
301
303
|
|
302
304
|
it do
|
303
305
|
client = uptime_robot do |stub|
|
304
|
-
stub.
|
305
|
-
expect(env.
|
306
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
306
|
+
stub.post('/v2/deleteAlertContact') do |env|
|
307
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS.merge(stringify_hash(params))
|
308
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
307
309
|
end
|
308
310
|
end
|
309
311
|
|
@@ -313,14 +315,14 @@ describe UptimeRobot::Client do
|
|
313
315
|
|
314
316
|
context 'when stat is fail' do
|
315
317
|
let(:response) do
|
316
|
-
{"stat"=>"fail", "id"=>"101", "message"=>"
|
318
|
+
{"stat"=>"fail", "id"=>"101", "message"=>"api_key is wrong"}
|
317
319
|
end
|
318
320
|
|
319
321
|
it do
|
320
322
|
client = uptime_robot do |stub|
|
321
|
-
stub.
|
322
|
-
expect(env.
|
323
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
323
|
+
stub.post('/v2/getAccountDetails') do |env|
|
324
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS
|
325
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
324
326
|
end
|
325
327
|
end
|
326
328
|
|
@@ -333,8 +335,8 @@ describe UptimeRobot::Client do
|
|
333
335
|
context 'when status is not 200' do
|
334
336
|
it do
|
335
337
|
client = uptime_robot do |stub|
|
336
|
-
stub.
|
337
|
-
expect(env.
|
338
|
+
stub.post('/v2/getAccountDetails') do |env|
|
339
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS
|
338
340
|
[500, {}, 'An error occurred on the server when processing the URL']
|
339
341
|
end
|
340
342
|
end
|
@@ -365,11 +367,11 @@ describe UptimeRobot::Client do
|
|
365
367
|
end
|
366
368
|
end
|
367
369
|
|
368
|
-
context 'when
|
370
|
+
context 'when api_key is not passed' do
|
369
371
|
it do
|
370
372
|
expect {
|
371
|
-
uptime_robot(:
|
372
|
-
}.to raise_error(ArgumentError, ':
|
373
|
+
uptime_robot(:api_key => nil)
|
374
|
+
}.to raise_error(ArgumentError, ':api_key is required')
|
373
375
|
end
|
374
376
|
end
|
375
377
|
|
@@ -380,9 +382,9 @@ describe UptimeRobot::Client do
|
|
380
382
|
|
381
383
|
it do
|
382
384
|
client = uptime_robot do |stub|
|
383
|
-
stub.
|
384
|
-
expect(env.
|
385
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
385
|
+
stub.post('/v2/getAccountDetails') do |env|
|
386
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS
|
387
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
386
388
|
end
|
387
389
|
end
|
388
390
|
|
@@ -391,15 +393,15 @@ describe UptimeRobot::Client do
|
|
391
393
|
"id"=>"212",
|
392
394
|
"message"=>"The account has no monitors",
|
393
395
|
"total"=>"0",
|
394
|
-
"monitors"=>
|
396
|
+
"monitors"=>[]}
|
395
397
|
)
|
396
398
|
end
|
397
399
|
|
398
400
|
it do
|
399
401
|
client = uptime_robot(:raise_no_monitors_error => true) do |stub|
|
400
|
-
stub.
|
401
|
-
expect(env.
|
402
|
-
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
|
402
|
+
stub.post('/v2/getAccountDetails') do |env|
|
403
|
+
expect(decoded_request_body(env.body)).to eq DEFAULT_PARAMS
|
404
|
+
[200, {'Content-Type' => 'application/json'}, JSON.dump(response)]
|
403
405
|
end
|
404
406
|
end
|
405
407
|
|
data/uptimerobot.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'uptimerobot/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'uptimerobot'
|
8
|
-
spec.version = UptimeRobot::
|
8
|
+
spec.version = UptimeRobot::GEM_VERSION
|
9
9
|
spec.authors = ['Genki Sugawara']
|
10
10
|
spec.email = ['sgwr_dts@yahoo.co.jp']
|
11
11
|
spec.summary = %q{Uptime Robot API client for Ruby.}
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uptimerobot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday_middleware
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 3.0.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.0.0
|
83
83
|
description: Uptime Robot API client for Ruby.
|
@@ -87,9 +87,9 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
91
|
-
- .rspec
|
92
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
93
|
- Gemfile
|
94
94
|
- LICENSE.txt
|
95
95
|
- README.md
|
@@ -112,17 +112,17 @@ require_paths:
|
|
112
112
|
- lib
|
113
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- -
|
120
|
+
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.6.12
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Uptime Robot API client for Ruby.
|