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
ConferenceCallService::ConferenceCallService, IpLocationService::IpLocationService, LocalSearchService::LocalSearchService, QuotaService::QuotaService, SmsService::SmsService, SmsService::SmsValidationService, VoiceCallService::VoiceCallService
Instance Method Summary collapse
-
#initialize(username, password, environment = ServiceEnvironment.SANDBOX) ⇒ AuthenticatedService
constructor
- Constructor ===Parameters
username
- Username, such as [email protected]
password
-
Password.
- Username, such as [email protected]
- Constructor ===Parameters
-
#invoke_authenticated(action, &block) ⇒ Object
Invokes the given action and also adds the security token to the SOAP header.
Methods inherited from BasicService
#on_create_document, #on_response_document
Constructor Details
#initialize(username, password, environment = ServiceEnvironment.SANDBOX) ⇒ AuthenticatedService
11 12 13 14 15 |
# File 'lib/authenticated_service.rb', line 11 def initialize(username, password, environment = ServiceEnvironment.SANDBOX) 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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/authenticated_service.rb', line 19 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 |