SingleEmailVerification 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 385271c44c88aa965fe314b7736b875e1f073739205db1b5127e04a303bfe6f0
4
- data.tar.gz: 580e9a690d812921b2c885cca533338fc3050007962532d6619ee715c301ae70
3
+ metadata.gz: ba39a5ee1c1b2b428546ea535f57a63a547594177554ba92a27565fe744bb691
4
+ data.tar.gz: 7e626577b871807bfd59208622a2251835450a7797cc1b8a3f520e9572d3a64a
5
5
  SHA512:
6
- metadata.gz: e2e6d32a36755fdcabdc890a456b7ce0225deac29dcb5b87ac2d5c77add50082f0010f9090417c516d6771f37df12452cd857bf5031a4fd7647a73d6a5943434
7
- data.tar.gz: 9bb0d0aa18ede2927fa4800e272e7d8edb958792cccc341757c07a9e6e9aecf054166422bb2047b8c8e20b51ddfa52e370250490e4255e269b5a3c72fa8e3866
6
+ metadata.gz: 311914c90070ce655d5f4c8e36cdff2dba7f6c251c11fa3ff9a2540b948d009c7821f6de5b7b25957c502b082ddf21ec6575e52ebc45ab28dd1df5ed0137d223
7
+ data.tar.gz: abf373a8ec31164e5a353d9bf75d1be6281c455d8ba9ff66c6448397c3ddd7a424224df669b469ad021d40f0fcdc245a796a0896ab5138638b56a34ce7f897f2
data/README.md CHANGED
@@ -42,6 +42,44 @@ end
42
42
 
43
43
  ClientTest.new.test_single_verify
44
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
80
+
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.
82
+
45
83
  ## Contributing
46
84
 
47
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.
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EmailVerification
4
- VERSION = "0.1.1"
4
+ VERSION = "1.1.0"
5
5
  end
@@ -4,7 +4,7 @@ require 'json'
4
4
 
5
5
  module EmailVerification
6
6
 
7
- class SingleVerifyReqOpts
7
+ class SingleVerifyReqOpts
8
8
  attr_accessor :disable_url_encode
9
9
  attr_accessor :api_key
10
10
  end
@@ -14,6 +14,7 @@ module EmailVerification
14
14
  def initialize(api_key = nil)
15
15
  @api_key = api_key
16
16
  end
17
+
17
18
  def single_verify(email_addr, opts = nil)
18
19
  opt = SingleVerifyReqOpts.new
19
20
  opt = opts.last unless opts.nil? || opts.empty?
@@ -35,6 +36,42 @@ module EmailVerification
35
36
  return sv_resp
36
37
  end
37
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
+
38
75
  private
39
76
 
40
77
  def prepare_url(path, query_params, opts)
@@ -48,13 +85,27 @@ module EmailVerification
48
85
  http = Net::HTTP.new(uri.host, uri.port)
49
86
  http.use_ssl = true if uri.scheme == 'https'
50
87
 
51
- request = Net::HTTP::Get.new(uri.request_uri)
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
+
52
98
  response_data = http.request(request)
53
99
 
54
- 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
55
105
  json_response = JSON.parse(response_data.body)
56
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']]
57
107
  return response
108
+
58
109
  else
59
110
  return "HTTP #{response_data.code}: #{response_data.message}"
60
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SingleEmailVerification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sahal Abdullah
@@ -23,6 +23,7 @@ files:
23
23
  - README.md
24
24
  - Rakefile
25
25
  - SingleEmailVerification-0.1.0.gem
26
+ - SingleEmailVerification-0.1.1.gem
26
27
  - emailVerification.gemspec
27
28
  - lib/emailVerification.rb
28
29
  - lib/emailVerification/version.rb