Module: KickboxRails
- Defined in:
- lib/kickbox_rails.rb,
lib/kickbox_rails/version.rb,
lib/generators/kickbox_rails/install_generator.rb
Defined Under Namespace
Modules: Generators
Classes: Configuration
Constant Summary
collapse
- VERSION =
"1.0.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
8
9
10
|
# File 'lib/kickbox_rails.rb', line 8
def configuration
@configuration
end
|
.provider ⇒ Object
Returns the value of attribute provider.
8
9
10
|
# File 'lib/kickbox_rails.rb', line 8
def provider
@provider
end
|
Class Method Details
10
11
12
13
14
15
16
|
# File 'lib/kickbox_rails.rb', line 10
def configure
@configuration ||= Configuration.new
yield(configuration)
@provider = KickboxApi.new(url: @configuration.api_url,
end_point: @configuration.api_resource,
token: @configuration.api_key)
end
|
.invalid?(email) ⇒ Boolean
45
46
47
|
# File 'lib/kickbox_rails.rb', line 45
def invalid? email
!valid? email
end
|
.valid?(email) ⇒ Boolean
32
33
34
35
|
# File 'lib/kickbox_rails.rb', line 32
def valid? email
response = validate(email)
valid_response?(response)
end
|
.valid_response?(response) ⇒ Boolean
37
38
39
40
41
42
43
|
# File 'lib/kickbox_rails.rb', line 37
def valid_response?(response)
if @configuration.treat_unknown_as_valid
[ 'valid', 'unknown' ].include?(response['result'])
else
[ 'valid' ].include?(response['result'])
end
end
|
.validate(email) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/kickbox_rails.rb', line 18
def validate email
begin
response = @provider.verify(email||String.new)
throw Exception unless response['success'] == 'true' || response['success'] == true
response
rescue Exception => e
basic_email_validation email
end
end
|