Class: JasperClient::RepositoryService
- Inherits:
-
Savon::Client
- Object
- Savon::Client
- JasperClient::RepositoryService
- Defined in:
- lib/jasper-client/jasper_client.rb
Overview
A crack at a Jasper Server client for the repository service.
This client sits on top of several common Ruby APIs including the Savon SOAP API, XmlBuilder, and nokogiri.
Defined Under Namespace
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#wsdl_url ⇒ Object
readonly
Returns the value of attribute wsdl_url.
Instance Method Summary collapse
-
#initialize(wsdl_url, username, password) ⇒ RepositoryService
constructor
Initialize the JapserClient with a URL (points to the repository service), a username, and a password.
-
#method_missing(name, *params, &block) ⇒ Object
Essentially a proxy to method_missing for Savon.
-
#supported_request?(name) ⇒ Boolean
return true if name indicates a supported request.
Constructor Details
#initialize(wsdl_url, username, password) ⇒ RepositoryService
Initialize the JapserClient with a URL (points to the repository service), a username, and a password.
236 237 238 239 240 241 242 243 |
# File 'lib/jasper-client/jasper_client.rb', line 236 def initialize(wsdl_url, username, password) @wsdl_url = wsdl_url.to_s @username = username.to_s @password = password.to_s super @wsdl_url request.basic_auth @username, @password end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *params, &block) ⇒ Object
Essentially a proxy to method_missing for Savon. If the method call is to a known request type, build XML with a request object and then execute the Savon request.
253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/jasper-client/jasper_client.rb', line 253 def method_missing(name, *params, &block) if supported_request?(name) req = Request.new(name) request_xml = req.build(&block) savon_response = super(name) { |soap| soap.body = request_xml.to_s } response_class = Response.const_get "%sResponse" % [ name.to_s.humpify.to_sym ] response_class.new savon_response else super(name, params) end end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
232 233 234 |
# File 'lib/jasper-client/jasper_client.rb', line 232 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
232 233 234 |
# File 'lib/jasper-client/jasper_client.rb', line 232 def username @username end |
#wsdl_url ⇒ Object (readonly)
Returns the value of attribute wsdl_url.
232 233 234 |
# File 'lib/jasper-client/jasper_client.rb', line 232 def wsdl_url @wsdl_url end |
Instance Method Details
#supported_request?(name) ⇒ Boolean
return true if name indicates a supported request.
246 247 248 |
# File 'lib/jasper-client/jasper_client.rb', line 246 def supported_request?(name) [:get, :list, :run_report].include? name.to_sym end |