Sha256: 6af0efc16611055a1f55208921533c13fec36a3fa770a041821f013ffc39ce1d
Contents?: true
Size: 992 Bytes
Versions: 1
Compression:
Stored size: 992 Bytes
Contents
require 'httparty' # This module analize and extract score from social analizer http://kred.com module Skore class Kred # Include httparty module from http querys include HTTParty base_uri 'http://api.kred.com/kredscore' default_timeout 1 attr_accessor :data # Initialize and load data from kred api def initialize(app_id, app_key) raise ArgumentError, 'app_id is required' if app_id == nil || app_id.empty? raise ArgumentError, 'api_key is required' if app_key == nil || app_key.empty? @app_id = app_id @app_key = app_key end # Get score from Kred api def score(social_network, username) begin @data = self.class.get("?term=#{username}&source=#{social_network}&app_id=#{@app_id}&app_key=#{@app_key}", verify: false) result = @data ? JSON.parse(@data.body) : nil result['data'][0]['influence'] if result && result['data'] rescue Timeout::Error nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
skore-1.0.0 | lib/skore/kred.rb |