class Sharedcount::API
Attributes
apikey[RW]
connection[RW]
endpoint[RW]
Public Class Methods
new(endpoint = nil, apikey = nil)
click to toggle source
# File lib/sharedcount/api.rb, line 9 def initialize(endpoint = nil, apikey = nil) self.endpoint = endpoint || Sharedcount.config.endpoint self.apikey = apikey || Sharedcount.config.apikey self.connection = Faraday.new(:url => self.endpoint) do |faraday| faraday.request :url_encoded faraday.adapter Faraday.default_adapter end end
Public Instance Methods
fetch(url)
click to toggle source
# File lib/sharedcount/api.rb, line 18 def fetch(url) response = self.connection.get "/?apikey=#{self.apikey}&url=#{url}" return Sharedcount::Data.new(response.body) end