lib/uptimerobot/client.rb in uptimerobot-0.1.2 vs lib/uptimerobot/client.rb in uptimerobot-0.1.3
- old
+ new
@@ -18,10 +18,11 @@
Faraday::Adapter::Test
]
def initialize(options)
@apiKey = options.delete(:apiKey)
+ @raise_no_monitors_error = !!options.delete(:raise_no_monitors_error)
raise ArgumentError, ':apiKey is required' unless @apiKey
options[:url] ||= ENDPOINT
@@ -71,10 +72,21 @@
end
json = response.body
if json['stat'] != 'ok'
- raise UptimeRobot::Error.new(json)
+ if json['id'] == '212'
+ if @raise_no_monitors_error
+ raise UptimeRobot::Error.new(json)
+ else
+ json.update(
+ 'total' => '0',
+ 'monitors' => {'monitor' => []}
+ )
+ end
+ else
+ raise UptimeRobot::Error.new(json)
+ end
end
json
end
end