checkmail 1.0.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.
Files changed (3) hide show
  1. data/lib/checkmail/client.rb +75 -0
  2. data/lib/checkmail.rb +7 -0
  3. metadata +82 -0
@@ -0,0 +1,75 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module CheckMail
5
+
6
+ class Client
7
+
8
+ attr_accessor :options
9
+
10
+ def initialize _account_sid, _auth_token
11
+
12
+ #
13
+ # verify the values
14
+ #
15
+ if (!_account_sid =~ /^[A-Z]{2}[0-9a-f]{32}$/)
16
+ raise 'invalid API acount sid provided.'
17
+ end
18
+ if (!_auth_token =~ /^[0-9a-f]{64}$/)
19
+ raise 'invalid API access token provided.'
20
+ end
21
+
22
+ #
23
+ # store them locally
24
+ #
25
+ @options = {
26
+
27
+ :api_url => 'http://10.10.0.1/',
28
+ :account_sid => _account_sid,
29
+ :auth_token => _auth_token
30
+ }
31
+
32
+ end
33
+
34
+ #
35
+ # process a verification
36
+ #
37
+ def verify(_address, _timeout=8000)
38
+
39
+ #
40
+ # verify we have an address
41
+ #
42
+ if (_address.length == 0)
43
+ raise 'empty email address provided.'
44
+ end
45
+
46
+ #
47
+ # build the URL
48
+ #
49
+ uri = URI(@options[:api_url] + 'verify')
50
+
51
+ #
52
+ # create the HTTP object
53
+ #
54
+ http = Net::HTTP.new(uri.host, uri.port)
55
+
56
+ #
57
+ # build the request object, with authentication
58
+ #
59
+ request = Net::HTTP::Post.new(uri.request_uri)
60
+
61
+ request.set_form_data('address' => _address, 'timeout' => _timeout)
62
+ request.basic_auth(@options[:account_sid], @options[:auth_token])
63
+
64
+ #
65
+ # execute the request
66
+ #
67
+ res = http.request(request);
68
+
69
+ #
70
+ # return a hash
71
+ #
72
+ JSON.parse(res.body)
73
+ end
74
+ end
75
+ end
data/lib/checkmail.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "rubygems"
2
+ require "checkmail/client"
3
+
4
+ module CheckMail
5
+ end
6
+
7
+
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: checkmail
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Mike Pultz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2016-12-29 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: json
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 31
30
+ segments:
31
+ - 1
32
+ - 8
33
+ version: "1.8"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: A Ruby wrapper for the CheckMail API
37
+ email: mike@mikepultz.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - lib/checkmail.rb
46
+ - lib/checkmail/client.rb
47
+ has_rdoc: true
48
+ homepage: https://checkmail.io/
49
+ licenses:
50
+ - MIT
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.7
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: A Ruby wrapper for the CheckMail API
81
+ test_files: []
82
+