sift 1.1.6.2 → 1.1.7.0
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 +8 -8
- data/HISTORY +44 -0
- data/lib/sift/client.rb +55 -16
- data/lib/sift/version.rb +1 -1
- data/spec/unit/client_label_spec.rb +18 -4
- data/spec/unit/client_spec.rb +49 -49
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWU0ZjhlZTFmYWZiOGQwMDY3NDIwNjFiZDgyYmQ5NDUxMDgzZTI3Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTZlNjYwZmVjMzZiZGZiNTMwYTYzY2E4OTBlMDVhM2M1MzI0OTViZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2NlMzk3MzQ2ZTgwMGQ4MzU5NGM1NDgyOTBjZWFlZTJkNDljYTk4OTE4Y2Iz
|
10
|
+
NzBlODBjMmIyZWMzNjY0MzQ0Mzk4MzA3YmU2Y2ZmMTQwNzE5ZjFmZTVkYTNi
|
11
|
+
YTVjZjI2NjM5Y2Y2NWFiYzYyZjgxNTUxY2Y2NTM4ZThkYTQ4NmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzQ0MmRhODAyZmJkNGU2ODdhZjdkNmYyMzIwZjZiYWZlYmE0OWJmODFlYWFk
|
14
|
+
MDFhODRlZjc1NzVlNDQzNzhlMzQ4MWM2NDI5MDE3NGQ0OGJlNTQ3MGVkZTc2
|
15
|
+
ZGY1ZDlkZTk4MjE2YTZjMWI0ZGJjNjEzNDY1Njc1OGJiMGMxODM=
|
data/HISTORY
CHANGED
@@ -1,3 +1,47 @@
|
|
1
|
+
=== 1.1.6.2 2014-09-19
|
2
|
+
* added API key parameter to track and label functions
|
3
|
+
|
4
|
+
=== 1.1.6.0 2014-09-03
|
5
|
+
* added module scoped API key variable
|
6
|
+
|
7
|
+
=== 1.1.4 2014-01-02
|
8
|
+
* removed support for ruby 1.9.2
|
9
|
+
* track/label return nil on failure
|
10
|
+
|
11
|
+
=== 1.1.3 2013-12-10
|
12
|
+
* nil values are removed from JSON body sent to track/label now.
|
13
|
+
* relaxed multi_json requirement to 1.0 or newer
|
14
|
+
* relaxed httparty requirement to 0.11.0 or newer
|
15
|
+
* migrated from fakeweb to webmock 1.16.0 or newer
|
16
|
+
|
17
|
+
=== 1.1.1 2013-11-14
|
18
|
+
* score request now requires API key
|
19
|
+
|
20
|
+
=== 1.1.0 2013-11-08
|
21
|
+
* now uses v203 API endpoint by default
|
22
|
+
|
23
|
+
=== 1.0.13 2014-10-22
|
24
|
+
* added path parameter to track function
|
25
|
+
* added label function for applying labels
|
26
|
+
* now requires httparty 0.12.0 or newer
|
27
|
+
* now requires multi_json 1.8.2 or newer
|
28
|
+
* now requires rspec 2.14.1 or newer for compilation only
|
29
|
+
|
30
|
+
=== 1.0.12 2013-06-13
|
31
|
+
* added score function for getting user scores.
|
32
|
+
* now requires httparty 0.10.0 or newer
|
33
|
+
* added rspec 2.0 or newer and rake dependency
|
34
|
+
|
35
|
+
=== 1.0.10 2013-01-09
|
36
|
+
* Add configurable path variable to Client
|
37
|
+
|
38
|
+
=== 1.0.5 2012-07-20
|
39
|
+
|
40
|
+
=== 1.0.3 2012-05-05
|
41
|
+
|
42
|
+
=== 1.0.2 2012-05-03
|
43
|
+
|
44
|
+
=== 1.0.1 2012-05-02
|
1
45
|
|
2
46
|
=== 1.0 2012-05-02
|
3
47
|
* Initial release
|
data/lib/sift/client.rb
CHANGED
@@ -7,6 +7,7 @@ module Sift
|
|
7
7
|
#
|
8
8
|
class Response
|
9
9
|
attr_reader :body
|
10
|
+
attr_reader :http_class
|
10
11
|
attr_reader :http_status_code
|
11
12
|
attr_reader :api_status
|
12
13
|
attr_reader :api_error_message
|
@@ -20,12 +21,17 @@ module Sift
|
|
20
21
|
# a JSON object that can be decoded into status, message and request
|
21
22
|
# sections.
|
22
23
|
#
|
23
|
-
def initialize(http_response, http_response_code)
|
24
|
-
@body = MultiJson.load(http_response)
|
25
|
-
@request = MultiJson.load(@body["request"].to_s) if @body["request"]
|
24
|
+
def initialize(http_response, http_headers, http_response_code, http_raw_response)
|
26
25
|
@http_status_code = http_response_code
|
27
|
-
@
|
28
|
-
|
26
|
+
@http_raw_response = http_raw_response
|
27
|
+
|
28
|
+
# only set these variables if a message-body is expected.
|
29
|
+
if not @http_raw_response.kind_of? Net::HTTPNoContent
|
30
|
+
@body = MultiJson.load(http_response) unless http_response.nil?
|
31
|
+
@request = MultiJson.load(@body["request"].to_s) if @body["request"]
|
32
|
+
@api_status = @body["status"].to_i if @body["status"]
|
33
|
+
@api_error_message = @body["error_message"].to_s if @body["error_message"]
|
34
|
+
end
|
29
35
|
end
|
30
36
|
|
31
37
|
# Helper method returns true if and only if the response from the API call was
|
@@ -34,7 +40,14 @@ module Sift
|
|
34
40
|
# == Returns:
|
35
41
|
# true on success; false otherwise
|
36
42
|
def ok?
|
37
|
-
|
43
|
+
|
44
|
+
if @http_raw_response.kind_of? Net::HTTPNoContent
|
45
|
+
#if there is no content expected, use HTTP code
|
46
|
+
204 == @http_status_code
|
47
|
+
else
|
48
|
+
# otherwise use API status
|
49
|
+
@http_raw_response.kind_of? Net::HTTPOK and 0 == @api_status.to_i
|
50
|
+
end
|
38
51
|
end
|
39
52
|
|
40
53
|
|
@@ -70,8 +83,8 @@ module Sift
|
|
70
83
|
# The path to the event API, e.g., "/v201/events"
|
71
84
|
#
|
72
85
|
def initialize(api_key = Sift.api_key, path = Sift.current_rest_api_path, timeout = API_TIMEOUT)
|
73
|
-
raise(
|
74
|
-
raise(
|
86
|
+
raise("api_key must be a non-empty string") if !api_key.is_a?(String) || api_key.empty?
|
87
|
+
raise("path must be a non-empty string") if !path.is_a?(String) || path.empty?
|
75
88
|
@api_key = api_key
|
76
89
|
@path = path
|
77
90
|
@timeout = timeout
|
@@ -118,9 +131,9 @@ module Sift
|
|
118
131
|
# result, though.
|
119
132
|
#
|
120
133
|
def track(event, properties = {}, timeout = nil, path = nil, return_score = false, api_key = @api_key)
|
121
|
-
raise(
|
122
|
-
raise(
|
123
|
-
raise(
|
134
|
+
raise("event must be a non-empty string") if (!event.is_a? String) || event.empty?
|
135
|
+
raise("properties cannot be empty") if properties.empty?
|
136
|
+
raise("Bad api_key parameter") if api_key.empty?
|
124
137
|
path ||= @path
|
125
138
|
timeout ||= @timeout
|
126
139
|
if return_score
|
@@ -134,7 +147,7 @@ module Sift
|
|
134
147
|
options.merge!(:timeout => timeout) unless timeout.nil?
|
135
148
|
begin
|
136
149
|
response = self.class.post(path, options)
|
137
|
-
Response.new(response.body, response.code)
|
150
|
+
Response.new(response.body, response.headers, response.code, response.response)
|
138
151
|
rescue StandardError => e
|
139
152
|
Sift.warn("Failed to track event: " + e.to_s)
|
140
153
|
Sift.warn(e.backtrace)
|
@@ -156,15 +169,15 @@ module Sift
|
|
156
169
|
#
|
157
170
|
def score(user_id, timeout = nil, api_key = @api_key)
|
158
171
|
|
159
|
-
raise(
|
160
|
-
raise(
|
172
|
+
raise("user_id must be a non-empty string") if (!user_id.is_a? String) || user_id.to_s.empty?
|
173
|
+
raise("Bad api_key parameter") if api_key.empty?
|
161
174
|
timetout ||= @timeout
|
162
175
|
|
163
176
|
options = { :headers => {"User-Agent" => user_agent} }
|
164
177
|
options.merge!(:timeout => timeout) unless timeout.nil?
|
165
178
|
|
166
179
|
response = self.class.get("/v#{API_VERSION}/score/#{user_id}/?api_key=#{api_key}", options)
|
167
|
-
Response.new(response.body, response.code)
|
180
|
+
Response.new(response.body, response.headers, response.code, response.response)
|
168
181
|
|
169
182
|
end
|
170
183
|
|
@@ -189,12 +202,38 @@ module Sift
|
|
189
202
|
#
|
190
203
|
def label(user_id, properties = {}, timeout = nil, api_key = @api_key)
|
191
204
|
|
192
|
-
raise(
|
205
|
+
raise("user_id must be a non-empty string") if (!user_id.is_a? String) || user_id.to_s.empty?
|
193
206
|
|
194
207
|
path = Sift.current_users_label_api_path(user_id)
|
195
208
|
track("$label", delete_nils(properties), timeout, path, false, api_key)
|
196
209
|
end
|
197
210
|
|
211
|
+
# Unlabels a user. This call is blocking.
|
212
|
+
#
|
213
|
+
# == Parameters:
|
214
|
+
# user_id
|
215
|
+
# A user's id. This id should be the same as the user_id used in
|
216
|
+
# event calls.
|
217
|
+
#
|
218
|
+
# timeout (optional)
|
219
|
+
# The number of seconds to wait before failing the request. By default this is
|
220
|
+
# configured to 2 seconds (see above). This parameter is optional.
|
221
|
+
#
|
222
|
+
# == Returns:
|
223
|
+
# A Response object is returned with only an http code of 204.
|
224
|
+
#
|
225
|
+
def unlabel(user_id, timeout = nil)
|
226
|
+
|
227
|
+
raise("user_id must be a non-empty string") if (!user_id.is_a? String) || user_id.to_s.empty?
|
228
|
+
timetout ||= @timeout
|
229
|
+
|
230
|
+
options = { :headers => {"User-Agent" => user_agent} }
|
231
|
+
options.merge!(:timeout => timeout) unless timeout.nil?
|
232
|
+
path = Sift.current_users_label_api_path(user_id)
|
233
|
+
response = self.class.delete(path + "?api_key=#{@api_key}", options)
|
234
|
+
Response.new(response.body, response.headers, response.code, response.response)
|
235
|
+
end
|
236
|
+
|
198
237
|
private
|
199
238
|
def delete_nils(properties)
|
200
239
|
properties.delete_if do |k, v|
|
data/lib/sift/version.rb
CHANGED
@@ -21,15 +21,29 @@ describe Sift::Client do
|
|
21
21
|
|
22
22
|
stub_request(:post, "https://api.siftscience.com/v203/users/frodo_baggins/labels").
|
23
23
|
with(:body => '{"$reasons":["$fake"],"$is_bad":true,"$description":"Listed a fake item","$type":"$label","$api_key":"foobar"}').
|
24
|
-
to_return(:body => MultiJson.dump(response_json), :status => 200, :
|
24
|
+
to_return(:body => MultiJson.dump(response_json), :status => 200, :headers =>
|
25
|
+
{"content-type"=>"application/json; charset=UTF-8","content-length"=> "74"})
|
25
26
|
|
26
27
|
api_key = "foobar"
|
27
28
|
properties = valid_label_properties
|
28
29
|
|
29
30
|
response = Sift::Client.new(api_key).label(user_id, properties)
|
30
|
-
response.ok
|
31
|
-
response.api_status.
|
32
|
-
response.api_error_message.
|
31
|
+
expect(response.ok?).to eq(true)
|
32
|
+
expect(response.api_status).to eq(0)
|
33
|
+
expect(response.api_error_message).to eq("OK")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "Successfully handles an $unlabel with the v203 API endpoing and returns OK" do
|
37
|
+
response_json = { :status => 0, :error_message => "OK" }
|
38
|
+
user_id = "frodo_baggins"
|
39
|
+
|
40
|
+
stub_request(:delete, "https://api.siftscience.com/v203/users/frodo_baggins/labels?api_key=foobar").
|
41
|
+
to_return(:status => 204)
|
42
|
+
|
43
|
+
api_key = "foobar"
|
44
|
+
|
45
|
+
response = Sift::Client.new(api_key).unlabel(user_id)
|
46
|
+
expect(response.ok?).to eq(true)
|
33
47
|
end
|
34
48
|
|
35
49
|
end
|
data/spec/unit/client_spec.rb
CHANGED
@@ -48,51 +48,51 @@ describe Sift::Client do
|
|
48
48
|
|
49
49
|
it "Can instantiate client with blank api key if Sift.api_key set" do
|
50
50
|
Sift.api_key = "test_global_api_key"
|
51
|
-
Sift::Client.new().api_key.
|
51
|
+
expect(Sift::Client.new().api_key).to eq(Sift.api_key)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "Parameter passed api key takes precedence over Sift.api_key" do
|
55
55
|
Sift.api_key = "test_global_api_key"
|
56
56
|
api_key = "test_local_api_key"
|
57
|
-
Sift::Client.new(api_key).api_key.
|
57
|
+
expect(Sift::Client.new(api_key).api_key).to eq(api_key)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "Cannot instantiate client with nil, empty, non-string, or blank api key" do
|
61
|
-
lambda { Sift::Client.new(nil) }.
|
62
|
-
lambda { Sift::Client.new("") }.
|
63
|
-
lambda { Sift::Client.new(123456) }.
|
64
|
-
lambda { Sift::Client.new() }.
|
61
|
+
expect(lambda { Sift::Client.new(nil) }).to raise_error
|
62
|
+
expect(lambda { Sift::Client.new("") }).to raise_error
|
63
|
+
expect(lambda { Sift::Client.new(123456) }).to raise_error
|
64
|
+
expect(lambda { Sift::Client.new() }).to raise_error
|
65
65
|
end
|
66
66
|
|
67
67
|
it "Cannot instantiate client with nil, empty, non-string, or blank path" do
|
68
68
|
api_key = "test_local_api_key"
|
69
|
-
lambda { Sift::Client.new(api_key, nil) }.
|
70
|
-
lambda { Sift::Client.new(api_key, "") }.
|
71
|
-
lambda { Sift::Client.new(api_key, 123456) }.
|
69
|
+
expect(lambda { Sift::Client.new(api_key, nil) }).to raise_error
|
70
|
+
expect(lambda { Sift::Client.new(api_key, "") }).to raise_error
|
71
|
+
expect(lambda { Sift::Client.new(api_key, 123456) }).to raise_error
|
72
72
|
end
|
73
73
|
|
74
74
|
it "Can instantiate client with non-default timeout" do
|
75
|
-
lambda { Sift::Client.new("test_local_api_key", Sift.current_rest_api_path, 4) }.
|
75
|
+
expect(lambda { Sift::Client.new("test_local_api_key", Sift.current_rest_api_path, 4) }).not_to raise_error
|
76
76
|
end
|
77
77
|
|
78
78
|
it "Track call must specify an event name" do
|
79
|
-
lambda { Sift::Client.new("foo").track(nil) }.
|
80
|
-
lambda { Sift::Client.new("foo").track("") }.
|
79
|
+
expect(lambda { Sift::Client.new("foo").track(nil) }).to raise_error
|
80
|
+
expect(lambda { Sift::Client.new("foo").track("") }).to raise_error
|
81
81
|
end
|
82
82
|
|
83
83
|
it "Must specify an event name" do
|
84
|
-
lambda { Sift::Client.new("foo").track(nil) }.
|
85
|
-
lambda { Sift::Client.new("foo").track("") }.
|
84
|
+
expect(lambda { Sift::Client.new("foo").track(nil) }).to raise_error
|
85
|
+
expect(lambda { Sift::Client.new("foo").track("") }).to raise_error
|
86
86
|
end
|
87
87
|
|
88
88
|
it "Must specify properties" do
|
89
89
|
event = "custom_event_name"
|
90
|
-
lambda { Sift::Client.new("foo").track(event) }.
|
90
|
+
expect(lambda { Sift::Client.new("foo").track(event) }).to raise_error
|
91
91
|
end
|
92
92
|
|
93
93
|
it "Score call must specify a user_id" do
|
94
|
-
lambda { Sift::Client.new("foo").score(nil) }.
|
95
|
-
lambda { Sift::Client.new("foo").score("") }.
|
94
|
+
expect(lambda { Sift::Client.new("foo").score(nil) }).to raise_error
|
95
|
+
expect(lambda { Sift::Client.new("foo").score("") }).to raise_error
|
96
96
|
end
|
97
97
|
|
98
98
|
it "Doesn't raise an exception on Net/HTTP errors" do
|
@@ -105,7 +105,7 @@ describe Sift::Client do
|
|
105
105
|
|
106
106
|
# This method should just return nil -- the track call failed because
|
107
107
|
# of an HTTP error
|
108
|
-
Sift::Client.new(api_key).track(event, properties).
|
108
|
+
expect(Sift::Client.new(api_key).track(event, properties)).to eq(nil)
|
109
109
|
end
|
110
110
|
|
111
111
|
it "Returns nil when a StandardError occurs within the request" do
|
@@ -118,7 +118,7 @@ describe Sift::Client do
|
|
118
118
|
|
119
119
|
# This method should just return nil -- the track call failed because
|
120
120
|
# a StandardError exception was thrown
|
121
|
-
Sift::Client.new(api_key).track(event, properties).
|
121
|
+
expect(Sift::Client.new(api_key).track(event, properties)).to eq(nil)
|
122
122
|
end
|
123
123
|
|
124
124
|
it "Successfuly handles an event and returns OK" do
|
@@ -128,17 +128,17 @@ describe Sift::Client do
|
|
128
128
|
stub_request(:post, "https://api.siftscience.com/v203/events").
|
129
129
|
with { |request|
|
130
130
|
parsed_body = JSON.parse(request.body)
|
131
|
-
parsed_body.
|
132
|
-
}.to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {})
|
131
|
+
expect(parsed_body).to include("$buyer_user_id" => "123456")
|
132
|
+
}.to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {"content-type"=>"application/json; charset=UTF-8","content-length"=> "74"})
|
133
133
|
|
134
134
|
api_key = "foobar"
|
135
135
|
event = "$transaction"
|
136
136
|
properties = valid_transaction_properties
|
137
137
|
|
138
138
|
response = Sift::Client.new(api_key).track(event, properties)
|
139
|
-
response.ok
|
140
|
-
response.api_status.
|
141
|
-
response.api_error_message.
|
139
|
+
expect(response.ok?).to eq(true)
|
140
|
+
expect(response.api_status).to eq(0)
|
141
|
+
expect(response.api_error_message).to eq("OK")
|
142
142
|
end
|
143
143
|
|
144
144
|
it "Successfully submits event with overriden key" do
|
@@ -146,8 +146,8 @@ describe Sift::Client do
|
|
146
146
|
stub_request(:post, "https://api.siftscience.com/v203/events").
|
147
147
|
with { | request|
|
148
148
|
parsed_body = JSON.parse(request.body)
|
149
|
-
parsed_body.
|
150
|
-
parsed_body.
|
149
|
+
expect(parsed_body).to include("$buyer_user_id" => "123456")
|
150
|
+
expect(parsed_body).to include("$api_key" => "overridden")
|
151
151
|
}.to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {})
|
152
152
|
|
153
153
|
api_key = "foobar"
|
@@ -155,9 +155,9 @@ describe Sift::Client do
|
|
155
155
|
properties = valid_transaction_properties
|
156
156
|
|
157
157
|
response = Sift::Client.new(api_key).track(event, properties, nil, nil, false, "overridden")
|
158
|
-
response.ok
|
159
|
-
response.api_status.
|
160
|
-
response.api_error_message.
|
158
|
+
expect(response.ok?).to eq(true)
|
159
|
+
expect(response.api_status).to eq(0)
|
160
|
+
expect(response.api_error_message).to eq("OK")
|
161
161
|
end
|
162
162
|
|
163
163
|
it "Successfuly scrubs nils" do
|
@@ -167,9 +167,9 @@ describe Sift::Client do
|
|
167
167
|
stub_request(:post, "https://api.siftscience.com/v203/events").
|
168
168
|
with { |request|
|
169
169
|
parsed_body = JSON.parse(request.body)
|
170
|
-
parsed_body.
|
171
|
-
parsed_body.
|
172
|
-
}.to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {})
|
170
|
+
expect(parsed_body).not_to include("fake_property")
|
171
|
+
expect(parsed_body).to include("sub_object" => {"one" => "two"})
|
172
|
+
}.to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {"content-type"=>"application/json; charset=UTF-8","content-length"=> "74"})
|
173
173
|
|
174
174
|
api_key = "foobar"
|
175
175
|
event = "$transaction"
|
@@ -181,9 +181,9 @@ describe Sift::Client do
|
|
181
181
|
}
|
182
182
|
)
|
183
183
|
response = Sift::Client.new(api_key).track(event, properties)
|
184
|
-
response.ok
|
185
|
-
response.api_status.
|
186
|
-
response.api_error_message.
|
184
|
+
expect(response.ok?).to eq(true)
|
185
|
+
expect(response.api_status).to eq(0)
|
186
|
+
expect(response.api_error_message).to eq("OK")
|
187
187
|
end
|
188
188
|
|
189
189
|
it "Successfully fetches a score" do
|
@@ -192,14 +192,14 @@ describe Sift::Client do
|
|
192
192
|
response_json = score_response_json
|
193
193
|
|
194
194
|
stub_request(:get, "https://api.siftscience.com/v203/score/247019/?api_key=foobar").
|
195
|
-
to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {})
|
195
|
+
to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {"content-type"=>"application/json; charset=UTF-8","content-length"=> "74"})
|
196
196
|
|
197
197
|
response = Sift::Client.new(api_key).score(score_response_json[:user_id])
|
198
|
-
response.ok
|
199
|
-
response.api_status.
|
200
|
-
response.api_error_message.
|
198
|
+
expect(response.ok?).to eq(true)
|
199
|
+
expect(response.api_status).to eq(0)
|
200
|
+
expect(response.api_error_message).to eq("OK")
|
201
201
|
|
202
|
-
response.body["score"].
|
202
|
+
expect(response.body["score"]).to eq(0.93)
|
203
203
|
end
|
204
204
|
|
205
205
|
it "Successfully fetches a score with an overridden key" do
|
@@ -211,11 +211,11 @@ describe Sift::Client do
|
|
211
211
|
to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {})
|
212
212
|
|
213
213
|
response = Sift::Client.new(api_key).score(score_response_json[:user_id], nil, "overridden")
|
214
|
-
response.ok
|
215
|
-
response.api_status.
|
216
|
-
response.api_error_message.
|
214
|
+
expect(response.ok?).to eq(true)
|
215
|
+
expect(response.api_status).to eq(0)
|
216
|
+
expect(response.api_error_message).to eq("OK")
|
217
217
|
|
218
|
-
response.body["score"].
|
218
|
+
expect(response.body["score"]).to eq(0.93)
|
219
219
|
end
|
220
220
|
|
221
221
|
|
@@ -229,15 +229,15 @@ describe Sift::Client do
|
|
229
229
|
}
|
230
230
|
|
231
231
|
stub_request(:post, "https://api.siftscience.com/v203/events?return_score=true").
|
232
|
-
to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {})
|
232
|
+
to_return(:status => 200, :body => MultiJson.dump(response_json), :headers => {"content-type"=>"application/json; charset=UTF-8","content-length"=> "74"})
|
233
233
|
|
234
234
|
event = "$transaction"
|
235
235
|
properties = valid_transaction_properties
|
236
236
|
response = Sift::Client.new(api_key).track(event, properties, nil, nil, true)
|
237
|
-
response.ok
|
238
|
-
response.api_status.
|
239
|
-
response.api_error_message.
|
240
|
-
response.body["score_response"]["score"].
|
237
|
+
expect(response.ok?).to eq(true)
|
238
|
+
expect(response.api_status).to eq(0)
|
239
|
+
expect(response.api_error_message).to eq("OK")
|
240
|
+
expect(response.body["score_response"]["score"]).to eq(0.93)
|
241
241
|
end
|
242
242
|
|
243
243
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Sadaghiani
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project: sift
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.2.2
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Sift Science Ruby API Gem
|