Module: Shurpa::ResourceInterface
Instance Method Summary collapse
-
#createResource(url, params = {}) ⇒ Object
Currently, the Shurpa API only supports creating and reading resources, so update and destroy are not necessary as of March 2017.
- #findResource(url, params = {}) ⇒ Object
Instance Method Details
#createResource(url, params = {}) ⇒ Object
Currently, the Shurpa API only supports creating and reading resources, so update and destroy are not necessary as of March 2017
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/shurpa/resource_interface.rb', line 12 def createResource(url, params={}) ## Configure Connection ## conn = Shurpa.get_connection api_key = Shurpa.api_key ## Perform the Request ## resp = conn.post do |req| req.url url req.headers["Authorization"] = "Bearer #{api_key}" req.headers["Content-Type"] = "application/json" req.body = params.to_json end ## Return Response Body ## JSON.parse(resp.body) end |
#findResource(url, params = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/shurpa/resource_interface.rb', line 29 def findResource(url, params={}) ## Configure Connection ## conn = Shurpa.get_connection api_key = Shurpa.api_key ## Perform the Request ## resp = conn.get do |req| req.url url req.headers["Authorization"] = "Bearer #{api_key}" req.headers["Content-Type"] = "application/json" end ## Return Response as Object ## JSON.parse(resp.body) end |