email-verification 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/email/verification/verifier.rb +32 -4
- data/lib/email/verification/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18dda62401ba79203197424d11fa97dd2b5559f4c7baf87d2f4f6bbf18dbe286
|
4
|
+
data.tar.gz: 72f9c42ae43a9ea1d719cdd6d5cb5abb809a06443c6844f35e1dc0ba1ba6c9c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5472ad7c1a514da199a89dc951d51d94d05388abc68353c857995ab77752110f62bcecb0761c01251933b721b0c27e2f26eb8a5b992cf3cf8ea47273d88234d
|
7
|
+
data.tar.gz: d638119dbaf5a774510277bec50f76185a5a61552926136e025fbb1b16a818177486654700d7c5a846d68307f4f43c59a3f69469bab5d667a14a7a7fc68e9895
|
@@ -15,10 +15,11 @@ module Email
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def retrieve_verification_code(email:, password:, mailboxes: %w(Inbox), settings: {})
|
19
|
-
|
18
|
+
def retrieve_verification_code(email:, password:, mailboxes: %w(Inbox), settings: {}, wait: 3, retries: 3)
|
19
|
+
result = nil
|
20
|
+
service = determine_email_service(email)
|
20
21
|
|
21
|
-
verifier
|
22
|
+
verifier = case service
|
22
23
|
when :gmail
|
23
24
|
::Email::Verification::Gmail.new
|
24
25
|
when :hotmail
|
@@ -27,7 +28,30 @@ module Email
|
|
27
28
|
nil
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
+
if verifier
|
32
|
+
if settings_provided?(settings) && !wait.nil? && !retries.nil?
|
33
|
+
result = retrieve_with_retries(email: email, password: password, mailboxes: mailboxes, settings: settings, wait: wait, retries: retries)
|
34
|
+
else
|
35
|
+
result = verifier.retrieve_verification_code(email: email, password: password, mailboxes: mailboxes, settings: settings)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
return result
|
40
|
+
end
|
41
|
+
|
42
|
+
def retrieve_with_retries(email:, password:, mailboxes: %w(Inbox), settings: {}, wait: 3, retries: 3)
|
43
|
+
result = nil
|
44
|
+
|
45
|
+
begin
|
46
|
+
result = verifier.retrieve_verification_code(email: email, password: password, mailboxes: mailboxes, settings: settings)
|
47
|
+
|
48
|
+
if result.to_s.empty?
|
49
|
+
sleep wait if wait
|
50
|
+
retries -= 1
|
51
|
+
end
|
52
|
+
end while result.to_s.empty? && retries > 0
|
53
|
+
|
54
|
+
return result
|
31
55
|
end
|
32
56
|
|
33
57
|
def determine_email_service(email_address)
|
@@ -45,6 +69,10 @@ module Email
|
|
45
69
|
return detected_service
|
46
70
|
end
|
47
71
|
|
72
|
+
def settings_provided?(settings = {})
|
73
|
+
settings && !settings.empty?
|
74
|
+
end
|
75
|
+
|
48
76
|
end
|
49
77
|
end
|
50
78
|
end
|