Module: Windoo::Connection::Actions
- Included in:
- Windoo::Connection
- Defined in:
- lib/windoo/connection/actions.rb
Overview
This module defines methods used for interacting with the TitleEditor API. This includes sending HTTP requests and handling responses
Class Method Summary collapse
Instance Method Summary collapse
-
#delete(rsrc) ⇒ Object
Delete a resource from the API.
-
#get(rsrc) ⇒ Object
The parsed JSON from the result of the request.
-
#post(rsrc, content) ⇒ Object
Create a new API resource via POST.
-
#put(rsrc, content) ⇒ Object
Update an existing API resource via PUT.
Class Method Details
.included(includer) ⇒ Object
18 19 20 |
# File 'lib/windoo/connection/actions.rb', line 18 def self.included(includer) Windoo.verbose_include(includer, self) end |
Instance Method Details
#delete(rsrc) ⇒ Object
Delete a resource from the API
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/windoo/connection/actions.rb', line 80 def delete(rsrc) validate_connected # send the data resp = cnx.delete(rsrc) @last_http_response = resp return resp.body if resp.success? handle_http_error resp end |
#get(rsrc) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/windoo/connection/actions.rb', line 26 def get(rsrc) validate_connected resp = cnx.get(rsrc) @last_http_response = resp return resp.body if resp.success? handle_http_error resp end |
#post(rsrc, content) ⇒ Object
Create a new API resource via POST
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/windoo/connection/actions.rb', line 44 def post(rsrc, content) validate_connected # send the data resp = cnx.post(rsrc) { |req| req.body = content } @last_http_response = resp return resp.body if resp.success? handle_http_error resp end |
#put(rsrc, content) ⇒ Object
Update an existing API resource via PUT
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/windoo/connection/actions.rb', line 63 def put(rsrc, content) validate_connected # send the data resp = cnx.put(rsrc) { |req| req.body = content } @last_http_response = resp return resp.body if resp.success? handle_http_error resp end |