Class: SocketLabs::InjectionApi::Core::SendValidator

Inherits:
Object
  • Object
show all
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

VERSION

Instance Method Summary collapse

Instance Method Details

#validate_credentials(server_id, api_key) ⇒ SendResponse

Validate the ServerId and Api Key pair prior before sending to the Injection API.

Parameters:

  • server_id (Integer)
  • api_key (String)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/socketlabs/injectionapi/core/send_validator.rb', line 41

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.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.

Parameters:

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/socketlabs/injectionapi/core/send_validator.rb', line 21

def validate_message(message)

  result = SendResponse.new

  if message.instance_of? BasicMessage
    result = validate_basic_message(message)
  end

  if message.instance_of? BulkMessage
    result = validate_bulk_message(message)
  end

  result

end