Class: SocketLabs::InjectionApi::Core::SendValidator
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::Core::SendValidator
- Includes:
- SocketLabs::InjectionApi, Message
- Defined in:
- lib/socketlabs/injectionapi/core/send_validator.rb
Overview
Used by the SocketLabsClient to conduct basic validation on the message before sending to the Injection API.
Constant Summary
Constants included from SocketLabs::InjectionApi
Instance Method Summary collapse
-
#validate_credentials(server_id, api_key) ⇒ SendResponse
Validate the ServerId and Api Key pair prior before sending to the Injection API.
-
#validate_message(message) ⇒ SendResponse
Validate a basic email message before sending to the Injection API.
Instance Method Details
#validate_credentials(server_id, api_key) ⇒ SendResponse
Validate the ServerId and Api Key pair prior before sending to the Injection API.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/socketlabs/injectionapi/core/send_validator.rb', line 42 def validate_credentials(server_id, api_key) if api_key.nil? || api_key.empty? SendResponse.new(result=SendResult.enum["AuthenticationValidationFailed"]) end if server_id.nil? || (!server_id.is_a?(Integer) && server_id.empty?) SendResponse.new(result=SendResult.enum["AuthenticationValidationFailed"]) end SendResponse.new(result=SendResult.enum["Success"]) end |
#validate_message(message) ⇒ SendResponse
Validate a basic email message before sending to the Injection API.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/socketlabs/injectionapi/core/send_validator.rb', line 22 def () result = SendResponse.new if .instance_of? BasicMessage result = () end if .instance_of? BulkMessage result = () end result end |