Class: DeviceCloud::Request
- Inherits:
-
Object
- Object
- DeviceCloud::Request
- Defined in:
- lib/device_cloud/request.rb
Overview
Public: Used to send Net::HTTP requests.
Examples:
get_response = DeviceCloud::Request.new("/ws/FileData").get
post_response = DeviceCloud::Request.new("/ws/sci").post(data)
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#delete ⇒ Object
Public: Send a DELETE request.
-
#get ⇒ Object
Public: Send a GET request.
-
#initialize(options = {}) ⇒ Request
constructor
Public: Create a new instance of Request.
-
#post ⇒ Object
Public: Send a POST request.
-
#put ⇒ Object
Public: Send a PUT request.
Constructor Details
#initialize(options = {}) ⇒ Request
Public: Create a new instance of Request.
path - The path String to use.
16 17 18 19 |
# File 'lib/device_cloud/request.rb', line 16 def initialize( = {}) @path = [:path] @body = [:body] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
11 12 13 |
# File 'lib/device_cloud/request.rb', line 11 def body @body end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/device_cloud/request.rb', line 11 def path @path end |
Instance Method Details
#delete ⇒ Object
Public: Send a DELETE request.
Returns a DeviceCloud::Response instance.
55 56 57 58 59 |
# File 'lib/device_cloud/request.rb', line 55 def delete make_request do Net::HTTP::Delete.new request_uri end end |
#get ⇒ Object
Public: Send a GET request.
Returns a DeviceCloud::Response instance.
24 25 26 27 28 |
# File 'lib/device_cloud/request.rb', line 24 def get make_request do Net::HTTP::Get.new request_uri end end |
#post ⇒ Object
Public: Send a POST request.
body
Returns a DeviceCloud::Response instance.
35 36 37 38 39 |
# File 'lib/device_cloud/request.rb', line 35 def post make_request do Net::HTTP::Post.new request_uri end end |
#put ⇒ Object
Public: Send a PUT request.
body
Returns a DeviceCloud::Response instance.
46 47 48 49 50 |
# File 'lib/device_cloud/request.rb', line 46 def put make_request do Net::HTTP::Put.new request_uri end end |