SingleEmailVerification 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +66 -12
- data/SingleEmailVerification-0.1.0.gem +0 -0
- data/SingleEmailVerification-0.1.1.gem +0 -0
- data/lib/emailVerification/version.rb +1 -1
- data/lib/emailVerification.rb +66 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba39a5ee1c1b2b428546ea535f57a63a547594177554ba92a27565fe744bb691
|
4
|
+
data.tar.gz: 7e626577b871807bfd59208622a2251835450a7797cc1b8a3f520e9572d3a64a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 311914c90070ce655d5f4c8e36cdff2dba7f6c251c11fa3ff9a2540b948d009c7821f6de5b7b25957c502b082ddf21ec6575e52ebc45ab28dd1df5ed0137d223
|
7
|
+
data.tar.gz: abf373a8ec31164e5a353d9bf75d1be6281c455d8ba9ff66c6448397c3ddd7a424224df669b469ad021d40f0fcdc245a796a0896ab5138638b56a34ce7f897f2
|
data/README.md
CHANGED
@@ -1,39 +1,93 @@
|
|
1
1
|
# EmailVerification
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/emailVerification`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
The Single Email Verification Gem is a Ruby library that provides functionality to verify single email addresses. It allows you to easily integrate email verification into your Ruby applications.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
To install the gem, add the following line to your application's Gemfile:
|
8
|
+
|
9
|
+
$ gem install 'SingleEmailVerification'
|
10
10
|
|
11
11
|
Install the gem and add to the application's Gemfile by executing:
|
12
12
|
|
13
|
-
$ bundle
|
13
|
+
$ bundle nstall
|
14
14
|
|
15
15
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
16
|
|
17
|
-
$ gem install
|
17
|
+
$ gem install SingleEmailVerification
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
To use the Single Email Verification gem, require it in your Ruby code:
|
22
|
+
|
23
|
+
require 'emailVerification'
|
22
24
|
|
23
25
|
## Development
|
24
26
|
|
25
|
-
|
27
|
+
Then, create an instance of the EmailVerification::Client class and use its single_verify method to verify a single email address:
|
28
|
+
|
29
|
+
class ClientTest
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@client = EmailVerification::Client.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_single_verify
|
36
|
+
email = 'sahal.abdullah@mslm.io'
|
37
|
+
resp = @client.single_verify(email)
|
38
|
+
puts resp
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
ClientTest.new.test_single_verify
|
44
|
+
|
45
|
+
To modify your ClientTest class to allow users to add their API key from the MSL cloud, you can implement a method to set the API key and use it when initializing the EmailVerification::Client. Here's the updated code:
|
46
|
+
|
47
|
+
require 'email_verification'
|
48
|
+
|
49
|
+
class ClientTest
|
50
|
+
def initialize(api_key = nil)
|
51
|
+
@api_key = api_key
|
52
|
+
@client = EmailVerification::Client.new(api_key: @api_key)
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_api_key(api_key)
|
56
|
+
@api_key = api_key
|
57
|
+
@client = EmailVerification::Client.new(api_key: @api_key)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_single_verify
|
61
|
+
email = 'sahal.abdullah@mslm.io'
|
62
|
+
resp = @client.single_verify(email)
|
63
|
+
puts resp
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Example usage:
|
68
|
+
|
69
|
+
# Instantiate ClientTest with API key
|
70
|
+
|
71
|
+
client_test = ClientTest.new('your_api_key_here')
|
72
|
+
|
73
|
+
# Alternatively, set API key after instantiation
|
74
|
+
|
75
|
+
# client_test.set_api_key('your_api_key_here')
|
76
|
+
|
77
|
+
# Perform single email verification
|
78
|
+
|
79
|
+
client_test.test_single_verify
|
26
80
|
|
27
|
-
|
81
|
+
With this modification, users can provide their API key either during initialization or after instantiation using the set_api_key method. This gives them the flexibility to use their MSL cloud API key for unlimited hits.
|
28
82
|
|
29
83
|
## Contributing
|
30
84
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
85
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sahalAbdullah/emailVerification. Please provide detailed descriptions and steps to reproduce any bugs you encounter.
|
32
86
|
|
33
87
|
## License
|
34
88
|
|
35
|
-
The gem is available as open source under the terms of the
|
89
|
+
The Single Email Verification gem is available as open source under the terms of the MIT License. You are free to use and modify it as per your requirements.
|
36
90
|
|
37
91
|
## Code of Conduct
|
38
92
|
|
39
|
-
Everyone interacting in the EmailVerification project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
93
|
+
Everyone interacting in the EmailVerification project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sahalAbdullah/emailVerification/blob/master/CODE_OF_CONDUCT.md).
|
Binary file
|
Binary file
|
data/lib/emailVerification.rb
CHANGED
@@ -6,9 +6,15 @@ module EmailVerification
|
|
6
6
|
|
7
7
|
class SingleVerifyReqOpts
|
8
8
|
attr_accessor :disable_url_encode
|
9
|
+
attr_accessor :api_key
|
9
10
|
end
|
10
11
|
|
11
12
|
class Client
|
13
|
+
|
14
|
+
def initialize(api_key = nil)
|
15
|
+
@api_key = api_key
|
16
|
+
end
|
17
|
+
|
12
18
|
def single_verify(email_addr, opts = nil)
|
13
19
|
opt = SingleVerifyReqOpts.new
|
14
20
|
opt = opts.last unless opts.nil? || opts.empty?
|
@@ -17,12 +23,55 @@ module EmailVerification
|
|
17
23
|
email_addr = URI.encode_www_form_component(email_addr) unless opt.disable_url_encode
|
18
24
|
|
19
25
|
qp = { 'email' => email_addr }
|
26
|
+
if @api_key || opt.api_key
|
27
|
+
api_key = opt.api_key || @api_key
|
28
|
+
qp['apikey'] = api_key
|
29
|
+
end
|
30
|
+
|
31
|
+
|
20
32
|
t_url = prepare_url('https://mslm.io/api/sv/v1', qp, opt)
|
33
|
+
puts "Url #{t_url}"
|
21
34
|
|
22
35
|
sv_resp = req_and_resp('GET', t_url, nil, opt)
|
23
36
|
return sv_resp
|
24
37
|
end
|
25
38
|
|
39
|
+
def send_otp(otp_send_req, opts = nil)
|
40
|
+
|
41
|
+
opt = SingleVerifyReqOpts.new
|
42
|
+
opt = opts.last unless opts.nil? || opts.empty?
|
43
|
+
qp ={}
|
44
|
+
if @api_key || opt.api_key
|
45
|
+
api_key = opt.api_key || @api_key
|
46
|
+
qp['apikey'] = api_key
|
47
|
+
end
|
48
|
+
|
49
|
+
t_url = prepare_url('https://mslm.io/api/otp/v1/send', qp, opt)
|
50
|
+
puts "Url #{t_url}"
|
51
|
+
puts otp_send_req.to_json
|
52
|
+
|
53
|
+
otp_send_resp = req_and_resp('POST', t_url, otp_send_req, opt)
|
54
|
+
return otp_send_resp
|
55
|
+
end
|
56
|
+
|
57
|
+
def verify(otp_token_verify_req, opts = nil)
|
58
|
+
opt = SingleVerifyReqOpts.new
|
59
|
+
opt = opts.last unless opts.nil? || opts.empty?
|
60
|
+
opt.disable_url_encode = true if opt.disable_url_encode.nil?
|
61
|
+
|
62
|
+
qp = {}
|
63
|
+
if @api_key || opt.api_key
|
64
|
+
api_key = opt.api_key || @api_key
|
65
|
+
qp['apikey'] = api_key
|
66
|
+
end
|
67
|
+
|
68
|
+
t_url = prepare_url('https://mslm.io/api/otp/v1/token_verify', qp, opt)
|
69
|
+
puts "Url #{t_url}"
|
70
|
+
|
71
|
+
otp_token_verify_resp = req_and_resp('POST', t_url, otp_token_verify_req, opt)
|
72
|
+
return otp_token_verify_resp
|
73
|
+
end
|
74
|
+
|
26
75
|
private
|
27
76
|
|
28
77
|
def prepare_url(path, query_params, opts)
|
@@ -36,15 +85,29 @@ module EmailVerification
|
|
36
85
|
http = Net::HTTP.new(uri.host, uri.port)
|
37
86
|
http.use_ssl = true if uri.scheme == 'https'
|
38
87
|
|
39
|
-
|
88
|
+
if _method == 'POST'
|
89
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
90
|
+
request.body = _data.to_json
|
91
|
+
request.content_type = 'application/json'
|
92
|
+
elsif _method == 'GET'
|
93
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
94
|
+
else
|
95
|
+
return "Unsupported HTTP method: #{_method}"
|
96
|
+
end
|
97
|
+
|
40
98
|
response_data = http.request(request)
|
41
99
|
|
42
|
-
if response_data.code.to_i == 200
|
100
|
+
if _method == 'POST' and response_data.code.to_i == 200
|
101
|
+
json_response = JSON.parse(response_data.body)
|
102
|
+
return json_response
|
103
|
+
|
104
|
+
elsif response_data.code.to_i == 200
|
43
105
|
json_response = JSON.parse(response_data.body)
|
44
106
|
response = [json_response["email"],json_response["username"],json_response["domain"],json_response["malformed"],json_response["suggestion"],json_response["status"],json_response["has_mailbox"],json_response["accept_all"],json_response["disposable"],json_response["free"],json_response["role"],json_response['mx']]
|
45
107
|
return response
|
108
|
+
|
46
109
|
else
|
47
|
-
|
110
|
+
return "HTTP #{response_data.code}: #{response_data.message}"
|
48
111
|
end
|
49
112
|
end
|
50
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SingleEmailVerification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sahal Abdullah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write a longer description or delete this line.
|
14
14
|
email:
|
@@ -22,6 +22,8 @@ files:
|
|
22
22
|
- LICENSE.txt
|
23
23
|
- README.md
|
24
24
|
- Rakefile
|
25
|
+
- SingleEmailVerification-0.1.0.gem
|
26
|
+
- SingleEmailVerification-0.1.1.gem
|
25
27
|
- emailVerification.gemspec
|
26
28
|
- lib/emailVerification.rb
|
27
29
|
- lib/emailVerification/version.rb
|