Permalink
Browse files

Added summary to rakefile

  • Loading branch information...
1 parent a231516 commit 061a4aa6a456ad2cdae826a4810d067d41197517 @cstrouse cstrouse committed Jan 7, 2012
Showing with 37 additions and 27 deletions.
  1. +1 −1 Rakefile
  2. +8 −0 example/custom_monitor_ex.rb
  3. +28 −26 lib/monitis-SDK/base.rb
View
2 Rakefile
@@ -17,7 +17,7 @@ Jeweler::Tasks.new do |gem|
gem.name = "monitis-SDK"
gem.homepage = "http://github.com/anjain/monitis-SDK"
gem.license = "MIT"
- gem.summary = %Q{TODO: one-line summary of your gem}
+ gem.summary = "Ruby interface to the Monitis, all-in-one IT monitoring platform (http://www.monitis.com)"
gem.description = %Q{TODO: longer description of your gem}
gem.email = "ankur.jain24@gmail.com"
gem.authors = ["Ankur"]
View
8 example/custom_monitor_ex.rb
@@ -0,0 +1,8 @@
+require File.join('..','lib','monitis-SDK')
+
+apikey = '7DA0AN1D950FBI7VLR967QH3NK'
+secretkey = '3QMQQRTK3HSH6ISQ11UI3AGIPF'
+
+monitor = CustomMonitors.new(apikey, secretkey)
+
+#monitor.addMonitor()
View
54 lib/monitis-SDK/base.rb
@@ -1,23 +1,24 @@
class Base
BASE_URL ="http://www.monitis.com/api"
+ SANDBOX_URL = 'http://sandbox.monitis.com/api'
VERSION="2"
-attr_accessor :apikey,:secretkey,:authtoken
+
+ attr_accessor :apikey, :secretkey, :authtoken
- def initialize(apikey,secretkey)
- @apikey,@secretkey=apikey,secretkey
- @authtoken=getAuthToken
-# @default_options=}
-
-end
+ def initialize(apikey, secretkey)
+ @apikey, @secretkey = apikey, secretkey
+ @authtoken = getAuthToken
+ # @default_options=}
+ end
- def get(action,options={})
- res=HTTParty.get(BASE_URL,build_get_request(action,options))
+ def get(action, options = {})
+ res = HTTParty.get(BASE_URL, build_get_request(action, options))
parse_response(res)
end
- def post(action,options={})
- res=HTTParty.post(BASE_URL,:body=>build_request(action,options))
+ def post(action, options = {})
+ res = HTTParty.post(BASE_URL, :body => build_request(action, options))
parse_response(res)
end
@@ -28,30 +29,31 @@ def parse_response(response)
end
def build_request(action, options={})
- options.merge!({
- :apikey=>@apikey, :version=>VERSION ,:validation=>"token",
- :timestamp=> Time.now.strftime("%Y-%m-%d %H:%m:%S"),
- :authToken=>@authtoken,
- :action=>action})
+ options.merge!({
+ :apikey => @apikey,
+ :version => VERSION,
+ :validation => "token",
+ :timestamp => Time.now.strftime("%Y-%m-%d %H:%m:%S"),
+ :authToken => @authtoken,
+ :action => action
+ })
end
- def build_get_request(action,options={})
- options={:query=>build_request(action,options)}
+ def build_get_request(action, options = {})
+ options = {:query => build_request(action, options)}
# pp options
end
- def getAuthToken
+ def getAuthToken()
if @authtoken.nil?
- options={:query=>{:action=> "authToken" ,:apikey=>@apikey,:secretkey=>@secretkey }}
- res=HTTParty.get(BASE_URL,options)
- @authtoken=parse_response(res).fetch("authToken")
+ options = {:query => {:action => "authToken", :apikey => @apikey, :secretkey => @secretkey }}
+ res = HTTParty.get(BASE_URL,options)
+ @authtoken = parse_response(res).fetch("authToken")
else
@authtoken
end
- pp @authtoken
+ pp @authtoken
end
# Crack::JSON.parse(json).fetch("authToken")
-
-end
-
+end

0 comments on commit 061a4aa

Please sign in to comment.