dopaminekit 3.0.0 → 4.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/dopaminekit/version.rb +1 -1
- data/lib/dopaminekit.rb +27 -106
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c67187a375cee2ad629ac3bbf07fd48c1b90fda4
|
4
|
+
data.tar.gz: ced8baa4c7d0d9b38bf9e311271162d3c63ccd9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a134792e784a80b0ac2e51e396009ab9732fb24e6592ad87489233afd796c45730588a7171c3b6734b51e3d0b345bc85200a5b74b29689e41329b9e4b10fd1f
|
7
|
+
data.tar.gz: 1c5b898e836bb1e0e3c72397a5b4417966898efdc0a67c4d43b46a5b05a0aa121ecd79bbf9924e565480fa031948524cd9603c303dbabb68f51c148e89de3074
|
data/README.md
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
# What is DopamineKit?
|
2
|
-
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/dopaminekit)
|
4
|
+
|
5
|
+
[](mailto:team@usedopamine.com)
|
6
|
+
|
7
|
+
|
8
|
+
Boost retention and user engagement in your Ruby app.
|
3
9
|
|
4
10
|
DopamineKit provides wrappers for accessing the DopamineAPI and expressive UI reinforcements for your app.
|
5
11
|
|
6
|
-
Get your free API key at [http://dashboard.usedopamine.com/](http://dashboard.usedopamine.com/)
|
12
|
+
Get your free API key at [http://dashboard.usedopamine.com/](http://dashboard.usedopamine.com/).
|
7
13
|
|
8
|
-
Learn more at [http://usedopamine.com](http://usedopamine.com)
|
14
|
+
Learn more at [http://usedopamine.com](http://usedopamine.com).
|
9
15
|
|
10
16
|
## Installation
|
11
17
|
|
data/lib/dopaminekit/version.rb
CHANGED
data/lib/dopaminekit.rb
CHANGED
@@ -49,111 +49,18 @@ class DopamineKit
|
|
49
49
|
# +metaData+:: Hash=nil - A hash containing extra data about the user or environment to generate better results.
|
50
50
|
#
|
51
51
|
# Return:
|
52
|
-
# +response+::
|
52
|
+
# +response+:: String - a JSON string containing the key 'status', and if 'status' != 200 also another key 'errors'
|
53
53
|
#
|
54
|
-
def track(
|
55
|
-
|
56
|
-
puts "[DopamineKit] - Invalid actionID for tracking call:#{actionID}"
|
57
|
-
return
|
58
|
-
end
|
59
|
-
if !identity.is_a? String
|
60
|
-
puts "[DopamineKit] - Invalid identity for tracking call:#{identity}"
|
61
|
-
return
|
62
|
-
end
|
63
|
-
|
64
|
-
postData = getBasePostData()
|
65
|
-
postData[:actionID] = actionID
|
66
|
-
postData[:primaryIdentity] = identity
|
67
|
-
if(metaData != nil and metaData.is_a? Hash)
|
68
|
-
postData[:metaData] = metaData.merge(@persistentMetaData){|key, meta, persistentmeta| meta}
|
69
|
-
else
|
70
|
-
postData[:metaData] = @persistentMetaData
|
71
|
-
end
|
72
|
-
|
73
|
-
response = JSON.parse( send(:tracking, postData) )
|
74
|
-
# Not necessary, but useful for customized logging
|
75
|
-
return response
|
54
|
+
def track(identity, payload)
|
55
|
+
return send(:track, identity, payload)
|
76
56
|
end
|
77
57
|
|
78
|
-
|
79
|
-
|
80
|
-
#
|
81
|
-
# Params:
|
82
|
-
# +actionID+:: String - A descriptive name for action that the user has performed
|
83
|
-
# +identity+:: String - A string used to identify a particular user, such as an email or username or UUID.
|
84
|
-
# +metaData+:: Hash=nil - A hash containing extra data about the user or environment to generate better results.
|
85
|
-
#
|
86
|
-
# Return:
|
87
|
-
# +response+:: String - the reinforcement decision, picked from a set declared on the Dopamine Developer Dashboard
|
88
|
-
#
|
89
|
-
def reinforce(actionID, identity, metaData=nil)
|
90
|
-
if !actionID.is_a? String
|
91
|
-
puts "[DopamineKit] - Invalid actionID for reinforcement call:#{actionID}"
|
92
|
-
return
|
93
|
-
end
|
94
|
-
if !identity.is_a? String
|
95
|
-
puts "[DopamineKit] - Invalid identity for reinforcement call:#{identity}"
|
96
|
-
return
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
postData = getBasePostData()
|
101
|
-
postData[:actionID] = actionID
|
102
|
-
postData[:primaryIdentity] = identity
|
103
|
-
if(metaData != nil and metaData.is_a? Hash)
|
104
|
-
postData[:metaData] = metaData.merge(@persistentMetaData){|key, meta, persistentmeta| meta}
|
105
|
-
else
|
106
|
-
postData[:metaData] = @persistentMetaData
|
107
|
-
end
|
108
|
-
|
109
|
-
response = JSON.parse( send(:reinforcement, postData) )
|
110
|
-
|
111
|
-
if response["status"] == 200
|
112
|
-
return response["reinforcementDecision"]
|
113
|
-
else
|
114
|
-
return response
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
##
|
120
|
-
# .
|
121
|
-
# Use setPersistentMetaData() to replace the entire persistentMetaData hashtable,
|
122
|
-
# and use clearPersistentMetaData() to clear it.
|
123
|
-
#
|
124
|
-
# Params:
|
125
|
-
# +key+:: String - A descriptive name for the metaData
|
126
|
-
# +value+:: var - A JSON compliant variable
|
127
|
-
#
|
128
|
-
def addPersistentMetaData(key, value)
|
129
|
-
@persistentMetaData[key.to_sym] = value
|
130
|
-
end
|
131
|
-
|
132
|
-
##
|
133
|
-
# Replace all contents within the persistentMetaData hash,
|
134
|
-
# and replace them with the hash passed in
|
135
|
-
#
|
136
|
-
# Params:
|
137
|
-
# +hash+:: Hash - A hash of JSON compliant key-value pairs
|
138
|
-
#
|
139
|
-
def setPersistentMetaData(hash)
|
140
|
-
if hash.is_a? Hash
|
141
|
-
@persistentMetaData = hash.clone
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
##
|
146
|
-
# Clear all entries in the persistentMetaData hash.
|
147
|
-
#
|
148
|
-
def clearPersistentMetaData()
|
149
|
-
@persistentMetaData.clear
|
58
|
+
def report(identity, payload)
|
59
|
+
return send(:report, identity, payload)
|
150
60
|
end
|
151
61
|
|
152
|
-
|
153
|
-
|
154
|
-
#
|
155
|
-
def getPersistentMetaData()
|
156
|
-
return @persistentMetaData.clone
|
62
|
+
def refresh(identity, payload)
|
63
|
+
return send(:refresh, identity, payload)
|
157
64
|
end
|
158
65
|
|
159
66
|
|
@@ -181,13 +88,27 @@ class DopamineKit
|
|
181
88
|
##
|
182
89
|
# Privately used function to send an HTTP POST
|
183
90
|
#
|
184
|
-
def send(type, data)
|
185
|
-
|
91
|
+
def send(type, identity, data)
|
92
|
+
if !data.is_a? Hash
|
93
|
+
puts "[DopamineKit] - Invalid data for api call:#{data}"
|
94
|
+
return
|
95
|
+
end
|
96
|
+
if !identity.is_a? String
|
97
|
+
puts "[DopamineKit] - Invalid identity for report call:#{identity}"
|
98
|
+
return
|
99
|
+
end
|
100
|
+
|
101
|
+
postData = getBasePostData().merge(data)
|
102
|
+
postData[:primaryIdentity] = identity
|
103
|
+
|
104
|
+
url = "https://staging-api.usedopamine.com/v4/app/"
|
186
105
|
case type
|
187
|
-
when :
|
106
|
+
when :track
|
188
107
|
url = url + "track/"
|
189
|
-
when :
|
190
|
-
url = url + "
|
108
|
+
when :report
|
109
|
+
url = url + "report/"
|
110
|
+
when :refresh
|
111
|
+
url = url + "refresh/"
|
191
112
|
else
|
192
113
|
return
|
193
114
|
end
|
@@ -200,7 +121,7 @@ class DopamineKit
|
|
200
121
|
https = Net::HTTP.new(uri.host, 443)
|
201
122
|
https.use_ssl = true
|
202
123
|
req = Net::HTTP::Post.new(uri.path, initheader={'Content-Type' => 'application/json'})
|
203
|
-
req.body =
|
124
|
+
req.body = postData.to_json
|
204
125
|
res = https.request(req)
|
205
126
|
|
206
127
|
if(@debugMode)
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dopaminekit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akash Desai
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.12'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '5.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.4.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.4.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.8.2
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.8.2
|
83
83
|
description: This gem provides a class for interacting with the DopamineAPI from ruby.
|
@@ -91,8 +91,8 @@ executables: []
|
|
91
91
|
extensions: []
|
92
92
|
extra_rdoc_files: []
|
93
93
|
files:
|
94
|
-
- .gitignore
|
95
|
-
- .travis.yml
|
94
|
+
- ".gitignore"
|
95
|
+
- ".travis.yml"
|
96
96
|
- CODE_OF_CONDUCT.md
|
97
97
|
- Gemfile
|
98
98
|
- LICENSE.txt
|
@@ -114,17 +114,17 @@ require_paths:
|
|
114
114
|
- lib
|
115
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 1.3.1
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.4.5.1
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: '"A class to use DopamineLabs machine learning API"'
|