Class: FreshServiceApiv2
- Inherits:
-
Object
- Object
- FreshServiceApiv2
- Defined in:
- lib/freshservice_apiv2.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#apikey ⇒ Object
Returns the value of attribute apikey.
-
#baseurl ⇒ Object
Returns the value of attribute baseurl.
-
#header ⇒ Object
Returns the value of attribute header.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #delete(uri) ⇒ Object
- #get(uri) ⇒ Object
-
#initialize(uri) ⇒ FreshServiceApiv2
constructor
A new instance of FreshServiceApiv2.
- #post(uri, data) ⇒ Object
- #update(uri, data) ⇒ Object
Constructor Details
#initialize(uri) ⇒ FreshServiceApiv2
Returns a new instance of FreshServiceApiv2.
8 9 10 |
# File 'lib/freshservice_apiv2.rb', line 8 def initialize(uri) @baseurl = uri.chomp('/') end |
Instance Attribute Details
#apikey ⇒ Object
Returns the value of attribute apikey.
6 7 8 |
# File 'lib/freshservice_apiv2.rb', line 6 def apikey @apikey end |
#baseurl ⇒ Object
Returns the value of attribute baseurl.
6 7 8 |
# File 'lib/freshservice_apiv2.rb', line 6 def baseurl @baseurl end |
#header ⇒ Object
Returns the value of attribute header.
6 7 8 |
# File 'lib/freshservice_apiv2.rb', line 6 def header @header end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/freshservice_apiv2.rb', line 6 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/freshservice_apiv2.rb', line 6 def username @username end |
Instance Method Details
#delete(uri) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/freshservice_apiv2.rb', line 23 def delete(uri) begin pick_header request = RestClient::Resource.new(baseurl+uri) response = request.delete(@header) return response.code,JSON.parse(response),response rescue RestClient::Exception => e return e.response.code, JSON.parse(e.response.body) end end |
#get(uri) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/freshservice_apiv2.rb', line 12 def get(uri) begin pick_header request = RestClient::Resource.new(baseurl+uri) response = request.get(@header) return response.code,JSON.parse(response),response rescue RestClient::Exception => e return e.response.code, JSON.parse(e.response.body) end end |
#post(uri, data) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/freshservice_apiv2.rb', line 45 def post(uri,data) begin pick_header request = RestClient::Resource.new(baseurl+uri) response = request.post(data,@header) return response.code,JSON.parse(response),response rescue RestClient::Exception => e return e.response.code, JSON.parse(e.response.body) end end |
#update(uri, data) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/freshservice_apiv2.rb', line 34 def update(uri,data) begin pick_header request = RestClient::Resource.new(baseurl+uri) response = request.put(data,@header) return response.code,JSON.parse(response),response rescue RestClient::Exception => e return e.response.code, JSON.parse(e.response.body) end end |