Class: SocketLabs::InjectionApi::SocketLabsClient

Inherits:
Object
  • Object
show all
Includes:
Core, Message
Defined in:
lib/socketlabs/injectionapi/socketlabsclient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_id, api_key, proxy = {}) ⇒ SocketLabsClient

Returns a new instance of SocketLabsClient.



21
22
23
24
25
26
27
28
29
30
# File 'lib/socketlabs/injectionapi/socketlabsclient.rb', line 21

def initialize (
    server_id,
    api_key,
    proxy= {}
)
  @server_id = server_id
  @api_key = api_key
  @proxy = proxy
  @endpoint = "https://inject.socketlabs.com/api/v1/email"
end

Instance Attribute Details

#request_jsonObject (readonly)

Returns the value of attribute request_json.



18
19
20
# File 'lib/socketlabs/injectionapi/socketlabsclient.rb', line 18

def request_json
  @request_json
end

#response_jsonObject (readonly)

Returns the value of attribute response_json.



19
20
21
# File 'lib/socketlabs/injectionapi/socketlabsclient.rb', line 19

def response_json
  @response_json
end

Instance Method Details

#send(message) ⇒ SendResponse

Sends a Message message and returns the response from the Injection API.

Parameters:

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/socketlabs/injectionapi/socketlabsclient.rb', line 35

def send(message)

  response = SendResponse.new

  if message.instance_of? BasicMessage
    response = send_basic_message(message)
  end

  if message.instance_of? BulkMessage
    response = send_bulk_message(message)
  end

  response

end

#to_sObject



51
52
53
# File 'lib/socketlabs/injectionapi/socketlabsclient.rb', line 51

def to_s
  "#{@endpoint}::#{@server_id}:#{@api_key}"
end