Class: CheckMail::Client
- Inherits:
-
Object
- Object
- CheckMail::Client
- Defined in:
- lib/checkmail/client.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(_account_sid, _auth_token) ⇒ Client
constructor
A new instance of Client.
-
#verify(_address, _timeout = 8000) ⇒ Object
process a verification.
Constructor Details
#initialize(_account_sid, _auth_token) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/checkmail/client.rb', line 10 def initialize _account_sid, _auth_token # # verify the values # if (!_account_sid =~ /^[A-Z]{2}[0-9a-f]{32}$/) raise 'invalid API acount sid provided.' end if (!_auth_token =~ /^[0-9a-f]{64}$/) raise 'invalid API access token provided.' end # # store them locally # = { :api_url => 'http://10.10.0.1/', :account_sid => _account_sid, :auth_token => _auth_token } end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/checkmail/client.rb', line 8 def end |
Instance Method Details
#verify(_address, _timeout = 8000) ⇒ Object
process a verification
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/checkmail/client.rb', line 37 def verify(_address, _timeout=8000) # # verify we have an address # if (_address.length == 0) raise 'empty email address provided.' end # # build the URL # uri = URI([:api_url] + 'verify') # # create the HTTP object # http = Net::HTTP.new(uri.host, uri.port) # # build the request object, with authentication # request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data('address' => _address, 'timeout' => _timeout) request.basic_auth([:account_sid], [:auth_token]) # # execute the request # res = http.request(request); # # return a hash # JSON.parse(res.body) end |