crowdskout 0.0.13 → 0.0.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6363fe9476f202a228b63d1311d75c5fe11e222d
4
- data.tar.gz: 2787ea9671187ea9e3e6104fa337fba26d3be521
3
+ metadata.gz: 50833641606d1c130260e26597621d67419eeb39
4
+ data.tar.gz: 884d05d051fbfdd89aabf3819b31541489725d06
5
5
  SHA512:
6
- metadata.gz: 874cdb9476f9fafef6081eed9b3a41379cb33ba0ec82ab017f287f68b15b66d44cc23d1dc67f6f8469df138737be582e4c81167b6a7dd5255e2abf63c18806c0
7
- data.tar.gz: 0e56816bcbf1ffc4337d02c965e7248248e40c6c3d6183b702c212bda2a9dd9815936d607747818337d6c51b8a07219239359c2564888e1eb2c88cacc6e01301
6
+ metadata.gz: 5c6f6487e9faa10114a68630b515c671088e93a3d3c707bd243104f297961c67fb7befd60d9a7647e9c50036d147aa3ae7c5626921c50c1263570581c79bda08
7
+ data.tar.gz: b41ced3f90a49cb0b9260887c81f3c9311ee45717686d4f18da2a149fe9028dd83880ce21adc07cc1cc331931dc9cffd1212f27e84b4a83f6e1c7f9f5a1cda7c
@@ -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.13'
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"
@@ -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
- %{<!-- Crowdskout -->
29
+ %{
30
+ <!-- Crowdskout -->
30
31
  <script>
31
- (function(l,o,v,e,d) {
32
- l.cs=l.cs || function() {cs.q.push(arguments);};
33
- cs.q=cs.q||[];cs.apiUrl=d;cs('pageView');
34
- l.sourceId = #{source};l.clientId = #{client};l.organizationId = #{organization};
35
- var a=o.getElementsByTagName(v)[0];var b=o.createElement(v);b.src=e+'/analytics.js';a.parentNode.insertBefore(b,a);
36
- })(window, document, 'script', '//s.crowdskout.com','https://a.crowdskout.com');
37
- </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 = #{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
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Crowdskout
22
- VERSION = '0.0.12'
22
+ VERSION = '0.0.19'
23
23
  end
@@ -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 %{<!-- Crowdskout -->
25
+ expect(component.tracking_code_source.gsub(/\s+/, " ")).to eq %{
26
+ <!-- Crowdskout -->
26
27
  <script>
27
- (function(l,o,v,e,d) {
28
- l.cs=l.cs || function() {cs.q.push(arguments);};
29
- cs.q=cs.q||[];cs.apiUrl=d;cs('pageView');
30
- l.sourceId = #{component.source};l.clientId = #{component.client};l.organizationId = #{component.organization};
31
- var a=o.getElementsByTagName(v)[0];var b=o.createElement(v);b.src=e+'/analytics.js';a.parentNode.insertBefore(b,a);
32
- })(window, document, 'script', '//s.crowdskout.com','https://a.crowdskout.com');
33
- </script>}.gsub(/\s+/, " ")
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 %{<!-- Crowdskout -->
30
- <script>
31
- (function(l,o,v,e,d) {
32
- l.cs=l.cs || function() {cs.q.push(arguments);};
33
- cs.q=cs.q||[];cs.apiUrl=d;cs('pageView');
34
- l.sourceId = #{tracking_code.source};l.clientId = #{tracking_code.client};l.organizationId = #{tracking_code.organization};
35
- var a=o.getElementsByTagName(v)[0];var b=o.createElement(v);b.src=e+'/analytics.js';a.parentNode.insertBefore(b,a);
36
- })(window, document, 'script', '//s.crowdskout.com','https://a.crowdskout.com');
37
- </script>}.gsub(/\s+/, " ")
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.13
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: 2016-07-18 00:00:00.000000000 Z
13
+ date: 2017-04-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client