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.
220 221 222 223 224 225 226 227 |
# File 'lib/jasper-client/jasper_client.rb', line 220 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.
237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/jasper-client/jasper_client.rb', line 237 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.
216 217 218 |
# File 'lib/jasper-client/jasper_client.rb', line 216 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
216 217 218 |
# File 'lib/jasper-client/jasper_client.rb', line 216 def username @username end |
#wsdl_url ⇒ Object (readonly)
Returns the value of attribute wsdl_url.
216 217 218 |
# File 'lib/jasper-client/jasper_client.rb', line 216 def wsdl_url @wsdl_url end |
Instance Method Details
#supported_request?(name) ⇒ Boolean
return true if name indicates a supported request.
230 231 232 |
# File 'lib/jasper-client/jasper_client.rb', line 230 def supported_request?(name) [:get, :list, :run_report].include? name.to_sym end |