crowdskout 0.0.13 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/crowdskout.gemspec +1 -1
- data/lib/crowdskout/api.rb +3 -0
- data/lib/crowdskout/components/quartermaster/tracking_code.rb +24 -8
- data/lib/crowdskout/services/profile_service.rb +18 -0
- data/lib/crowdskout/util/config.rb +3 -1
- data/lib/crowdskout/version.rb +1 -1
- data/spec/crowdskout/components/quartermaster/tracking_code_spec.rb +24 -8
- data/spec/crowdskout/services/profile_service_spec.rb +26 -0
- data/spec/crowdskout/services/quartermaster_service_spec.rb +25 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50833641606d1c130260e26597621d67419eeb39
|
4
|
+
data.tar.gz: 884d05d051fbfdd89aabf3819b31541489725d06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c6f6487e9faa10114a68630b515c671088e93a3d3c707bd243104f297961c67fb7befd60d9a7647e9c50036d147aa3ae7c5626921c50c1263570581c79bda08
|
7
|
+
data.tar.gz: b41ced3f90a49cb0b9260887c81f3c9311ee45717686d4f18da2a149fe9028dd83880ce21adc07cc1cc331931dc9cffd1212f27e84b4a83f6e1c7f9f5a1cda7c
|
data/crowdskout.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "crowdskout"
|
8
|
-
s.version = '0.0.
|
8
|
+
s.version = '0.0.19'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ["Crowdskout", "Revv","Kyle Schutt"]
|
11
11
|
s.homepage = "https://github.com/revvco/crowdskout"
|
data/lib/crowdskout/api.rb
CHANGED
@@ -37,6 +37,9 @@ module Crowdskout
|
|
37
37
|
def update_profiles_bulk(profiles)
|
38
38
|
Services::ProfileService.update_profiles_bulk(profiles)
|
39
39
|
end
|
40
|
+
def check_for_non_match(profile)
|
41
|
+
Services::ProfileService.check_for_non_match(profile)
|
42
|
+
end
|
40
43
|
|
41
44
|
# Fields Service Methods
|
42
45
|
def get_options_for_a_field(field_name, params = {})
|
@@ -26,15 +26,31 @@ module Crowdskout
|
|
26
26
|
# @return [String] javascript function with the tracking information
|
27
27
|
def tracking_code_source
|
28
28
|
if !source.nil? && !organization.nil? && !client.nil?
|
29
|
-
%{
|
29
|
+
%{
|
30
|
+
<!-- Crowdskout -->
|
30
31
|
<script>
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
(function(s,k,o,u,t){
|
33
|
+
s.cs=s.cs||function(){cs.q.push(arguments);};
|
34
|
+
cs.q=cs.q||[];cs.apiUrl=t;
|
35
|
+
s.sourceId = #{source};s.clientId = #{client};s.organizationId = #{organization};
|
36
|
+
var a=k.getElementsByTagName(o)[0];var b=k.createElement(o);b.src=u+'/analytics.js';
|
37
|
+
b.onreadystatechange = b.onload = function() {
|
38
|
+
if ((!b.readyState || /loaded|complete/.test(b.readyState))) {
|
39
|
+
s._csCalledBackup = s._csCalled;
|
40
|
+
s._csCalled = function(type, body) {
|
41
|
+
if (type === 'page-view') {
|
42
|
+
s.cspageviewuuid = body.uuid;
|
43
|
+
}
|
44
|
+
if (s._csCalledBackup) {
|
45
|
+
s._csCalledBackup(type, body);
|
46
|
+
}
|
47
|
+
};
|
48
|
+
}
|
49
|
+
};
|
50
|
+
a.parentNode.insertBefore(b,a);
|
51
|
+
})(window,document,'script','//s.crowdskout.com','https://a.crowdskout.com');
|
52
|
+
</script>
|
53
|
+
}
|
38
54
|
else
|
39
55
|
%{
|
40
56
|
Tracking Codes Error
|
@@ -103,6 +103,24 @@ module Crowdskout
|
|
103
103
|
|
104
104
|
Components::ResultSet.new(profiles, body['messages'])
|
105
105
|
end
|
106
|
+
|
107
|
+
# more info - https://docs.crowdskout.com/api/#check-for-a-non-match
|
108
|
+
#
|
109
|
+
# Check for a non-match. The endpoints returns true if the given Profile object is definitely NOT a match.
|
110
|
+
# That means that the ID given in the Profile object does not match the Profile data.
|
111
|
+
#
|
112
|
+
# @param [Profile] profile - profile to check for non-match
|
113
|
+
# @return [boolean] - returns true if it is a non-match, false in all other scenarios
|
114
|
+
def check_for_non_match(profile)
|
115
|
+
raise Exceptions::ServiceException, "Profile object must not be nil." if profile.nil?
|
116
|
+
url = Util::Config.get('endpoints.base_url') + sprintf(Util::Config.get('endpoints.check_for_non_match'), profile.id)
|
117
|
+
url = build_url(url)
|
118
|
+
payload = {
|
119
|
+
profile: profile.to_hash
|
120
|
+
}.to_json
|
121
|
+
response = RestClient.post(url, payload, get_headers())
|
122
|
+
JSON.parse(response.body)["data"]
|
123
|
+
end
|
106
124
|
end
|
107
125
|
end
|
108
126
|
end
|
@@ -25,7 +25,9 @@ module Crowdskout
|
|
25
25
|
:attribute => 'attribute',
|
26
26
|
:crud_attribute => 'attribute/%s',
|
27
27
|
|
28
|
-
:tracking => 'tracking'
|
28
|
+
:tracking => 'tracking',
|
29
|
+
|
30
|
+
:check_for_non_match => 'profile/%s/non-match-check'
|
29
31
|
},
|
30
32
|
|
31
33
|
# OAuth2 Authorization related configuration options
|
data/lib/crowdskout/version.rb
CHANGED
@@ -22,15 +22,31 @@ describe Crowdskout::Components::TrackingCode do
|
|
22
22
|
expect(component.organization).to eq 2
|
23
23
|
expect(component.client).to eq 3
|
24
24
|
|
25
|
-
expect(component.tracking_code_source.gsub(/\s+/, " ")).to eq
|
25
|
+
expect(component.tracking_code_source.gsub(/\s+/, " ")).to eq %{
|
26
|
+
<!-- Crowdskout -->
|
26
27
|
<script>
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
(function(s,k,o,u,t){
|
29
|
+
s.cs=s.cs||function(){cs.q.push(arguments);};
|
30
|
+
cs.q=cs.q||[];cs.apiUrl=t;
|
31
|
+
s.sourceId = #{component.source};s.clientId = #{component.client};s.organizationId = #{component.organization};
|
32
|
+
var a=k.getElementsByTagName(o)[0];var b=k.createElement(o);b.src=u+'/analytics.js';
|
33
|
+
b.onreadystatechange = b.onload = function() {
|
34
|
+
if ((!b.readyState || /loaded|complete/.test(b.readyState))) {
|
35
|
+
s._csCalledBackup = s._csCalled;
|
36
|
+
s._csCalled = function(type, body) {
|
37
|
+
if (type === 'page-view') {
|
38
|
+
s.cspageviewuuid = body.uuid;
|
39
|
+
}
|
40
|
+
if (s._csCalledBackup) {
|
41
|
+
s._csCalledBackup(type, body);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
}
|
45
|
+
};
|
46
|
+
a.parentNode.insertBefore(b,a);
|
47
|
+
})(window,document,'script','//s.crowdskout.com','https://a.crowdskout.com');
|
48
|
+
</script>
|
49
|
+
}.gsub(/\s+/, " ")
|
34
50
|
end
|
35
51
|
it "generates the correct json object" do
|
36
52
|
component = Crowdskout::Components::TrackingCode.create(@hash)
|
@@ -141,4 +141,30 @@ describe Crowdskout::Services::ProfileService do
|
|
141
141
|
profile.collections[0].items[0].fields[0].value.value.should eq "Male"
|
142
142
|
end
|
143
143
|
end
|
144
|
+
|
145
|
+
describe "#check_for_non_match" do
|
146
|
+
it "is a non-match" do
|
147
|
+
json = load_file('check_for_non_match_true_response.json')
|
148
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
149
|
+
|
150
|
+
response = RestClient::Response.create(json, net_http_resp, {}, @request)
|
151
|
+
RestClient.stub(:post).and_return(response)
|
152
|
+
profile = Crowdskout::Components::Profile.create(JSON.parse(load_file('profile_response.json'))["data"])
|
153
|
+
non_match_response = Crowdskout::Services::ProfileService.check_for_non_match(profile)
|
154
|
+
|
155
|
+
non_match_response.should eq true
|
156
|
+
end
|
157
|
+
|
158
|
+
it "is a not non-match" do
|
159
|
+
json = load_file('check_for_non_match_false_response.json')
|
160
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
|
161
|
+
|
162
|
+
response = RestClient::Response.create(json, net_http_resp, {}, @request)
|
163
|
+
RestClient.stub(:post).and_return(response)
|
164
|
+
profile = Crowdskout::Components::Profile.create(JSON.parse(load_file('profile_response.json'))["data"])
|
165
|
+
non_match_response = Crowdskout::Services::ProfileService.check_for_non_match(profile)
|
166
|
+
|
167
|
+
non_match_response.should eq false
|
168
|
+
end
|
169
|
+
end
|
144
170
|
end
|
@@ -26,15 +26,31 @@ describe Crowdskout::Services::QuartermasterService do
|
|
26
26
|
expect(tracking_code.organization).to eq 2
|
27
27
|
expect(tracking_code.client).to eq 3
|
28
28
|
|
29
|
-
expect(tracking_code.tracking_code_source.gsub(/\s+/, " ")).to eq
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
expect(tracking_code.tracking_code_source.gsub(/\s+/, " ")).to eq %{
|
30
|
+
<!-- Crowdskout -->
|
31
|
+
<script>
|
32
|
+
(function(s,k,o,u,t){
|
33
|
+
s.cs=s.cs||function(){cs.q.push(arguments);};
|
34
|
+
cs.q=cs.q||[];cs.apiUrl=t;
|
35
|
+
s.sourceId = #{tracking_code.source};s.clientId = #{tracking_code.client};s.organizationId = #{tracking_code.organization};
|
36
|
+
var a=k.getElementsByTagName(o)[0];var b=k.createElement(o);b.src=u+'/analytics.js';
|
37
|
+
b.onreadystatechange = b.onload = function() {
|
38
|
+
if ((!b.readyState || /loaded|complete/.test(b.readyState))) {
|
39
|
+
s._csCalledBackup = s._csCalled;
|
40
|
+
s._csCalled = function(type, body) {
|
41
|
+
if (type === 'page-view') {
|
42
|
+
s.cspageviewuuid = body.uuid;
|
43
|
+
}
|
44
|
+
if (s._csCalledBackup) {
|
45
|
+
s._csCalledBackup(type, body);
|
46
|
+
}
|
47
|
+
};
|
48
|
+
}
|
49
|
+
};
|
50
|
+
a.parentNode.insertBefore(b,a);
|
51
|
+
})(window,document,'script','//s.crowdskout.com','https://a.crowdskout.com');
|
52
|
+
</script>
|
53
|
+
}.gsub(/\s+/, " ")
|
38
54
|
end
|
39
55
|
end
|
40
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowdskout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdskout
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-04-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|