Class: AuthenticatedService
- Inherits:
-
BasicService
- Object
- Handsoap::Service
- BasicService
- AuthenticatedService
- Defined in:
- lib/authenticated_service.rb
Overview
Base service for all services demanding a security token.
Direct Known Subclasses
QuotaService::QuotaService, SmsService::SmsService, VoiceCallService::VoiceCallService
Instance Method Summary collapse
-
#initialize(username, password) ⇒ AuthenticatedService
constructor
A new instance of AuthenticatedService.
-
#invoke_authenticated(action, &block) ⇒ Object
Invokes the given action and also adds the security token to the SOAP header.
Constructor Details
#initialize(username, password) ⇒ AuthenticatedService
Returns a new instance of AuthenticatedService.
7 8 9 10 11 |
# File 'lib/authenticated_service.rb', line 7 def initialize(username, password) super(username, password) @token_service = TokenService::TokenService.new(@username, @password) end |
Instance Method Details
#invoke_authenticated(action, &block) ⇒ Object
Invokes the given action and also adds the security token to the SOAP header. Using this method authentication is totally hidden from the rest of the application.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/authenticated_service.rb', line 15 def invoke_authenticated(action, &block) security_token = @token_service.get_security_token response = invoke(action) do || doc = .document # Build the login header build_service_header(doc, security_token) yield(, doc) end return response end |