Class: RiskalyzeAPI::Session
- Inherits:
-
Object
- Object
- RiskalyzeAPI::Session
- Defined in:
- lib/riskalyze_api/session.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #delete(resource, id) ⇒ Object
- #get(resource, id = nil) ⇒ Object
-
#initialize {|@config| ... } ⇒ Session
constructor
A new instance of Session.
- #post(resource, params) ⇒ Object
- #put(resource, id, params) ⇒ Object
Constructor Details
#initialize {|@config| ... } ⇒ Session
Returns a new instance of Session.
15 16 17 18 |
# File 'lib/riskalyze_api/session.rb', line 15 def initialize @config = RiskalyzeAPI.config yield @config if block_given? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/riskalyze_api/session.rb', line 13 def config @config end |
Instance Method Details
#delete(resource, id) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/riskalyze_api/session.rb', line 43 def delete(resource, id) handle_response HTTParty.delete( url([resource, id]), headers: headers ) end |
#get(resource, id = nil) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/riskalyze_api/session.rb', line 28 def get(resource, id = nil) handle_response HTTParty.get( url([resource, id]), headers: headers ) end |
#post(resource, params) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/riskalyze_api/session.rb', line 20 def post(resource, params) handle_response HTTParty.post( url([resource, id]), headers: headers, body: params ) end |
#put(resource, id, params) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/riskalyze_api/session.rb', line 35 def put(resource, id, params) handle_response HTTParty.put( url([resource, id]), headers: headers, body: params ) end |