-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
32 lines (21 loc) · 826 Bytes
/
main.rb
File metadata and controls
32 lines (21 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Using Identibyte in a Ruby application
##
## This example shows how you can integrate Identibyte with a Ruby
## application by making a simple HTTP request to the /checks endpoint
## to see if an email is disposable.
require 'net/http'
require 'uri'
require 'json'
## Define the API endpoint and settings
email = "email@mailinator.com"
uri = URI.parse("https://identibyte.com/check/#{email}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
## Set a Basic Authorization header
request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth("API_TOKEN", "")
## Make the request and check if the email is disposable
response = JSON.parse(http.request(request).body)
disposable = response['email']['disposable'] == true ? 'Yes' : 'No'
# Print the result
puts "Is #{email} disposable? #{disposable}."