Class: SmsService::SmsValidationService

Inherits:
AuthenticatedService show all
Defined in:
lib/sms_service/sms_validation_service.rb

Overview

SmsValidationService allows you to use physical mobile phone numbers as the sender number of a text message.

See also:

Constant Summary collapse

@@SMS_VALIDATION_SERVICE_SCHEMA =
"http://webservice.sms.odg.tonline.de"
@@SMS_SERVICE_ENDPOINT =
{
        :uri => "https://gateway.developer.telekom.com/p3gw-mod-odg-sms-validation/services/SmsValidationUserService",
        :version => 1
}

Instance Method Summary collapse

Methods inherited from AuthenticatedService

#initialize, #invoke_authenticated

Methods inherited from BasicService

#initialize, #on_response_document

Constructor Details

This class inherits a constructor from AuthenticatedService

Instance Method Details

#get_validated_numbers(environment = ServiceEnvironment.MOCK) ⇒ Object

Retrieves a list of already validated numbers.

Parameters

environment

Note that only the MOCK and PRODUCTION environments can be used.



93
94
95
96
97
98
99
# File 'lib/sms_service/sms_validation_service.rb', line 93

def get_validated_numbers(environment = ServiceEnvironment.MOCK)
  response = invoke_authenticated('smsvs:getValidatedNumbersRequest') do |request, doc|                
    request.add('environment', environment)
  end

  return SmsGetValidatedNumbersResponse.new(response)
end

#invalidate(number, environment = ServiceEnvironment.MOCK) ⇒ Object

Invalidate the given number.

Parameters

number

Number to be invalidated

environment

Note that only the MOCK and PRODUCTION environments can be used. Numbers already validated

in the PRODUCTIOn environment can also be used for sending text messages in the SANDBOX ENVIRONMENT.
Validations with the keyword <tt>SECRET</tt> in the MOCK environment should always succeed.


81
82
83
84
85
86
87
88
# File 'lib/sms_service/sms_validation_service.rb', line 81

def invalidate(number, environment = ServiceEnvironment.MOCK)
  response = invoke_authenticated('smsvs:invalidateRequest') do |request, doc|
    request.add('number', number)              
    request.add('environment', environment)
  end

  return SmsSendValidationResponse.new(response)
end

#on_create_document(doc) ⇒ Object

Add namespaces to the handsoap XmlMason document.



29
30
31
32
# File 'lib/sms_service/sms_validation_service.rb', line 29

def on_create_document(doc)
  super(doc)
  doc.alias 'smsvs', @@SMS_VALIDATION_SERVICE_SCHEMA
end

#send_validation_keyword(message, number, originator, environment = ServiceEnvironment.MOCK, account = "") ⇒ Object

Send a validation text message.

Note this method does not support a sandbox service environment. Validated numbers can be used in both the production and sandbox environment. For more details please refer to the developergarden docs.

Parameters

message

Message which should be send along the validation key. Message needs to contain two placeholders: #key# and #validUntil#.

number

Number to be validated.

originator

Originator to be displayed in the receiver’s validation text message.

account

Optional developergarden subaccount.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sms_service/sms_validation_service.rb', line 45

def send_validation_keyword(message, number, originator, environment = ServiceEnvironment.MOCK,  = "")
  response = invoke_authenticated('smsvs:sendValidationKeywordRequest') do |request, doc|
    request.add('message', message)
    request.add('number', number)
    request.add('originator', originator)        
    request.add('account', )
    request.add('environment', environment)
  end

  return SmsSendValidationResponse.new(response)
end

#validate(keyword, number, environment = ServiceEnvironment.MOCK) ⇒ Object

Validate the requested number using the received keyword.

Parameters

keyword

Secret keyword used to finalize the ongoing validation process.

number

Number to be validated

environment

Note that only the MOCK and PRODUCTION environments can be used. Numbers already validated

in the PRODUCTIOn environment can also be used for sending text messages in the SANDBOX ENVIRONMENT.
Validations with the keyword <tt>SECRET</tt> in the MOCK environment should always succeed.


65
66
67
68
69
70
71
72
73
# File 'lib/sms_service/sms_validation_service.rb', line 65

def validate(keyword, number, environment = ServiceEnvironment.MOCK)
  response = invoke_authenticated('smsvs:validateRequest') do |request, doc|
    request.add('keyword', keyword)
    request.add('number', number)              
    request.add('environment', environment)
  end

  return SmsSendValidationResponse.new(response)
end