@@ -5,6 +5,7 @@ class Monitor
55 attr_reader :key , :api_key , :api_version , :env
66
77 PING_RETRY_THRESHOLD = 3
8+ MONITOR_API_URL = 'https://cronitor.io/api/monitors'
89
910 module Formats
1011 ALL = [
@@ -24,13 +25,12 @@ module Headers
2425 } )
2526 end
2627
27-
2828 def self . put ( opts = { } )
2929 rollback = opts [ :rollback ] || false
3030 opts . delete ( :rollback )
3131
3232 monitors = opts [ :monitors ] || [ opts ]
33- url = "https://cronitor.io/api/monitors"
33+ url = MONITOR_API_URL
3434 if opts [ :format ] == Cronitor ::Monitor ::Formats ::YAML
3535 url = "#{ url } .yaml"
3636 monitors [ 'rollback' ] = true if rollback
@@ -77,12 +77,12 @@ def self.put(opts = {})
7777 end
7878 end
7979
80- def self . delete ( key )
80+ def delete
8181 resp = HTTParty . delete (
82- "#{ Cronitor . monitor_api_url } /#{ key } " ,
82+ "#{ monitor_api_url } /#{ key } " ,
8383 timeout : Cronitor . timeout ,
8484 basic_auth : {
85- username : Cronitor . api_key ,
85+ username : api_key ,
8686 password : ''
8787 } ,
8888 headers : Cronitor ::Monitor ::Headers ::JSON
@@ -187,10 +187,9 @@ def fallback_ping_api_url
187187 end
188188
189189 def monitor_api_url
190- "https://cronitor.io/api/monitors"
190+ MONITOR_API_URL
191191 end
192192
193-
194193 private
195194
196195 def fetch
@@ -219,7 +218,7 @@ def clean_params(params)
219218 message : params . fetch ( :message , nil ) ,
220219 series : params . fetch ( :series , nil ) ,
221220 host : params . fetch ( :host , Socket . gethostname ) ,
222- metric : params [ :metrics ] ? params [ :metrics ] . map { |k , v | "#{ k } :#{ v } " } : nil ,
221+ metric : params [ :metrics ] & .map { |k , v | "#{ k } :#{ v } " } ,
223222 stamp : Time . now . to_f ,
224223 env : params . fetch ( :env , env )
225224 }
0 commit comments