class Dopamine
Constants
- HEADERS
Public Class Methods
new(api_token, api_key, app_id, device_type=3)
click to toggle source
# File lib/dopamine.rb, line 18 def initialize(api_token, api_key, app_id, device_type=3) @api_token = api_token @api_key = api_key @app_id = app_id @device_type = device_type HEADERS.merge!('User-Agent'=> "#{@app_id}") end
Public Instance Methods
get_user(unique_id, id_type=5)
click to toggle source
# File lib/dopamine.rb, line 26 def get_user(unique_id, id_type=5) query = config.merge( 'deviceType' => @device_type, 'IDType' => id_type, 'uniqueID' => unique_id ) self.class.get('/user', query: query, headers: HEADERS) end
redeem(user_uri, hablet_id, email)
click to toggle source
# File lib/dopamine.rb, line 44 def redeem(user_uri, hablet_id, email) body = config.merge( 'deviceType' => @device_type, 'userURI' => user_uri, 'habletID' => hablet_id, 'email' => email ) self.class.post("/user/#{user_uri}/app/#{@app_id}/", body: body, headers: HEADERS) end
reinforce?(user_uri, hablet_id)
click to toggle source
# File lib/dopamine.rb, line 35 def reinforce?(user_uri, hablet_id) query = config.merge( 'deviceType' => @device_type, 'userURI' => user_uri, 'habletID' => hablet_id ) self.class.get("/user/#{user_uri}/app/#{@app_id}", query: query, headers: HEADERS) end
Private Instance Methods
config()
click to toggle source
# File lib/dopamine.rb, line 56 def config {'key' => @api_key, 'token' => @api_token, 'appID' => @app_id} end