talkable 0.0.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +4 -2
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +126 -0
- data/LICENSE +22 -0
- data/README.md +144 -185
- data/Rakefile +17 -0
- data/lib/talkable.rb +43 -0
- data/lib/talkable/api.rb +13 -0
- data/lib/talkable/api/base.rb +98 -0
- data/lib/talkable/api/offer.rb +11 -0
- data/lib/talkable/api/origin.rb +29 -0
- data/lib/talkable/api/person.rb +17 -0
- data/lib/talkable/api/referral.rb +19 -0
- data/lib/talkable/api/reward.rb +19 -0
- data/lib/talkable/api/share.rb +19 -0
- data/lib/talkable/api/visitor.rb +13 -0
- data/lib/talkable/configuration.rb +40 -0
- data/lib/talkable/generators/install_generator.rb +81 -0
- data/lib/talkable/generators/templates/app/controllers/invite_controller.rb +8 -0
- data/lib/talkable/generators/templates/app/views/invite/show.html.erb +2 -0
- data/lib/talkable/generators/templates/app/views/invite/show.html.haml +2 -0
- data/lib/talkable/generators/templates/app/views/invite/show.html.slim +2 -0
- data/lib/talkable/generators/templates/app/views/shared/_talkable_offer.html.erb +4 -0
- data/lib/talkable/generators/templates/app/views/shared/_talkable_offer.html.haml +3 -0
- data/lib/talkable/generators/templates/app/views/shared/_talkable_offer.html.slim +3 -0
- data/lib/talkable/generators/templates/config/initializers/talkable.rb +13 -0
- data/lib/talkable/integration.rb +41 -0
- data/lib/talkable/middleware.rb +147 -0
- data/lib/talkable/railtie.rb +11 -0
- data/lib/talkable/resources.rb +3 -0
- data/lib/talkable/resources/offer.rb +49 -0
- data/lib/talkable/resources/origin.rb +22 -0
- data/lib/talkable/version.rb +3 -0
- data/solano.yml +20 -0
- data/talkable.gemspec +37 -0
- metadata +202 -9
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Y2MzNjExMDczNTIxNjUwMzA4YWNjYTY1M2MzMzg2Y2M1NDAyM2YxNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTdmZTFiYTIwNzZhNDJmNjhhOWVlNmJkZWQwNzNhYTc2MGNhMTk4Mw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NmNlMGVjMWRiOTZhZTMzOTZhMjZhNGI0ODBhYzRmYzczYjdlOGZkOTg3NDE1
|
10
|
+
NDg3ODIyMzBiMGFhMzMxMzZmMjQ0NTA0NWQ3MWQyOGE5YTFiZTdiZmU1MjVj
|
11
|
+
MGJlYmJjMWFkNzk3M2MwZmZhZjRlNzdjNTQwNDA2MjViNmVhMzA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTBjZDU2NDJhYzYzZWU5NGMxOTZmZGNkMzhmM2NkMjMzODY0ODQzMDg5NDU5
|
14
|
+
M2I0ZjNmNzk0YWVjN2ViNzc2MmIyMDRjMDYxZGZjODc0ZWE5YjUxMTc4YWM3
|
15
|
+
OTExYzhhOTYzZGI1N2Q4Nzk0YjQyZWZiNmY0NWQ3ODNhOGJiYWI=
|
data/.gitignore
CHANGED
@@ -43,8 +43,10 @@ build-iPhoneSimulator/
|
|
43
43
|
# for a library or gem, you might want to ignore these files since the code is
|
44
44
|
# intended to run in multiple environments; otherwise, check them in:
|
45
45
|
# Gemfile.lock
|
46
|
-
|
47
|
-
|
46
|
+
.ruby-version
|
47
|
+
.ruby-gemset
|
48
48
|
|
49
49
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
50
|
.rvmrc
|
51
|
+
|
52
|
+
.DS_Store
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
talkable (0.9.0)
|
5
|
+
furi (~> 0.2)
|
6
|
+
hashie (~> 3.4)
|
7
|
+
rack (>= 1.5.2, < 2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionpack (4.2.7.1)
|
13
|
+
actionview (= 4.2.7.1)
|
14
|
+
activesupport (= 4.2.7.1)
|
15
|
+
rack (~> 1.6)
|
16
|
+
rack-test (~> 0.6.2)
|
17
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
18
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
19
|
+
actionview (4.2.7.1)
|
20
|
+
activesupport (= 4.2.7.1)
|
21
|
+
builder (~> 3.1)
|
22
|
+
erubis (~> 2.7.0)
|
23
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
24
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
25
|
+
activesupport (4.2.7.1)
|
26
|
+
i18n (~> 0.7)
|
27
|
+
json (~> 1.7, >= 1.7.7)
|
28
|
+
minitest (~> 5.1)
|
29
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
30
|
+
tzinfo (~> 1.1)
|
31
|
+
addressable (2.4.0)
|
32
|
+
ammeter (1.1.3)
|
33
|
+
activesupport (>= 3.0)
|
34
|
+
railties (>= 3.0)
|
35
|
+
rspec-rails (>= 2.2)
|
36
|
+
builder (3.2.2)
|
37
|
+
crack (0.4.3)
|
38
|
+
safe_yaml (~> 1.0.0)
|
39
|
+
diff-lcs (1.2.5)
|
40
|
+
docile (1.1.5)
|
41
|
+
erubis (2.7.0)
|
42
|
+
furi (0.2.0)
|
43
|
+
haml (4.0.7)
|
44
|
+
tilt
|
45
|
+
hashdiff (0.3.0)
|
46
|
+
hashie (3.4.4)
|
47
|
+
i18n (0.7.0)
|
48
|
+
json (1.8.3)
|
49
|
+
loofah (2.0.3)
|
50
|
+
nokogiri (>= 1.5.9)
|
51
|
+
mini_portile2 (2.1.0)
|
52
|
+
minitest (5.9.0)
|
53
|
+
nokogiri (1.6.8)
|
54
|
+
mini_portile2 (~> 2.1.0)
|
55
|
+
pkg-config (~> 1.1.7)
|
56
|
+
pkg-config (1.1.7)
|
57
|
+
rack (1.6.4)
|
58
|
+
rack-test (0.6.3)
|
59
|
+
rack (>= 1.0)
|
60
|
+
rails-deprecated_sanitizer (1.0.3)
|
61
|
+
activesupport (>= 4.2.0.alpha)
|
62
|
+
rails-dom-testing (1.0.7)
|
63
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
64
|
+
nokogiri (~> 1.6.0)
|
65
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
66
|
+
rails-html-sanitizer (1.0.3)
|
67
|
+
loofah (~> 2.0)
|
68
|
+
railties (4.2.7.1)
|
69
|
+
actionpack (= 4.2.7.1)
|
70
|
+
activesupport (= 4.2.7.1)
|
71
|
+
rake (>= 0.8.7)
|
72
|
+
thor (>= 0.18.1, < 2.0)
|
73
|
+
rake (11.2.2)
|
74
|
+
rspec (3.5.0)
|
75
|
+
rspec-core (~> 3.5.0)
|
76
|
+
rspec-expectations (~> 3.5.0)
|
77
|
+
rspec-mocks (~> 3.5.0)
|
78
|
+
rspec-core (3.5.1)
|
79
|
+
rspec-support (~> 3.5.0)
|
80
|
+
rspec-expectations (3.5.0)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.5.0)
|
83
|
+
rspec-mocks (3.5.0)
|
84
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
+
rspec-support (~> 3.5.0)
|
86
|
+
rspec-rails (3.5.2)
|
87
|
+
actionpack (>= 3.0)
|
88
|
+
activesupport (>= 3.0)
|
89
|
+
railties (>= 3.0)
|
90
|
+
rspec-core (~> 3.5.0)
|
91
|
+
rspec-expectations (~> 3.5.0)
|
92
|
+
rspec-mocks (~> 3.5.0)
|
93
|
+
rspec-support (~> 3.5.0)
|
94
|
+
rspec-support (3.5.0)
|
95
|
+
safe_yaml (1.0.4)
|
96
|
+
simplecov (0.12.0)
|
97
|
+
docile (~> 1.1.0)
|
98
|
+
json (>= 1.8, < 3)
|
99
|
+
simplecov-html (~> 0.10.0)
|
100
|
+
simplecov-html (0.10.0)
|
101
|
+
thor (0.19.1)
|
102
|
+
thread_safe (0.3.5)
|
103
|
+
tilt (2.0.5)
|
104
|
+
tzinfo (1.2.2)
|
105
|
+
thread_safe (~> 0.1)
|
106
|
+
webmock (2.1.0)
|
107
|
+
addressable (>= 2.3.6)
|
108
|
+
crack (>= 0.3.2)
|
109
|
+
hashdiff
|
110
|
+
|
111
|
+
PLATFORMS
|
112
|
+
ruby
|
113
|
+
|
114
|
+
DEPENDENCIES
|
115
|
+
ammeter
|
116
|
+
bundler (~> 1.12)
|
117
|
+
haml
|
118
|
+
json (~> 1.8.3)
|
119
|
+
rake (~> 11.2)
|
120
|
+
rspec (~> 3.4)
|
121
|
+
simplecov (~> 0.12)
|
122
|
+
talkable!
|
123
|
+
webmock (~> 2.1)
|
124
|
+
|
125
|
+
BUNDLED WITH
|
126
|
+
1.12.5
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Talkable
|
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
CHANGED
@@ -1,12 +1,23 @@
|
|
1
|
-
# Talkable Referral
|
1
|
+
# Talkable Referral Program API Gem
|
2
|
+
[![](https://ci.solanolabs.com:443/Talkable/talkable-ruby/badges/branches/master?badge_token=c2445aee31992aafe3d8fda62fcde2708f6254f6)](https://ci.solanolabs.com:443/Talkable/talkable-ruby/suites/484176)
|
2
3
|
|
3
4
|
Talkable Ruby Gem to make your own referral program in Sinatra or Rails application
|
4
5
|
|
6
|
+
## Demo
|
5
7
|
|
8
|
+
Example of usage at http://github.com/talkable/talkable-spree-example
|
6
9
|
|
7
|
-
|
10
|
+
Live demo available at http://spree-example.talkable.com
|
11
|
+
|
12
|
+
## Requirements
|
13
|
+
|
14
|
+
Gem requires:
|
15
|
+
- `Ruby` version since `1.9.3`
|
16
|
+
- `Rack` version since `1.5.2`
|
8
17
|
|
9
|
-
|
18
|
+
Gem supports:
|
19
|
+
- `Ruby on Rails` since `4.0.0`
|
20
|
+
- `Sinatra` since `1.4.0`
|
10
21
|
|
11
22
|
## Intallation
|
12
23
|
|
@@ -14,232 +25,180 @@ Take a spree demo app and intall Talkable
|
|
14
25
|
gem "talkable"
|
15
26
|
```
|
16
27
|
|
17
|
-
|
28
|
+
### Step by step instruction
|
18
29
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
30
|
+
- [Setup configuration file __*__](#configuration)
|
31
|
+
- [Add Middleware __*__](#add-talkable-middleware)
|
32
|
+
- [Load an offer __*__](#load-an-offer)
|
33
|
+
- [Display a share page __*__](#display-an-offer-inside-view)
|
34
|
+
- [Integrate Conversion Points](#integrate-conversion-points)
|
35
|
+
- [Registering a purchase](#registering-a-purchase)
|
36
|
+
- [Registering other events](#registering-other-events)
|
37
|
+
|
38
|
+
__*__ - Automated in Ruby On Rails by using the generator
|
26
39
|
|
40
|
+
## Using the Ruby On Rails Generator
|
27
41
|
|
28
|
-
|
29
|
-
update app/controllers/application_controller.rb
|
42
|
+
Talkable gem provides Ruby On Rails generator to automate an integration process.
|
30
43
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
44
|
+
``` sh
|
45
|
+
rails generate talkable:install
|
46
|
+
```
|
47
|
+
``` sh
|
48
|
+
Your Talkable site slug: spree-example
|
49
|
+
Your Talkable API Key: SOME-API-KEY
|
50
|
+
Do you have a custom domain? [Y/n] n
|
51
|
+
```
|
52
|
+
``` sh
|
53
|
+
create config/initializers/talkable.rb
|
54
|
+
insert app/controllers/application_controller.rb
|
55
|
+
insert app/controllers/application_controller.rb
|
56
|
+
create app/views/shared
|
57
|
+
create app/views/shared/_talkable_offer.html.erb
|
58
|
+
insert app/views/layouts/application.html.erb
|
59
|
+
create app/controllers/invite_controller.rb
|
60
|
+
create app/views/invite/show.html.erb
|
61
|
+
route get '/invite' => 'invite#show'
|
36
62
|
```
|
37
63
|
|
38
64
|
## Configuration
|
39
65
|
|
40
66
|
``` ruby
|
41
|
-
Talkable.configure do |
|
42
|
-
#
|
43
|
-
|
44
|
-
# or
|
45
|
-
c.site_slug = Rails.env.production? ? "hello" : "hello-staging"
|
46
|
-
# required
|
47
|
-
c.api_token = Rails.env.production? ? "1235" : "6789"
|
48
|
-
# required
|
49
|
-
c.server = 'http://invite.site.com' # fetched from site settings automatically using generator
|
50
|
-
# optional
|
51
|
-
c.js_integration_library = 'http://d2jj/integration/hello.js' # default
|
52
|
-
end
|
53
|
-
```
|
54
|
-
|
67
|
+
Talkable.configure do |config|
|
68
|
+
# site slug is taken form ENV["TALKABLE_SITE_SLUG"]
|
69
|
+
config.site_slug = "spree-example"
|
55
70
|
|
71
|
+
# api key is taken from ENV["TALKABLE_API_KEY"]
|
72
|
+
# config.api_key =
|
56
73
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
initialize_talkable_api
|
74
|
+
# custom server address - by default https://www.talkable.com
|
75
|
+
# config.server =
|
61
76
|
|
77
|
+
# manually specified per-client integration library
|
78
|
+
# config.js_integration_library =
|
62
79
|
end
|
63
80
|
|
64
|
-
# GEM internals
|
65
|
-
class Talkable
|
66
|
-
module ActionControllerExtension
|
67
|
-
def self.initialize_talkable_api
|
68
|
-
before_action :talkable_before_request
|
69
|
-
end
|
70
|
-
|
71
|
-
def talkable_before_request
|
72
|
-
cookies[:talkable_visitor_uuid] = params[:talkable_visitor_uuid] || talkable_visitor_uuid
|
73
|
-
Talkable.with_uuid(talkable_visitor_uuid) do
|
74
|
-
yield
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def talkable_visitor_uuid
|
79
|
-
cookies[:talkable_visitor_uuid] ||= Talkable.find_or_generate_uuid
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
81
|
```
|
84
82
|
|
83
|
+
## Manual Integration
|
85
84
|
|
86
|
-
|
87
|
-
|
88
|
-
## API
|
89
|
-
|
90
|
-
Full API support according to DOC
|
91
|
-
|
85
|
+
### Add Talkable Middleware
|
92
86
|
|
93
87
|
``` ruby
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
subtotal: 100.53,
|
98
|
-
coupon_codes: [],
|
99
|
-
traffic_source: 'zz'
|
100
|
-
},
|
101
|
-
)
|
102
|
-
origin = Talkable::API.register_event()
|
103
|
-
origin = Talkable::API.register_affiliate_member(
|
104
|
-
offer = origin.offer
|
105
|
-
{
|
106
|
-
email: '...'
|
107
|
-
sharing_channels: ['facebook', 'embedded_email', 'sms', 'other']
|
108
|
-
}
|
109
|
-
)
|
110
|
-
|
111
|
-
offer.claim_links # =>
|
112
|
-
# {
|
113
|
-
# twitter: "http://invite.site.com/x/12356"
|
114
|
-
# facebook: "http://invite.site.com/x/12356"
|
115
|
-
# embedded_email: "http://invite.site.com/x/12356"
|
116
|
-
# twitter: "http://invite.site.com/x/12356"
|
117
|
-
# }
|
88
|
+
class Application < Rails::Application
|
89
|
+
config.middleware.use Talkable::Middleware
|
90
|
+
end
|
118
91
|
```
|
119
92
|
|
120
|
-
|
93
|
+
### Load an offer
|
121
94
|
|
95
|
+
Floating widget at every page
|
122
96
|
|
97
|
+
```ruby
|
98
|
+
class ApplicationController < ActionController::Base
|
99
|
+
before_action :load_talkable_offer
|
123
100
|
|
124
|
-
|
101
|
+
protected
|
125
102
|
|
126
|
-
|
127
|
-
|
103
|
+
def load_talkable_offer
|
104
|
+
origin = Talkable.register_affiliate_member(campaign_tags: 'popup')
|
105
|
+
@offer ||= origin.offer if origin
|
106
|
+
end
|
128
107
|
|
108
|
+
end
|
129
109
|
```
|
130
110
|
|
131
|
-
|
111
|
+
or invite page at specific path
|
132
112
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
<script>
|
141
|
-
_talkableq.push(['init', {
|
142
|
-
server: '...',
|
143
|
-
site_id: '...',
|
144
|
-
visitor_uuid: '...'
|
145
|
-
}])
|
146
|
-
_talkableq.push(['show_offer'], "https://invite.site.com/x/38828", {container: 'talkable-offer-xxx'})
|
147
|
-
</script>
|
113
|
+
```ruby
|
114
|
+
class InviteController < ApplicationController
|
115
|
+
def show
|
116
|
+
origin = Talkable.register_affiliate_member(campaign_tags: 'invite')
|
117
|
+
@offer = origin.offer if origin
|
118
|
+
end
|
119
|
+
end
|
148
120
|
```
|
149
121
|
|
150
|
-
|
122
|
+
### Getting information about an offer
|
151
123
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
talkable.showOffer(offer.show_url)
|
124
|
+
```ruby
|
125
|
+
offer = origin.offer
|
126
|
+
offer.claim_links # => { facebook: "https://www.talkable.com/x/kqiYhR", sms: "https://www.talkable.com/x/PFxhNB" }
|
156
127
|
```
|
157
128
|
|
129
|
+
### Display an offer inside view
|
158
130
|
|
159
|
-
|
160
|
-
|
131
|
+
Provide iframe options to show a share page in specific place
|
161
132
|
|
162
|
-
```
|
163
|
-
offer
|
164
|
-
|
165
|
-
title: ['An offer for all my friends', 'Claim your reward'], # AB test
|
166
|
-
description: 'Click this link and get #{campaign.friend_incentive.description} off on the merchant.com'
|
167
|
-
image: "http://merchant.com/assets/fb_image.jpg"
|
168
|
-
},
|
169
|
-
twitter: {
|
170
|
-
message: 'Click #{offer.claim_links.twitter} and get {{friend_incentive.description}} off on the merchant.com'
|
171
|
-
},
|
172
|
-
)
|
173
|
-
|
174
|
-
|
175
|
-
offer.configure(
|
176
|
-
twitter: {
|
177
|
-
message: 'Click #{offer.claim_links.twitter} and get {{friend_incentive.description}} off on the merchant.com'
|
178
|
-
},
|
179
|
-
|
180
|
-
)
|
133
|
+
```erb
|
134
|
+
<div id="talkable-inline-offer-container"></div>
|
135
|
+
<%== offer.advocate_share_iframe(iframe: {container: 'talkable-inline-offer-container'}) %>
|
181
136
|
```
|
182
137
|
|
138
|
+
## Integrate Conversion Points
|
183
139
|
|
140
|
+
### Registering a purchase
|
184
141
|
|
142
|
+
Registering a purchase has to be implemented manually based on your platform.
|
143
|
+
> It's highly required to have submitted purchases for closing a referral loop.
|
185
144
|
|
186
|
-
```
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
145
|
+
```ruby
|
146
|
+
Talkable::API::Origin.create(Talkable::API::Origin::PURCHASE, {
|
147
|
+
email: 'customer@email.com',
|
148
|
+
order_number: 'ORDER-12345',
|
149
|
+
subtotal: 123.45,
|
150
|
+
coupon_code: 'SALE10', # optional
|
151
|
+
ip_address: request.remote_ip, # optional
|
152
|
+
shipping_zip: '94103', # optional
|
153
|
+
shipping_address: '290 Division St., Suite 405, San Francisco, California, 94103, United States', # optional
|
154
|
+
items: order_items.map do |item|
|
155
|
+
{
|
156
|
+
price: item.price,
|
157
|
+
quantity: item.quantity,
|
158
|
+
product_id: item.product_id,
|
159
|
+
title: item.title,
|
160
|
+
}
|
161
|
+
end # optional
|
162
|
+
})
|
199
163
|
```
|
200
164
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
165
|
+
### Registering other events
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
Talkable::API::Origin.create(Talkable::API::Origin::EVENT, {
|
169
|
+
email: 'customer@email.com',
|
170
|
+
event_number: 'N12345',
|
171
|
+
event_category: 'user_signuped',
|
172
|
+
subtotal: 123.45, # optional
|
173
|
+
coupon_code: 'SALE10', # optional
|
174
|
+
ip_address: request.remote_ip, # optional
|
175
|
+
shipping_zip: '94103', # optional
|
176
|
+
shipping_address: '290 Division St., Suite 405, San Francisco, California, 94103, United States', # optional
|
177
|
+
items: order_items.map do |item|
|
178
|
+
{
|
179
|
+
price: item.price,
|
180
|
+
quantity: item.quantity,
|
181
|
+
product_id: item.product_id,
|
182
|
+
title: item.title,
|
183
|
+
}
|
184
|
+
end # optional
|
185
|
+
})
|
212
186
|
```
|
213
187
|
|
188
|
+
## API
|
214
189
|
|
215
|
-
|
216
|
-
|
217
|
-
|
190
|
+
Full API support according to [DOC](http://docs.talkable.com/api_v2.html)
|
191
|
+
|
192
|
+
```ruby
|
193
|
+
Talkable::API::Origin.create(Talkable::API::Origin::PURCHASE, {
|
194
|
+
email: 'customer@domain.com',
|
195
|
+
order_number: '123',
|
196
|
+
subtotal: 34.56,
|
197
|
+
})
|
198
|
+
Talkable::API::Offer.find(short_url_code)
|
199
|
+
Talkable::API::Share.create(short_url_code, Talkable::API::Share::CHANNEL_SMS)
|
200
|
+
Talkable::API::Reward.find(visitor_uuid: '8fdf75ac-92b4-479d-9974-2f9c64eb2e09')
|
201
|
+
Talkable::API::Person.find(email)
|
202
|
+
Talkable::API::Person.update(email, unsubscribed: true)
|
203
|
+
Talkable::API::Referral.update(order_number, Talkable::API::Referral::APPROVED)
|
218
204
|
```
|
219
|
-
|
220
|
-
|
221
|
-
## TODO
|
222
|
-
|
223
|
-
Functionality:
|
224
|
-
|
225
|
-
* [ ] Gem infrustructure
|
226
|
-
* [ ] Configuration
|
227
|
-
* [ ] API
|
228
|
-
* Custom Traffic Source
|
229
|
-
* Custom User Agent
|
230
|
-
* Visitors
|
231
|
-
* Origins
|
232
|
-
* Shares
|
233
|
-
* Rewards
|
234
|
-
* [ ] Controller uuid hook
|
235
|
-
* [ ] Offer Share Iframe
|
236
|
-
* [ ] Integration JS additions
|
237
|
-
* [ ] Ruby iframe generation method
|
238
|
-
* [ ] Generator
|
239
|
-
* [ ] Documentation
|
240
|
-
* Post-Checkout integration instructions
|
241
|
-
* Events integration instructions
|
242
|
-
* [ ] Setup demo with the most popular ruby shopping cart gem
|
243
|
-
|
244
|
-
Caveats:
|
245
|
-
* [ ] Prevent API call to create visitor on first request. Delay until user interacts with RAF.
|