14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/mailerooby/email_verifier.rb', line 14
def self.verify_email(email_address)
= {
'X-API-Key' => Mailerooby.verifying_api_key,
'Content-Type' => 'application/json'
}
body = { email_address: email_address }.to_json
response = post(base_uri, headers: , body: body)
case response.code
when 400
raise BadRequestError, "Bad request: #{response.body}"
when 401
raise UnauthorizedError, "Unauthorized: #{response.body}"
when 200
JSON.parse(response.body)
else
raise GeneralAPIError, "API Error: #{response.body}"
end
end
|