Class: Ixtlan::SimpleClient
- Inherits:
-
Object
- Object
- Ixtlan::SimpleClient
- Defined in:
- lib/ixtlan/simple_client.rb
Overview
restful XML client using HTTP (no HTTPS support !!)
Instance Method Summary collapse
-
#delete(path, payload = nil) ⇒ Object
restful delete for the given path (like ‘/users/1.xml’).
-
#get(path, payload = nil) ⇒ Object
restful get for the given path (like ‘/users.xml’ or ‘/users/1.xml’).
-
#initialize(options) ⇒ SimpleClient
constructor
A new instance of SimpleClient.
-
#post(path, payload) ⇒ Object
restful post for the given path (like ‘/users.xml’).
-
#put(path, payload) ⇒ Object
restful put for the given path (like ‘/users/1.xml’).
Constructor Details
#initialize(options) ⇒ SimpleClient
Returns a new instance of SimpleClient.
8 9 10 11 12 13 |
# File 'lib/ixtlan/simple_client.rb', line 8 def initialize() @host = [:host] @port = ([:port] || 80).to_i # defaults to 80 @username = [:username] @password = [:password] end |
Instance Method Details
#delete(path, payload = nil) ⇒ Object
restful delete for the given path (like ‘/users/1.xml’). delete a single resource (with no payload) or many resources (if the underlying service provides bulk updates - path like ‘/users.xml’)
42 43 44 45 |
# File 'lib/ixtlan/simple_client.rb', line 42 def delete(path, payload = nil) req = Net::HTTP::Delete.new(path) action(req, payload) end |
#get(path, payload = nil) ⇒ Object
restful get for the given path (like ‘/users.xml’ or ‘/users/1.xml’). which retrieves the data usually there is no payload - maybe a query if the service accepts it
18 19 20 21 |
# File 'lib/ixtlan/simple_client.rb', line 18 def get(path, payload = nil) req = Net::HTTP::Get.new(path) action(req, payload) end |
#post(path, payload) ⇒ Object
restful post for the given path (like ‘/users.xml’). which creates a new resource or new resources (if the underlying service provides bulk creation)
26 27 28 29 |
# File 'lib/ixtlan/simple_client.rb', line 26 def post(path, payload) req = Net::HTTP::Post.new(path) action(req, payload) end |
#put(path, payload) ⇒ Object
restful put for the given path (like ‘/users/1.xml’). which updates a given resource or many resources (if the underlying service provides bulk updates - path like ‘/users.xml’)
34 35 36 37 |
# File 'lib/ixtlan/simple_client.rb', line 34 def put(path, payload) req = Net::HTTP::Put.new(path) action(req, payload) end |