tamber 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/.travis.yml +11 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +223 -0
- data/README.rdoc +196 -0
- data/Rakefile +7 -0
- data/VERSION +1 -0
- data/lib/security/ca-bundle.crt +3893 -0
- data/lib/tamber/api_operations/create.rb +10 -0
- data/lib/tamber/api_operations/remove.rb +10 -0
- data/lib/tamber/api_operations/request.rb +21 -0
- data/lib/tamber/api_operations/retrieve.rb +10 -0
- data/lib/tamber/api_operations/update.rb +10 -0
- data/lib/tamber/api_resource.rb +21 -0
- data/lib/tamber/behavior.rb +6 -0
- data/lib/tamber/discover.rb +81 -0
- data/lib/tamber/event.rb +24 -0
- data/lib/tamber/item.rb +37 -0
- data/lib/tamber/tamber_error.rb +10 -0
- data/lib/tamber/tamber_object.rb +35 -0
- data/lib/tamber/user.rb +18 -0
- data/lib/tamber/util.rb +89 -0
- data/lib/tamber/version.rb +3 -0
- data/lib/tamber.rb +202 -0
- data/tamber.gemspec +35 -0
- data/test/discover_test.rb +56 -10
- data/test/item_test.rb +13 -2
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8fed11bb5f401f45c1c884abfaca26fb830959
|
4
|
+
data.tar.gz: e623a12f3d1b68e53c8813ab18b9007f141dd4e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 887b3119d229994872f2686c20f0622e4b683ea25d829a79d8773b24a276f043ff04031030d7a3f58637f73ff63b611c561987783fbca5d8e7f48f77c7030232
|
7
|
+
data.tar.gz: 38428805fbce8ccdde489cd7d95c80dd2145d7d8b333b3f0657598913f9b6761e76a62f710646ffe53414c43eab2ccdce42c137ab9fa39a5ba82774f72fcb138
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Tamber, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
# Tamber API Client for Ruby [![Build Status](https://travis-ci.org/tamber/tamber-ruby.svg?branch=master)](https://travis-ci.org/tamber/tamber-ruby)
|
2
|
+
|
3
|
+
Recommendation engines for developers, easy as π. Build blazing fast, head-scratchingly accurate hosted recommendation engines in minutes.
|
4
|
+
|
5
|
+
The Tamber iOS SDK makes it easy to track events (user-item interactions) and get recommendations for your users inside your iOS app.
|
6
|
+
|
7
|
+
[Get a free api key][homepage] to get started.
|
8
|
+
|
9
|
+
## Documentation
|
10
|
+
|
11
|
+
See [full API documentation][reference].
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
To use the Tamber Ruby bindings, you should run:
|
16
|
+
|
17
|
+
```
|
18
|
+
gem install tamber
|
19
|
+
```
|
20
|
+
|
21
|
+
If you want to build the gem from source:
|
22
|
+
|
23
|
+
```
|
24
|
+
gem build tamber.gemspec
|
25
|
+
```
|
26
|
+
|
27
|
+
## Compatibility
|
28
|
+
|
29
|
+
We are compatible with Ruby 1.9.3 and above.
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
If you are just getting started, check out the [Quick Start][quickstart] guide for instructions on how to get setup.
|
35
|
+
|
36
|
+
*We recommend tracking events from the client-side so that Tamber can learn from clicks/views, guest users, and contextual data. Use our [iOS][tamber-ios], [Node][tamber-node], or [javascript][tamber-js] SDKs to start tracking.*
|
37
|
+
|
38
|
+
Of course, you can also track events from your backend.
|
39
|
+
|
40
|
+
### Track Events
|
41
|
+
|
42
|
+
```rb
|
43
|
+
require 'tamber'
|
44
|
+
Tamber.project_key = 'your_project_key'
|
45
|
+
|
46
|
+
begin
|
47
|
+
Tamber::Event.track(
|
48
|
+
user: 'user_rlox8k927z7p',
|
49
|
+
behavior: 'like'
|
50
|
+
item: 'item_wmt4fn6o4zlk',
|
51
|
+
context: ["homepage", "featured_section"]
|
52
|
+
)
|
53
|
+
rescue TamberError => error
|
54
|
+
puts error.message
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
|
59
|
+
### Get Recommendations
|
60
|
+
|
61
|
+
Once you have tracked enough events and created your engine, it's time to put personalized recommendations in your app.
|
62
|
+
|
63
|
+
The primary method of discovery in Tamber is the `Discover.next` method, which returns the optimal set of items that the user should be shown next.
|
64
|
+
|
65
|
+
#### For You
|
66
|
+
|
67
|
+
To put personalized recommendations on your homepage, or in any recommended section, just call `Discover.next` with the number of recommendations you want to display (if you are calling server-side, also set the `user`).
|
68
|
+
|
69
|
+
```rb
|
70
|
+
Tamber.project_key = 'your_project_key'
|
71
|
+
|
72
|
+
begin
|
73
|
+
d = Tamber::Discover.next(
|
74
|
+
user: 'user_rlox8k927z7p',
|
75
|
+
number: 10
|
76
|
+
)
|
77
|
+
d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
78
|
+
rescue TamberError => error
|
79
|
+
puts error.message
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
##### `continuation`
|
84
|
+
|
85
|
+
`Discover.next` is optimized for the exact moment and context of the user at the time of request, so standard pagination is not possible. Instead, `Discover.next` uses automatic continuation to allow you to 'show more' or implement infinite scrolling.
|
86
|
+
|
87
|
+
When you want to add more recommendations to those currently displayed to the user, just set the `continuation` field to `true`. Tamber will automatically generate the set of items that should be appended to the current user-session's list. The `Discover.next` user-session is reset when `Discover.next` is called without `continuation`.
|
88
|
+
|
89
|
+
```rb
|
90
|
+
Tamber.project_key = 'your_project_key'
|
91
|
+
|
92
|
+
begin
|
93
|
+
d = Tamber::Discover.next(
|
94
|
+
user: 'user_rlox8k927z7p',
|
95
|
+
number: 10,
|
96
|
+
continuation: true
|
97
|
+
)
|
98
|
+
d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
99
|
+
rescue TamberError => error
|
100
|
+
puts error.message
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
#### Up Next
|
105
|
+
|
106
|
+
Keep users engaged by creating a path of discovery as they navigate from item to item. Just add the id of the item that the user is navigating to / looking at.
|
107
|
+
|
108
|
+
```rb
|
109
|
+
begin
|
110
|
+
d = Tamber::Discover.next(
|
111
|
+
user: 'user_rlox8k927z7p',
|
112
|
+
item: 'item_wmt4fn6o4zlk',
|
113
|
+
number: 14
|
114
|
+
)
|
115
|
+
d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
116
|
+
rescue TamberError => error
|
117
|
+
puts error.message
|
118
|
+
end
|
119
|
+
```
|
120
|
+
|
121
|
+
If you are tracking events in your backend and want to track `clicked` or `viewed` events when users request the next page, you can also get `next` for the user-item pair by adding the `get_recs` field to your `Event.track` call.
|
122
|
+
|
123
|
+
```rb
|
124
|
+
begin
|
125
|
+
e = Tamber::Event.track(
|
126
|
+
user: 'user_rlox8k927z7p',
|
127
|
+
behavior: 'clicked'
|
128
|
+
item: 'item_wmt4fn6o4zlk',
|
129
|
+
get_recs: {
|
130
|
+
number: 14
|
131
|
+
}
|
132
|
+
)
|
133
|
+
e.recommended.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
134
|
+
rescue TamberError => error
|
135
|
+
puts error.message
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
139
|
+
#### Trending
|
140
|
+
|
141
|
+
Help your users keep their fingers on the pulse of your platform by showing them the hottest, most popular, newest, or most up-and-coming items.
|
142
|
+
|
143
|
+
```rb
|
144
|
+
begin
|
145
|
+
d = Tamber::Discover.hot() // the hottest (trending) items
|
146
|
+
d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
147
|
+
end
|
148
|
+
|
149
|
+
begin
|
150
|
+
d = Tamber::Discover.popular() // the hottest (trending) items
|
151
|
+
end
|
152
|
+
|
153
|
+
# BETA endpoints
|
154
|
+
begin
|
155
|
+
d = Tamber::Discover.uac() // the most up-and-coming items
|
156
|
+
end
|
157
|
+
|
158
|
+
begin
|
159
|
+
d = Tamber::Discover.new() // the newest items
|
160
|
+
end
|
161
|
+
```
|
162
|
+
|
163
|
+
#### Build Your Own Features
|
164
|
+
|
165
|
+
Tamber allows you to use lower-level methods to get lists of recommended items, similar item matches, and similar items for a given user with which you can build your own discovery experiences. Importantly, these methods return raw recommendation data and are not intended to be pushed directly to users.
|
166
|
+
|
167
|
+
```rb
|
168
|
+
begin
|
169
|
+
Tamber::Discover.recommended(user: 'user_rlox8k927z7p').each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
170
|
+
rescue TamberError => error
|
171
|
+
puts error.message
|
172
|
+
end
|
173
|
+
|
174
|
+
begin
|
175
|
+
Tamber::Discover.similar(item: 'item_wmt4fn6o4zlk').each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
176
|
+
rescue TamberError => error
|
177
|
+
puts error.message
|
178
|
+
end
|
179
|
+
|
180
|
+
begin
|
181
|
+
Tamber::Discover.recommendedSimilar(
|
182
|
+
user: 'user_rlox8k927z7p',
|
183
|
+
item: 'item_wmt4fn6o4zlk'
|
184
|
+
).each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
185
|
+
rescue TamberError => error
|
186
|
+
puts error.message
|
187
|
+
end
|
188
|
+
```
|
189
|
+
|
190
|
+
### Sync Items (optional)
|
191
|
+
|
192
|
+
Keep Tamber in sync with your item data in order to use recommendation filtering. Just call `Item.update` wherever you create and update items in your backend. If you have a Database module, we recommend adding this method there.
|
193
|
+
|
194
|
+
```rb
|
195
|
+
require 'tamber'
|
196
|
+
Tamber.project_key = 'your_project_key'
|
197
|
+
|
198
|
+
begin
|
199
|
+
Tamber::Item.update(
|
200
|
+
id: 'item_wmt4fn6o4zlk',
|
201
|
+
updates: {
|
202
|
+
add: {
|
203
|
+
properties: {
|
204
|
+
'available_large': false,
|
205
|
+
'stock': 89
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
)
|
210
|
+
rescue TamberError => error
|
211
|
+
puts error.message
|
212
|
+
end
|
213
|
+
```
|
214
|
+
|
215
|
+
See [Tests](https://github.com/tamber/tamber-ruby/tree/master/test) for more examples.
|
216
|
+
|
217
|
+
[homepage]: https://tamber.com
|
218
|
+
[quickstart]: https://tamber.com/docs/start/
|
219
|
+
[reference]: https://tamber.com/docs/api
|
220
|
+
[dashboard]: https://dashboard.tamber.com/
|
221
|
+
[tamber-ios]: https://github.com/tamber/tamber-ios
|
222
|
+
[tamber-node]: https://github.com/tamber/tamber-node
|
223
|
+
[tamber-js]: https://github.com/tamber/tamber.js
|
data/README.rdoc
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
= Tamber API Client for Ruby {<img src="https://travis-ci.org/tamber/tamber-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/tamber/tamber-ruby]
|
2
|
+
|
3
|
+
Recommendation engines for developers, easy as π. Build blazing fast, head-scratchingly accurate hosted recommendation engines in minutes.
|
4
|
+
|
5
|
+
The Tamber iOS SDK makes it easy to track events (user-item interactions) and get recommendations for your users inside your iOS app.
|
6
|
+
|
7
|
+
{Get a free api key}[https://tamber.com] to get started.
|
8
|
+
|
9
|
+
== Documentation
|
10
|
+
|
11
|
+
See {full API documentation}[https://tamber.com/docs/api].
|
12
|
+
|
13
|
+
== Installation
|
14
|
+
|
15
|
+
To use the Tamber Ruby bindings, you should run:
|
16
|
+
|
17
|
+
gem install tamber
|
18
|
+
|
19
|
+
If you want to build the gem from source:
|
20
|
+
|
21
|
+
gem build tamber.gemspec
|
22
|
+
|
23
|
+
|
24
|
+
== Compatibility
|
25
|
+
|
26
|
+
We are compatible with Ruby 1.9.3 and above.
|
27
|
+
|
28
|
+
|
29
|
+
== Usage
|
30
|
+
|
31
|
+
If you are just getting started, check out the {Quick Start}[https://tamber.com/docs/start/] guide for instructions on how to get setup.
|
32
|
+
|
33
|
+
*We recommend tracking events from the client-side so that Tamber can learn from clicks/views, guest users, and contextual data. Use our {iOS}[https://github.com/tamber/tamber-ios], {Node}[https://github.com/tamber/tamber-node], or {javascript}[https://github.com/tamber/tamber.js] SDKs to start tracking.*
|
34
|
+
|
35
|
+
Of course, you can also track events from your backend.
|
36
|
+
|
37
|
+
=== Track Events
|
38
|
+
|
39
|
+
require 'tamber'
|
40
|
+
Tamber.project_key = 'your_project_key'
|
41
|
+
|
42
|
+
begin
|
43
|
+
Tamber::Event.track(
|
44
|
+
user: 'user_rlox8k927z7p',
|
45
|
+
behavior: 'like'
|
46
|
+
item: 'item_wmt4fn6o4zlk',
|
47
|
+
context: ["homepage", "featured_section"]
|
48
|
+
)
|
49
|
+
rescue TamberError => error
|
50
|
+
puts error.message
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
=== Get Recommendations
|
55
|
+
|
56
|
+
Once you have tracked enough events and created your engine, it's time to put personalized recommendations in your app.
|
57
|
+
|
58
|
+
The primary method of discovery in Tamber is the `Discover.next` method, which returns the optimal set of items that the user should be shown next.
|
59
|
+
|
60
|
+
==== For You
|
61
|
+
|
62
|
+
To put personalized recommendations on your homepage, or in any recommended section, just call `Discover.next` with the number of recommendations you want to display (if you are calling server-side, also set the `user`).
|
63
|
+
|
64
|
+
Tamber.project_key = 'your_project_key'
|
65
|
+
|
66
|
+
begin
|
67
|
+
d = Tamber::Discover.next(
|
68
|
+
user: 'user_rlox8k927z7p',
|
69
|
+
number: 10
|
70
|
+
)
|
71
|
+
d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
72
|
+
rescue TamberError => error
|
73
|
+
puts error.message
|
74
|
+
end
|
75
|
+
|
76
|
+
===== `continuation`
|
77
|
+
|
78
|
+
`Discover.next` is optimized for the exact moment and context of the user at the time of request, so standard pagination is not possible. Instead, `Discover.next` uses automatic continuation to allow you to 'show more' or implement infinite scrolling.
|
79
|
+
|
80
|
+
When you want to add more recommendations to those currently displayed to the user, just set the `continuation` field to `true`. Tamber will automatically generate the set of items that should be appended to the current user-session's list. The `Discover.next` user-session is reset when `Discover.next` is called without `continuation`.
|
81
|
+
|
82
|
+
Tamber.project_key = 'your_project_key'
|
83
|
+
|
84
|
+
begin
|
85
|
+
d = Tamber::Discover.next(
|
86
|
+
user: 'user_rlox8k927z7p',
|
87
|
+
number: 10,
|
88
|
+
continuation: true
|
89
|
+
)
|
90
|
+
d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
91
|
+
rescue TamberError => error
|
92
|
+
puts error.message
|
93
|
+
end
|
94
|
+
|
95
|
+
==== Up Next
|
96
|
+
|
97
|
+
Keep users engaged by creating a path of discovery as they navigate from item to item. Just add the id of the item that the user is navigating to / looking at.
|
98
|
+
|
99
|
+
begin
|
100
|
+
d = Tamber::Discover.next(
|
101
|
+
user: 'user_rlox8k927z7p',
|
102
|
+
item: 'item_wmt4fn6o4zlk',
|
103
|
+
number: 14
|
104
|
+
)
|
105
|
+
d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
106
|
+
rescue TamberError => error
|
107
|
+
puts error.message
|
108
|
+
end
|
109
|
+
|
110
|
+
If you are tracking events in your backend and want to track `clicked` or `viewed` events when users request the next page, you can also get `next` for the user-item pair by adding the `get_recs` field to your `Event.track` call.
|
111
|
+
|
112
|
+
begin
|
113
|
+
e = Tamber::Event.track(
|
114
|
+
user: 'user_rlox8k927z7p',
|
115
|
+
behavior: 'clicked'
|
116
|
+
item: 'item_wmt4fn6o4zlk',
|
117
|
+
get_recs: {
|
118
|
+
number: 14
|
119
|
+
}
|
120
|
+
)
|
121
|
+
e.recommended.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
122
|
+
rescue TamberError => error
|
123
|
+
puts error.message
|
124
|
+
end
|
125
|
+
|
126
|
+
==== Trending
|
127
|
+
|
128
|
+
Help your users keep their fingers on the pulse of your platform by showing them the hottest, most popular, newest, or most up-and-coming items.
|
129
|
+
|
130
|
+
begin
|
131
|
+
d = Tamber::Discover.hot() // the hottest (trending) items
|
132
|
+
d.each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
133
|
+
end
|
134
|
+
|
135
|
+
begin
|
136
|
+
d = Tamber::Discover.popular() // the hottest (trending) items
|
137
|
+
end
|
138
|
+
|
139
|
+
// BETA endpoints
|
140
|
+
begin
|
141
|
+
d = Tamber::Discover.uac() // the most up-and-coming items
|
142
|
+
end
|
143
|
+
|
144
|
+
begin
|
145
|
+
d = Tamber::Discover.new() // the newest items
|
146
|
+
end
|
147
|
+
|
148
|
+
==== Build Your Own Features
|
149
|
+
|
150
|
+
Tamber allows you to use lower-level methods to get lists of recommended items, similar item matches, and similar items for a given user with which you can build your own discovery experiences. Importantly, these methods return raw recommendation data and are not intended to be pushed directly to users.
|
151
|
+
|
152
|
+
begin
|
153
|
+
Tamber::Discover.recommended(user: 'user_rlox8k927z7p').each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
154
|
+
rescue TamberError => error
|
155
|
+
puts error.message
|
156
|
+
end
|
157
|
+
|
158
|
+
begin
|
159
|
+
Tamber::Discover.similar(item: 'item_wmt4fn6o4zlk').each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
160
|
+
rescue TamberError => error
|
161
|
+
puts error.message
|
162
|
+
end
|
163
|
+
|
164
|
+
begin
|
165
|
+
Tamber::Discover.recommendedSimilar(
|
166
|
+
user: 'user_rlox8k927z7p',
|
167
|
+
item: 'item_wmt4fn6o4zlk'
|
168
|
+
).each { |rec| puts "item: #{rec.item}, score: #{rec.score}"}
|
169
|
+
rescue TamberError => error
|
170
|
+
puts error.message
|
171
|
+
end
|
172
|
+
|
173
|
+
=== Sync Items (optional)
|
174
|
+
|
175
|
+
Keep Tamber in sync with your item data in order to use recommendation filtering. Just call `Item.update` wherever you create and update items in your backend. If you have a Database module, we recommend adding this method there.
|
176
|
+
|
177
|
+
require 'tamber'
|
178
|
+
Tamber.project_key = 'your_project_key'
|
179
|
+
|
180
|
+
begin
|
181
|
+
Tamber::Item.update(
|
182
|
+
id: 'item_wmt4fn6o4zlk',
|
183
|
+
updates: {
|
184
|
+
add: {
|
185
|
+
properties: {
|
186
|
+
'available_large': false,
|
187
|
+
'stock': 89
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
)
|
192
|
+
rescue TamberError => error
|
193
|
+
puts error.message
|
194
|
+
end
|
195
|
+
|
196
|
+
See {Tests}[https://github.com/tamber/tamber-ruby/tree/master/test] for more examples.
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.7
|