outbound 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/outbound.rb +19 -35
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0880d96cb2a3a97eab063a1bb7f5b2528e945a74
|
4
|
+
data.tar.gz: 296c46923e1fa4061f56932b84e6b1ab2140c45b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cf9dff2e7df82501cffe497ce61962baa9587cdb84d88d89122971fb2394954e85abe3eeede3e45b9723f254b8f25f0b56b5e53f7646fde2708706c9ee94066
|
7
|
+
data.tar.gz: dc781b782d9406d93ba570a7c8c8ddc7ecb61900fe4c8575377ac5f2a0578b7498f930ce0d1d160abc2e69d97ad13eb2356ac4b64e435d3200a9092bec410910
|
data/lib/outbound.rb
CHANGED
@@ -4,7 +4,7 @@ require 'net/http'
|
|
4
4
|
require 'uri'
|
5
5
|
|
6
6
|
module Outbound
|
7
|
-
VERSION = '1.0.
|
7
|
+
VERSION = '1.0.1'
|
8
8
|
BASE_URL = 'https://api.outbound.io/v2'
|
9
9
|
|
10
10
|
APNS = "apns"
|
@@ -29,51 +29,51 @@ module Outbound
|
|
29
29
|
}
|
30
30
|
end
|
31
31
|
|
32
|
-
def Outbound.init
|
32
|
+
def Outbound.init(api_key, log_level=Logger::ERROR)
|
33
33
|
@logger.level = log_level
|
34
34
|
@ob = Outbound::Client.new api_key, @logger
|
35
35
|
end
|
36
36
|
|
37
|
-
def Outbound.identify
|
37
|
+
def Outbound.identify(user_id, info={})
|
38
38
|
if @ob == nil
|
39
39
|
res = Result.new Outbound::ERROR_INIT, false
|
40
40
|
@logger.error res.error
|
41
41
|
return res
|
42
42
|
end
|
43
|
-
return @ob.identify
|
43
|
+
return @ob.identify(user_id, info)
|
44
44
|
end
|
45
45
|
|
46
|
-
def Outbound.track
|
46
|
+
def Outbound.track(user_id, event, properties={}, timestamp=Time.now.to_i)
|
47
47
|
if @ob == nil
|
48
48
|
res = Result.new Outbound::ERROR_INIT, false
|
49
49
|
@logger.error res.error
|
50
50
|
return res
|
51
51
|
end
|
52
|
-
return @ob.track
|
52
|
+
return @ob.track(user_id, event, properties, timestamp)
|
53
53
|
end
|
54
54
|
|
55
|
-
def Outbound.disable
|
55
|
+
def Outbound.disable(platform, user_id, token)
|
56
56
|
if @ob == nil
|
57
57
|
res = Result.new Outbound::ERROR_INIT, false
|
58
58
|
@logger.error res.error
|
59
59
|
return res
|
60
60
|
end
|
61
|
-
return @ob.disable
|
61
|
+
return @ob.disable(platform, user_id, token)
|
62
62
|
end
|
63
63
|
|
64
|
-
def Outbound.register
|
64
|
+
def Outbound.register(platform, user_id, token)
|
65
65
|
if @ob == nil
|
66
66
|
res = Result.new Outbound::ERROR_INIT, false
|
67
67
|
@logger.error res.error
|
68
68
|
return res
|
69
69
|
end
|
70
|
-
return @ob.register
|
70
|
+
return @ob.register(platform, user_id, token)
|
71
71
|
end
|
72
72
|
|
73
73
|
class Result
|
74
74
|
include Defaults
|
75
75
|
|
76
|
-
def initialize
|
76
|
+
def initialize(error, received_call)
|
77
77
|
@error = error
|
78
78
|
@received_call = received_call
|
79
79
|
end
|
@@ -113,12 +113,12 @@ module Outbound
|
|
113
113
|
class Client
|
114
114
|
include Defaults
|
115
115
|
|
116
|
-
def initialize
|
116
|
+
def initialize(api_key, logger)
|
117
117
|
@api_key = api_key
|
118
118
|
@logger = logger
|
119
119
|
end
|
120
120
|
|
121
|
-
def identify
|
121
|
+
def identify(user_id, info={})
|
122
122
|
unless user_id.is_a? String or user_id.is_a? Numeric
|
123
123
|
res = Result.new Outbound::ERROR_USER_ID, false
|
124
124
|
@logger.error res.error
|
@@ -136,7 +136,7 @@ module Outbound
|
|
136
136
|
return post(@api_key, '/identify', user_data)
|
137
137
|
end
|
138
138
|
|
139
|
-
def track
|
139
|
+
def track(user_id, event, properties={}, user_info={}, timestamp=Time.now.to_i)
|
140
140
|
unless user_id.is_a? String or user_id.is_a? Numeric
|
141
141
|
res = Result.new Outbound::ERROR_USER_ID, false
|
142
142
|
@logger.error res.error
|
@@ -151,15 +151,6 @@ module Outbound
|
|
151
151
|
|
152
152
|
data = {:user_id => user_id, :event => event}
|
153
153
|
|
154
|
-
begin
|
155
|
-
user = user(user_info)
|
156
|
-
if user.length > 0
|
157
|
-
data[:user] = user
|
158
|
-
end
|
159
|
-
rescue
|
160
|
-
@logger.error "Could not use user info (#{user_info}) and/or user attributes #{user_attributes} given to track call."
|
161
|
-
end
|
162
|
-
|
163
154
|
if properties.is_a? Hash
|
164
155
|
if properties.length > 0
|
165
156
|
data[:properties] = properties
|
@@ -168,20 +159,13 @@ module Outbound
|
|
168
159
|
@logger.error "Could not use event properties (#{properties}) given to track call."
|
169
160
|
end
|
170
161
|
|
162
|
+
data[:timestamp] = timestamp
|
171
163
|
puts timestamp
|
172
164
|
|
173
|
-
unless timestamp == {}
|
174
|
-
data[:timestamp] = timestamp
|
175
|
-
else
|
176
|
-
data[:timestamp] = Time.now.to_i
|
177
|
-
end
|
178
|
-
|
179
|
-
puts data[:timestamp]
|
180
|
-
|
181
165
|
return post(@api_key, '/track', data)
|
182
166
|
end
|
183
167
|
|
184
|
-
def disable
|
168
|
+
def disable(platform, user_id, token)
|
185
169
|
unless user_id.is_a? String or user_id.is_a? Numeric
|
186
170
|
res = Result.new Outbound::ERROR_USER_ID, false
|
187
171
|
@logger.error res.error
|
@@ -203,7 +187,7 @@ module Outbound
|
|
203
187
|
return post(@api_key, "/#{platform}/disable", {:token => token, :user_id => user_id})
|
204
188
|
end
|
205
189
|
|
206
|
-
def register
|
190
|
+
def register(platform, user_id, token)
|
207
191
|
unless user_id.is_a? String or user_id.is_a? Numeric
|
208
192
|
res = Result.new Outbound::ERROR_USER_ID, false
|
209
193
|
@logger.error res.error
|
@@ -227,7 +211,7 @@ module Outbound
|
|
227
211
|
|
228
212
|
private
|
229
213
|
|
230
|
-
def post
|
214
|
+
def post(api_key, path, data)
|
231
215
|
begin
|
232
216
|
headers = HEADERS
|
233
217
|
headers['X-Outbound-Key'] = api_key
|
@@ -253,7 +237,7 @@ module Outbound
|
|
253
237
|
return err, true
|
254
238
|
end
|
255
239
|
|
256
|
-
def user
|
240
|
+
def user(info={})
|
257
241
|
unless info.is_a? Hash
|
258
242
|
raise
|
259
243
|
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outbound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Beauvais
|
8
|
-
- Muhammad Usman
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-06-07 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: |-
|
15
14
|
Outbound sends automated email, SMS, phone calls and push notifications based on the actions users take or do not take in your app. The Outbound API has two components:
|