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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfc3ab8898cecfba92dc9503f32dea94133613d831832e02cde1aceb8fe71dd7
4
- data.tar.gz: be0c28e0614b05ef73327a1c7824e71db0fffd1067f327fe4771dc47957cf58d
3
+ metadata.gz: 18dda62401ba79203197424d11fa97dd2b5559f4c7baf87d2f4f6bbf18dbe286
4
+ data.tar.gz: 72f9c42ae43a9ea1d719cdd6d5cb5abb809a06443c6844f35e1dc0ba1ba6c9c7
5
5
  SHA512:
6
- metadata.gz: dcd2558ac7c582d53915bdaa9c6ceae103316a5a0729f685b1318ebc087b27b466d9abee683a635b5d8a3d267ae8d82d408a166653112a28aa365e5291c3e798
7
- data.tar.gz: 28d869fce17dfb239a70c650f2bb9762f5445746848333009615574e182977a96dfbbc7d769475499ed824836ea7ca90097261332dee60852addc491d5f2b42f
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
- service = determine_email_service(email)
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 = case service
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
- result = verifier ? verifier.retrieve_verification_code(email: email, password: password, mailboxes: mailboxes, settings: settings) : nil
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
@@ -1,5 +1,5 @@
1
1
  module Email
2
2
  module Verification
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email-verification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Johnsson