Sha256: 1bb40c33a54b7ce09494a978ed6d4bc62e8cc71230fb4bd508ab471c8ca03a12
Contents?: true
Size: 630 Bytes
Versions: 1
Compression:
Stored size: 630 Bytes
Contents
require "faraday" require "json" module Sharedcount class API attr_accessor :connection, :endpoint, :apikey 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 def fetch(url) response = self.connection.get "/?apikey=#{self.apikey}&url=#{url}" return Sharedcount::Data.new(response.body) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sharedcount-0.0.2 | lib/sharedcount/api.rb |