Class: Skore::Kred
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(app_id, app_key) ⇒ Kred
constructor
Initialize and load data from kred api.
-
#score(social_network, username) ⇒ Object
Get score from Kred api.
Constructor Details
#initialize(app_id, app_key) ⇒ Kred
Initialize and load data from kred api
16 17 18 19 20 21 |
# File 'lib/skore/kred.rb', line 16 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 |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
13 14 15 |
# File 'lib/skore/kred.rb', line 13 def data @data end |
Instance Method Details
#score(social_network, username) ⇒ Object
Get score from Kred api
24 25 26 27 28 29 30 31 32 |
# File 'lib/skore/kred.rb', line 24 def score(, username) begin @data = self.class.get("?term=#{username}&source=#{}&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 |