electric_profile_ruby 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7520e1512d18763ac1c4a6e1693ef9c51b020bd
4
- data.tar.gz: 37dacdc7c02edb31aef5813c5ae9fc48389abee7
3
+ metadata.gz: f105b2d965b73405c00dfda1f1a8a627713c686f
4
+ data.tar.gz: b02e57c4aade601ec746718303c013b092450820
5
5
  SHA512:
6
- metadata.gz: 447b0b0253f74816f18c7c13df43bc0173296b5a6b5e476ff8e10b9e1be0b21b4f2848812aad8dc707c983ee7350861565b84c96b83adf41ffb821387d0b7cd5
7
- data.tar.gz: 3ecdcedbb87a6fec5b2a8f1a90df15d3c7b9575fa14db0ef149214b61431efc5a73cea0645a9cdffc7a9c5ce252a7c04b58e441c99b3d912c4eec34ceb5ef23e
6
+ metadata.gz: d168ac93f3f4d84ebc46b0be6032d1091a6383be4c5138d3334a03aabf7dcbbca929a495a27007d45151bd0af9cdeef0f463c85868c7d65d4f44bfe18fe96db2
7
+ data.tar.gz: 41f5d74a716901079e2192e82ca6a22ab8234bf171db14f7c2eaf92644234c73dca810de67afcfb48ada8ca0e38e6e1ee74ca9a2057aec4a382ab97231949af5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- electric_profile_ruby (1.2.0)
4
+ electric_profile_ruby (1.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -71,6 +71,14 @@ module ElectricProfile
71
71
  perform_request(uri, http_request)
72
72
  end
73
73
 
74
+ def fetch_respondent_profiler(profiler_id, user_id, locale)
75
+ raise ArgumentError, 'Survey token is required' unless survey_token = ENV['ELECTRIC_PROFILE_SURVEY_TOKEN']
76
+ @http_headers['Profiling-Auth-Token'] = survey_token
77
+ uri = URI("#{@api_url}respondentProfiler?profilerId=#{profiler_id}&userId=#{user_id}&locale=#{locale}")
78
+ http_request = Net::HTTP::Get.new uri, @http_headers
79
+ perform_request(uri, http_request)
80
+ end
81
+
74
82
  private
75
83
  def perform_request(uri, http_request)
76
84
  use_ssl = @api_url.include? "https"
@@ -1,7 +1,7 @@
1
1
  module ElectricProfile
2
2
 
3
3
  class Question
4
- attr_accessor :id, :customerId, :name, :prompt, :type, :answerOptions, :answerOptionOrder, :allowMultiple, :categories, :error, :exclusiveAnswerOptions, :regExValidation, :regExValidationMessage
4
+ attr_accessor :id, :customerId, :name, :prompt, :type, :answerOptions, :answerOptionOrder, :allowMultiple, :categories, :error, :exclusiveAnswerOptions, :regExValidation, :regExValidationMessage, :baseLogic, :derived, :derivationLogic
5
5
  TYPES = ['multi_choice', 'number', 'short_text', 'long_text']
6
6
 
7
7
  def initialize(atts)
@@ -18,6 +18,9 @@ module ElectricProfile
18
18
  @answerOptionOrder = atts[:answerOptionOrder]
19
19
  @regExValidation = atts[:regExValidation]
20
20
  @regExValidationMessage = atts[:regExValidationMessage]
21
+ @baseLogic = atts[:baseLogic]
22
+ @derived = atts[:derived] || false
23
+ @derivationLogic = atts[:derivationLogic] || []
21
24
  end
22
25
 
23
26
  def save
@@ -40,7 +43,10 @@ module ElectricProfile
40
43
  exclusiveAnswerOptions: @exclusiveAnswerOptions,
41
44
  answerOptionOrder: @answerOptionOrder,
42
45
  regExValidation: @regExValidation,
43
- regExValidationMessage: @regExValidationMessage
46
+ regExValidationMessage: @regExValidationMessage,
47
+ baseLogic: @baseLogic,
48
+ derived: @derived,
49
+ derivationLogic: @derivationLogic
44
50
  }
45
51
  if @client.create_question(attributes)
46
52
  @id = @client.data["id"]
@@ -66,7 +72,10 @@ module ElectricProfile
66
72
  exclusiveAnswerOptions: @exclusiveAnswerOptions,
67
73
  answerOptionOrder: @answerOptionOrder,
68
74
  regExValidation: @regExValidation,
69
- regExValidationMessage: @regExValidationMessage
75
+ regExValidationMessage: @regExValidationMessage,
76
+ baseLogic: @baseLogic,
77
+ derived: @derived,
78
+ derivationLogic: @derivationLogic
70
79
  }
71
80
  if @client.update_question(attributes)
72
81
  true
@@ -0,0 +1,31 @@
1
+ module ElectricProfile
2
+
3
+ class RespondentProfiler
4
+ attr_accessor :questions, :profiler
5
+
6
+ def initialize(atts)
7
+ atts = atts.inject({}){ |memo, (k, v) | memo[k.to_sym] = v; memo }
8
+ @questions = atts[:questions]
9
+ @profiler = atts[:profiler]
10
+ end
11
+
12
+ def save
13
+ if @id
14
+ save_existing
15
+ else
16
+ save_new
17
+ end
18
+ end
19
+
20
+ def self.find(profiler_id, user_id, locale)
21
+ client = Client.new
22
+ if client.fetch_respondent_profiler(profiler_id, user_id, locale)
23
+ new client.data
24
+ else
25
+ raise StandardError, client.error
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -1,3 +1,3 @@
1
1
  module ElectricProfile
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -2,7 +2,7 @@ require "electric_profile_ruby/version"
2
2
  require "electric_profile_ruby/client"
3
3
  require "electric_profile_ruby/question"
4
4
  require "electric_profile_ruby/profiler"
5
+ require "electric_profile_ruby/respondent_profiler"
5
6
 
6
7
  module ElectricProfile
7
- # Your code goes here...
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: electric_profile_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Alston
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-19 00:00:00.000000000 Z
11
+ date: 2018-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,7 @@ files:
103
103
  - lib/electric_profile_ruby/client.rb
104
104
  - lib/electric_profile_ruby/profiler.rb
105
105
  - lib/electric_profile_ruby/question.rb
106
+ - lib/electric_profile_ruby/respondent_profiler.rb
106
107
  - lib/electric_profile_ruby/version.rb
107
108
  homepage: http://www.bovitzinc.com
108
109
  licenses: