Class: EmailVerify

Inherits:
Object
  • Object
show all
Defined in:
lib/mslm/email_verify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ EmailVerify

Initializes an EmailVerify object with an API key.



9
10
11
# File 'lib/mslm/email_verify.rb', line 9

def initialize(api_key)
    @lib = Lib.new(api_key)
end

Instance Attribute Details

#libObject (readonly)

Class for performing email verification using an API.



6
7
8
# File 'lib/mslm/email_verify.rb', line 6

def lib
  @lib
end

Instance Method Details

#set_api_key(api_key) ⇒ Object

Sets the API key for authentication.



24
25
26
# File 'lib/mslm/email_verify.rb', line 24

def set_api_key(api_key)
    @lib.set_api_key(api_key)
end

#set_http_client(http_client) ⇒ Object

Sets the HTTP client to be used for making requests.



14
15
16
# File 'lib/mslm/email_verify.rb', line 14

def set_http_client(http_client)
    @lib.set_http_client(http_client)
end

#set_user_agent(user_agent) ⇒ Object

Sets the user agent to be used in HTTP requests.



19
20
21
# File 'lib/mslm/email_verify.rb', line 19

def set_user_agent(user_agent)
    @lib.set_user_agent(user_agent)
end

#single_verify(email, opts = nil) ⇒ Object

Performs a single email verification with optional request options.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/mslm/email_verify.rb', line 29

def single_verify(email, opts = nil)
    opt = ReqOpts::Builder.new
                        .with_api_key(@lib.api_key)
                        .with_base_url(@lib.base_url)
                        .with_http_client(@lib.http)
                        .with_user_agent(@lib.user_agent)
                        .build

    opt = opts if opts
    query_params = { 'email' => email }
    target_url = @lib.prepare_url('/api/sv/v1', query_params, opt)

    resp = @lib.req_and_resp(target_url, opt)
    resp
end