Class: KickboxApi
- Inherits:
-
Object
- Object
- KickboxApi
- Defined in:
- lib/kickbox_api.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ KickboxApi
constructor
A new instance of KickboxApi.
- #verify(email) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ KickboxApi
Returns a new instance of KickboxApi.
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/kickbox_api.rb', line 2 def initialize opts = {} @token = opts[:token] @end_point = opts[:end_point] @url = opts[:url] raise ArgumentError if @token.nil? || @end_point.nil? || @url.nil? @conn = Faraday.new(@url) do |faraday| faraday.adapter Faraday.default_adapter end end |
Instance Method Details
#verify(email) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kickbox_api.rb', line 14 def verify email begin response = @conn.get do |req| req.url "#{@end_point}?email=#{email}&apikey=#{@token}" req..timeout = 2 req..open_timeout = 2 end if response.status == 200 JSON.parse(response.body) if response.body.is_a? String end rescue {'success' => 'false'} end end |