dopamine 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/dopamine.rb +59 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd05ed7e61072f70e7bb352aa587a550cac3d98e
|
4
|
+
data.tar.gz: 7cebf6f9b53131a9a5dbf2499a21f4e4ee90a52b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ca90178f77455273ce29f40fdd65497dec2074dabff460d73388dd0b55a1fc67e732e30414705893bce6c1039bfe47383fdb3e3d14dfe59090a3bf038fa3bc45
|
7
|
+
data.tar.gz: fe86ed27c484e4248c9840bcc5db0f582114544df1387d8847006875a4cee561e5becc614a70ec7346adbb6cccb8c7e655715d1512e53c672b2ac38d2f3fc553
|
data/lib/dopamine.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
class Dopamine
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
#debug_output $stdout
|
7
|
+
|
8
|
+
# use SSL
|
9
|
+
base_uri 'http://api.usedopamine.com/v1'
|
10
|
+
|
11
|
+
format :json
|
12
|
+
|
13
|
+
HEADERS = {
|
14
|
+
'Accept' => 'application/json',
|
15
|
+
'Content-Type' => 'application/x-www-form-urlencoded'
|
16
|
+
}
|
17
|
+
|
18
|
+
def initialize(api_token, api_key, app_id, device_type=3)
|
19
|
+
@api_token = api_token
|
20
|
+
@api_key = api_key
|
21
|
+
@app_id = app_id
|
22
|
+
@device_type = device_type
|
23
|
+
HEADERS.merge!('User-Agent'=> "#{@app_id}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_user(unique_id, id_type=5)
|
27
|
+
query = config.merge(
|
28
|
+
'deviceType' => @device_type,
|
29
|
+
'IDType' => id_type,
|
30
|
+
'uniqueID' => unique_id
|
31
|
+
)
|
32
|
+
self.class.get('/user', query: query, headers: HEADERS)
|
33
|
+
end
|
34
|
+
|
35
|
+
def reinforce?(user_uri, hablet_id)
|
36
|
+
query = config.merge(
|
37
|
+
'deviceType' => @device_type,
|
38
|
+
'userURI' => user_uri,
|
39
|
+
'habletID' => hablet_id
|
40
|
+
)
|
41
|
+
self.class.get("/user/#{user_uri}/app/#{@app_id}", query: query, headers: HEADERS)
|
42
|
+
end
|
43
|
+
|
44
|
+
def redeem(user_uri, hablet_id, email)
|
45
|
+
body = config.merge(
|
46
|
+
'deviceType' => @device_type,
|
47
|
+
'userURI' => user_uri,
|
48
|
+
'habletID' => hablet_id,
|
49
|
+
'email' => email
|
50
|
+
)
|
51
|
+
self.class.post("/user/#{user_uri}/app/#{@app_id}/", body: body, headers: HEADERS)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def config
|
57
|
+
{'key' => @api_key, 'token' => @api_token, 'appID' => @app_id}
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dopamine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marko Vasiljevic
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Rest client for Dopamine API, a behavioral reward platform
|
28
|
+
email: marmarko@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/dopamine.rb
|
34
|
+
homepage: http://rubygems.org/gems/dopamine
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.0.6
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Rest client for Dopamine API
|
58
|
+
test_files: []
|