uptimerobot 0.1.2 → 0.1.3

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: 006ec7202822a33f9317f61b64d60b7140ff00f5
4
- data.tar.gz: 65078bd836e6a1ebf9785bd963393ce69fb9a244
3
+ metadata.gz: b2dd9afefcc2700e84aee76b59b8eff83f6b4189
4
+ data.tar.gz: 759431d88327f91c1a390f3befa84f71e9d67ab5
5
5
  SHA512:
6
- metadata.gz: da1b503a92834da031af255877d716e145e96206a07814294e09d1c0d40036cb58df31dd5133a4f25cf9782d52e5096c0fe4da398bfdbb43ca95e5af74ae950b
7
- data.tar.gz: 411656731c19126fe966e0fe3ce0f0fedb34226c67794ac22f8c532225bb4fe422a1f97a737248b9929020b66967881421172975f88f76d1d381cb8a781c0524
6
+ metadata.gz: 58f973019110873771c81b56930fd33f88ba38c90f37ce0f12871827b36119a6dffc00af77d7b6e820da30f3209d20dcf12f9781586856501bfe1cadca551e81
7
+ data.tar.gz: 6318681db5a9db150551477735b3724c7089618f827f8153eaa88daf8081dd6ee07d9956a469bc65707057243bf2110e106234d36043c15c486367c395d77795
@@ -20,6 +20,7 @@ class UptimeRobot::Client
20
20
 
21
21
  def initialize(options)
22
22
  @apiKey = options.delete(:apiKey)
23
+ @raise_no_monitors_error = !!options.delete(:raise_no_monitors_error)
23
24
 
24
25
  raise ArgumentError, ':apiKey is required' unless @apiKey
25
26
 
@@ -73,7 +74,18 @@ class UptimeRobot::Client
73
74
  json = response.body
74
75
 
75
76
  if json['stat'] != 'ok'
76
- raise UptimeRobot::Error.new(json)
77
+ if json['id'] == '212'
78
+ if @raise_no_monitors_error
79
+ raise UptimeRobot::Error.new(json)
80
+ else
81
+ json.update(
82
+ 'total' => '0',
83
+ 'monitors' => {'monitor' => []}
84
+ )
85
+ end
86
+ else
87
+ raise UptimeRobot::Error.new(json)
88
+ end
77
89
  end
78
90
 
79
91
  json
@@ -1,3 +1,3 @@
1
1
  module UptimeRobot
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -328,4 +328,40 @@ describe UptimeRobot::Client do
328
328
  }.to raise_error(ArgumentError, ':apiKey is required')
329
329
  end
330
330
  end
331
+
332
+ context 'when account has no monitors' do
333
+ let(:response) {
334
+ {"stat"=>"fail", "id"=>"212", "message"=>"The account has no monitors"}
335
+ }
336
+
337
+ it do
338
+ client = uptime_robot do |stub|
339
+ stub.get('getAccountDetails') do |env|
340
+ expect(env.params).to eq DEFAULT_PARAMS
341
+ [200, {'Content-Type' => 'json'}, JSON.dump(response)]
342
+ end
343
+ end
344
+
345
+ expect(client.getAccountDetails).to eq(
346
+ {"stat"=>"fail",
347
+ "id"=>"212",
348
+ "message"=>"The account has no monitors",
349
+ "total"=>"0",
350
+ "monitors"=>{"monitor"=>[]}}
351
+ )
352
+ end
353
+
354
+ it do
355
+ client = uptime_robot(:raise_no_monitors_error => true) do |stub|
356
+ stub.get('getAccountDetails') do |env|
357
+ expect(env.params).to eq DEFAULT_PARAMS
358
+ [200, {'Content-Type' => 'json'}, JSON.dump(response)]
359
+ end
360
+ end
361
+
362
+ expect {
363
+ client.getAccountDetails
364
+ }.to raise_error(UptimeRobot::Error, '{"stat"=>"fail", "id"=>"212", "message"=>"The account has no monitors"}')
365
+ end
366
+ end
331
367
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uptimerobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-30 00:00:00.000000000 Z
11
+ date: 2014-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday