questionpro_rails 0.0.4 → 0.0.5

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: a63a3d7bfda4183121f767e024576305417286f0
4
- data.tar.gz: 61b597f8b59322c37e25fd11191b35ac33faa20a
3
+ metadata.gz: ef961772ad89a7964a173d02cd4ca93a3853363c
4
+ data.tar.gz: bceb92de666f5666b19c84ebceaf16030f2a7715
5
5
  SHA512:
6
- metadata.gz: eedb498321bcfffbcd26015016afc98880f4d39c6b293a322d236debfe90123371a33c5eed26c679ce6d66a4eed51d8bb87987865188ab1bb2d67010e2c2a4ac
7
- data.tar.gz: 4cfbda04096486083a30b639643e3bd46f2181877793545cd0c3613ce6e3b09608b3ff617e6476535fd752e20bd80424f0bc030ee7b771618b71ddbff26d55f3
6
+ metadata.gz: 79eada3ac1f1262c992aff1256e793e1b3ca664d7b823123d93ab0bee8aa4bd3d2f7e6a58bc9d79b0243cfcdcf95099c8b88e7181f9a7a3c9fc45f2d62a37189
7
+ data.tar.gz: 0aca497dd1ba4ca0078cd1d56f675d7501a4e3b44d153c4b6d22cacebc9ab67a40929b6022a8fe91864abdae532340480eccbd4e7dab6a58d42632e3d9940490
@@ -1,4 +1,5 @@
1
1
  require "questionpro_rails/survey"
2
+ require "questionpro_rails/survey_response"
2
3
  require "questionpro_rails/survey_response_count"
3
4
 
4
5
  module QuestionproRails
@@ -7,10 +8,12 @@ module QuestionproRails
7
8
  format :json
8
9
  base_uri 'www.questionpro.com'
9
10
 
10
- attr_accessor :id, :result_mode, :start_date, :end_date, :starting_response_counter, :status
11
+ attr_accessor :id, :response_id,:result_mode, :start_date, :end_date, :starting_response_counter,
12
+ :status, :full_response, :success
11
13
 
12
- def initialize(id, result_mode = 0, start_date = nil, end_date = nil, starting_response_counter = nil)
14
+ def initialize(id, response_id = nil, result_mode = 0, start_date = nil, end_date = nil, starting_response_counter = nil)
13
15
  @id = id
16
+ @response_id = response_id
14
17
  @result_mode = result_mode
15
18
  @start_date = start_date
16
19
  @end_date = end_date
@@ -22,7 +25,7 @@ module QuestionproRails
22
25
  end
23
26
 
24
27
  def options
25
- {id: self.id, resultMode: self.result_mode, startDate: self.start_date,
28
+ {id: self.id, surveyID: self.id, responseID: self.response_id, resultMode: self.result_mode, startDate: self.start_date,
26
29
  endDate: self.end_date, startingResponseCounter: self.starting_response_counter}.compact.to_json
27
30
  end
28
31
 
@@ -30,11 +33,12 @@ module QuestionproRails
30
33
  url = ApiRequest.base_path("questionpro.survey.getAllSurveys")
31
34
  result = self.class.get(url, body: self.options)
32
35
 
33
- self.status = result['status']
34
- result = result['response']['surveys']
36
+ self.full_response = result
37
+ self.status = result['status']
35
38
 
36
39
  surveys = []
37
- result.each do |survey|
40
+ result_surveys = result['response']['surveys']
41
+ result_surveys.each do |survey|
38
42
  surveys.push(Survey.new(survey))
39
43
  end
40
44
 
@@ -45,20 +49,74 @@ module QuestionproRails
45
49
  url = ApiRequest.base_path("questionpro.survey.getSurvey")
46
50
  result = self.class.get(url, body: self.options)
47
51
 
52
+ self.full_response = result
48
53
  self.status = result['status']
49
- survey = Survey.new(result['response'])
54
+
55
+ survey = Survey.new(result['response'])
50
56
 
51
57
  return survey
52
58
  end
53
59
 
60
+ def delete_survey
61
+ url = ApiRequest.base_path("questionpro.survey.deleteSurvey")
62
+ result = self.class.get(url, body: self.options)
63
+
64
+ self.full_response = result
65
+ self.status = result['status']
66
+ self.success = result['response']['success']
67
+
68
+ return self
69
+ end
70
+
71
+ def get_survey_responses
72
+ url = ApiRequest.base_path("questionpro.survey.surveyResponses")
73
+ result = self.class.get(url, body: self.options)
74
+
75
+ self.full_response = result
76
+ self.status = result['status']
77
+
78
+ survey_responses = []
79
+ result_responses = result['response']['responses']
80
+ result_responses.each do |response|
81
+ survey_responses.push(SurveyResponse.new(response))
82
+ end
83
+
84
+ return survey_responses
85
+ end
86
+
87
+ def get_survey_reponse
88
+ url = ApiRequest.base_path("questionpro.survey.surveyResponse")
89
+ result = self.class.get(url, body: self.options)
90
+
91
+ self.full_response = result
92
+ self.status = result['status']
93
+
94
+ response = SurveyResponse.new(result['response']['surveyResponse'])
95
+
96
+ return response
97
+ end
98
+
54
99
  def get_survey_response_count
55
100
  url = ApiRequest.base_path("questionpro.survey.responseCount")
56
101
  result = self.class.get(url, body: self.options)
57
102
 
103
+ self.full_response = result
58
104
  self.status = result['status']
105
+
59
106
  response_count = SurveyResponseCount.new(result['response'])
60
107
 
61
108
  return response_count
62
- end
109
+ end
110
+
111
+ def delete_response
112
+ url = ApiRequest.base_path("questionpro.survey.deleteResponse")
113
+ result = self.class.get(url, body: self.options)
114
+
115
+ self.full_response = result
116
+ self.status = result['status']
117
+ self.success = result['response']['success']
118
+
119
+ return self
120
+ end
63
121
  end
64
122
  end
@@ -0,0 +1,13 @@
1
+ module QuestionproRails
2
+ class ResponseAnswer
3
+
4
+ attr_reader :id, :answer_text, :value
5
+
6
+ def initialize (attributes)
7
+ @id = attributes['id']
8
+ @answer_text = attributes['answerText']
9
+ @value = attributes['value']
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ require "questionpro_rails/response_answer"
2
+
3
+ module QuestionproRails
4
+ class ResponseSet
5
+
6
+ attr_reader :question_code, :question_description, :question_id, :question_text, :qp_values
7
+
8
+ def initialize (attributes)
9
+ @question_code = attributes['questionCode']
10
+ @question_description = attributes['questionDescription']
11
+ @question_id = attributes['questionID']
12
+ @question_text = attributes['questionText']
13
+ @qp_values = attributes['values']
14
+ end
15
+
16
+ def answers
17
+ extracted_answers = []
18
+
19
+ if self.qp_values.any?
20
+ self.qp_values.each do |answer|
21
+ extracted_answers.push(ResponseAnswer.new(answer))
22
+ end
23
+ end
24
+
25
+ return extracted_answers
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,35 @@
1
+ require "questionpro_rails/response_set"
2
+
3
+ module QuestionproRails
4
+ class SurveyResponse
5
+
6
+ attr_reader :id, :country, :duplicate, :external_reference,
7
+ :ip_address, :region, :qp_response_set, :response_status,
8
+ :time_taken, :timestamp
9
+
10
+ def initialize (attributes)
11
+ @id = attributes['id']
12
+ @country = attributes['country']
13
+ @duplicate = attributes['duplicate']
14
+ @external_reference = attributes['externalReference']
15
+ @ip_address = attributes['ipAddress']
16
+ @region = attributes['region']
17
+ @qp_response_set = attributes['responseSet']
18
+ @response_status = attributes['responseStatus']
19
+ @time_taken = attributes['timeTaken']
20
+ @timestamp = attributes['timestamp']
21
+ end
22
+
23
+ def response_set
24
+ extracted_sets = []
25
+
26
+ if self.qp_response_set.any?
27
+ self.qp_response_set.each do |set|
28
+ extracted_sets.push(ResponseSet.new(set))
29
+ end
30
+ end
31
+
32
+ return extracted_sets
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module QuestionproRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: questionpro_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Assem Deghady
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-26 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,8 +78,11 @@ files:
78
78
  - lib/questionpro_rails/choice.rb
79
79
  - lib/questionpro_rails/configuration.rb
80
80
  - lib/questionpro_rails/question.rb
81
+ - lib/questionpro_rails/response_answer.rb
82
+ - lib/questionpro_rails/response_set.rb
81
83
  - lib/questionpro_rails/section.rb
82
84
  - lib/questionpro_rails/survey.rb
85
+ - lib/questionpro_rails/survey_response.rb
83
86
  - lib/questionpro_rails/survey_response_count.rb
84
87
  - lib/questionpro_rails/version.rb
85
88
  homepage: https://github.com/AssemDeghady/questionpro_rails