questionpro_rails 0.1.0 → 0.1.1
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 +4 -4
- data/lib/questionpro_rails/account.rb +6 -6
- data/lib/questionpro_rails/api_request.rb +119 -11
- data/lib/questionpro_rails/choice.rb +5 -5
- data/lib/questionpro_rails/configuration.rb +1 -0
- data/lib/questionpro_rails/email_batch.rb +9 -9
- data/lib/questionpro_rails/email_group.rb +1 -1
- data/lib/questionpro_rails/email_list.rb +22 -10
- data/lib/questionpro_rails/email_list_statistic.rb +4 -4
- data/lib/questionpro_rails/email_template.rb +3 -3
- data/lib/questionpro_rails/question.rb +11 -4
- data/lib/questionpro_rails/response_answer.rb +2 -2
- data/lib/questionpro_rails/response_set.rb +12 -5
- data/lib/questionpro_rails/section.rb +29 -21
- data/lib/questionpro_rails/survey.rb +15 -8
- data/lib/questionpro_rails/survey_meta.rb +14 -2
- data/lib/questionpro_rails/survey_response.rb +17 -10
- data/lib/questionpro_rails/survey_response_count.rb +10 -10
- data/lib/questionpro_rails/template.rb +1 -1
- data/lib/questionpro_rails/unsubscribed_email.rb +2 -2
- data/lib/questionpro_rails/version.rb +2 -1
- data/lib/questionpro_rails.rb +9 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd1ba206c0b432c652116dd0efada3b51cbcaacb
|
4
|
+
data.tar.gz: ef14a1dc5cfea420dfd8ac4c992045d140a8206f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79fe244e0d32a63f69d440c70921f3dc13bb2982272a3cb93f7dc3e314f6e67a731b0591a123c131bee6d2eb992999d4819d33f65456c1894e3ca4e9b4259679
|
7
|
+
data.tar.gz: aa8deba5ec504f730985e41f34eb2eca58856c49e42f6dbd3990f9ca9e788f0cd1d6e46f7cce469a0891e0dd1e56515b38af2e8609470874dbb6299eaa45c3da
|
@@ -5,13 +5,13 @@ module QuestionproRails
|
|
5
5
|
:account_type, :creation_date, :phone
|
6
6
|
|
7
7
|
def initialize (attributes)
|
8
|
-
@id
|
9
|
-
@first_name
|
10
|
-
@last_name
|
11
|
-
@last_login
|
8
|
+
@id = attributes['userID']
|
9
|
+
@first_name = attributes['firstName']
|
10
|
+
@last_name = attributes['lastName']
|
11
|
+
@last_login = attributes['lastLogin']
|
12
12
|
@email_address = attributes['emailAddress']
|
13
|
-
@phone
|
14
|
-
@account_type
|
13
|
+
@phone = attributes['phone']
|
14
|
+
@account_type = attributes['accountType']
|
15
15
|
@creation_date = attributes['creationDate']
|
16
16
|
end
|
17
17
|
end
|
@@ -18,22 +18,41 @@ module QuestionproRails
|
|
18
18
|
:success, :message, :user_id, :status, :full_response,
|
19
19
|
:starting_response_counter, :email_group_id, :template_id
|
20
20
|
|
21
|
+
# Initializes a new Api Request.
|
22
|
+
#
|
23
|
+
# @param survey_id [Integer]
|
24
|
+
# @param response_id [Integer]
|
25
|
+
# @param result_mode [Integer]
|
26
|
+
# @param start_date [String]
|
27
|
+
# @param end_date [String]
|
28
|
+
# @param starting_response_counter [Integer]
|
29
|
+
# @param email_group_id [Integer]
|
30
|
+
# @param template_id [Integer]
|
31
|
+
# @param user_id [Integer]
|
32
|
+
# @return [QuestionproRails::ApiRequest] Api Request object that is used to make the calls
|
21
33
|
def initialize(survey_id = nil, response_id = nil, result_mode = 0, start_date = nil, end_date = nil, starting_response_counter = nil, email_group_id = nil, template_id = nil, user_id = nil)
|
22
|
-
@survey_id
|
23
|
-
@response_id
|
24
|
-
@result_mode
|
25
|
-
@start_date
|
26
|
-
@end_date
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
34
|
+
@survey_id = survey_id
|
35
|
+
@response_id = response_id
|
36
|
+
@result_mode = result_mode
|
37
|
+
@start_date = start_date
|
38
|
+
@end_date = end_date
|
39
|
+
@email_group_id = email_group_id
|
40
|
+
@template_id = template_id
|
41
|
+
@user_id = user_id
|
42
|
+
@starting_response_counter = starting_response_counter
|
31
43
|
end
|
32
44
|
|
45
|
+
# Get the base url for api call.
|
46
|
+
#
|
47
|
+
# @param method_url [String] the api method url.
|
48
|
+
# @return [String] Url for Api Call.
|
33
49
|
def self.base_path(method_url)
|
34
50
|
"/a/api/#{method_url}?apiKey=#{QuestionproRails.api_key}"
|
35
51
|
end
|
36
52
|
|
53
|
+
# Transform the object to the acceptable json format by questionpro.
|
54
|
+
#
|
55
|
+
# @return [Json] options in the call request.
|
37
56
|
def options
|
38
57
|
{id: self.survey_id, surveyID: self.survey_id, responseID: self.response_id,
|
39
58
|
resultMode: self.result_mode, startDate: self.start_date, userID: self.user_id,
|
@@ -41,6 +60,9 @@ module QuestionproRails
|
|
41
60
|
emailGroupID: self.email_group_id, templateID: self.template_id}.compact.to_json
|
42
61
|
end
|
43
62
|
|
63
|
+
# Get all the surveys that belongs to the api key's owner.
|
64
|
+
#
|
65
|
+
# @return [Array<QuestionproRails::Survey>] Surveys.
|
44
66
|
def list_surveys
|
45
67
|
url = ApiRequest.base_path("questionpro.survey.getAllSurveys")
|
46
68
|
result = self.class.get(url, body: self.options)
|
@@ -57,6 +79,10 @@ module QuestionproRails
|
|
57
79
|
return surveys
|
58
80
|
end
|
59
81
|
|
82
|
+
# Get a specific survey.
|
83
|
+
# Survey ID must be set inside the api request object.
|
84
|
+
#
|
85
|
+
# @return [QuestionproRails::Survey] Survey.
|
60
86
|
def get_survey
|
61
87
|
url = ApiRequest.base_path("questionpro.survey.getSurvey")
|
62
88
|
result = self.class.get(url, body: self.options)
|
@@ -69,6 +95,10 @@ module QuestionproRails
|
|
69
95
|
return survey
|
70
96
|
end
|
71
97
|
|
98
|
+
# Delete a specific survey.
|
99
|
+
# Survey ID must be set inside the api request object.
|
100
|
+
#
|
101
|
+
# @return sets ApiRequest success attribute to 1.
|
72
102
|
def delete_survey
|
73
103
|
url = ApiRequest.base_path("questionpro.survey.deleteSurvey")
|
74
104
|
result = self.class.get(url, body: self.options)
|
@@ -80,6 +110,10 @@ module QuestionproRails
|
|
80
110
|
return self
|
81
111
|
end
|
82
112
|
|
113
|
+
# Get list of survey Responses.
|
114
|
+
# Survey ID must be set inside the api request object.
|
115
|
+
#
|
116
|
+
# @return [Array<QuestionproRails::SurveyResponse>] Survey Responses.
|
83
117
|
def get_survey_responses
|
84
118
|
url = ApiRequest.base_path("questionpro.survey.surveyResponses")
|
85
119
|
result = self.class.get(url, body: self.options)
|
@@ -96,6 +130,11 @@ module QuestionproRails
|
|
96
130
|
return survey_responses
|
97
131
|
end
|
98
132
|
|
133
|
+
# Get a specific survey Response.
|
134
|
+
# Survey ID must be set inside the api request object.
|
135
|
+
# Response ID must be set inside the api request object.
|
136
|
+
#
|
137
|
+
# @return [QuestionproRails::SurveyResponse] Survey Response.
|
99
138
|
def get_survey_reponse
|
100
139
|
url = ApiRequest.base_path("questionpro.survey.surveyResponse")
|
101
140
|
result = self.class.get(url, body: self.options)
|
@@ -108,6 +147,10 @@ module QuestionproRails
|
|
108
147
|
return response
|
109
148
|
end
|
110
149
|
|
150
|
+
# Get a specific survey Response Statistics.
|
151
|
+
# Survey ID must be set inside the api request object.
|
152
|
+
#
|
153
|
+
# @return [QuestionproRails::SurveyResponseCount] Survey Response Statistics.
|
111
154
|
def get_survey_response_count
|
112
155
|
url = ApiRequest.base_path("questionpro.survey.responseCount")
|
113
156
|
result = self.class.get(url, body: self.options)
|
@@ -120,6 +163,11 @@ module QuestionproRails
|
|
120
163
|
return response_count
|
121
164
|
end
|
122
165
|
|
166
|
+
# Delete a specific survey response.
|
167
|
+
# Survey ID must be set inside the api request object.
|
168
|
+
# Response ID must be set inside the api request object.
|
169
|
+
#
|
170
|
+
# @return sets ApiRequest success attribute to 1.
|
123
171
|
def delete_response
|
124
172
|
url = ApiRequest.base_path("questionpro.survey.deleteResponse")
|
125
173
|
result = self.class.get(url, body: self.options)
|
@@ -131,6 +179,10 @@ module QuestionproRails
|
|
131
179
|
return self
|
132
180
|
end
|
133
181
|
|
182
|
+
# Get Email Lists related to a specific survey.
|
183
|
+
# Survey ID must be set inside the api request object.
|
184
|
+
#
|
185
|
+
# @return [Array<QuestionproRails::EmailList>] Email Lists.
|
134
186
|
def get_email_lists
|
135
187
|
url = ApiRequest.base_path("questionpro.survey.getEmailLists")
|
136
188
|
result = self.class.get(url, body: self.options)
|
@@ -147,6 +199,10 @@ module QuestionproRails
|
|
147
199
|
return email_lists
|
148
200
|
end
|
149
201
|
|
202
|
+
# Get Specific Email List.
|
203
|
+
# Email Group ID must be set inside the api request object.
|
204
|
+
#
|
205
|
+
# @return [QuestionproRails::EmailList] Email List.
|
150
206
|
def get_email_list
|
151
207
|
url = ApiRequest.base_path("questionpro.survey.getEmailList")
|
152
208
|
result = self.class.get(url, body: self.options)
|
@@ -159,6 +215,10 @@ module QuestionproRails
|
|
159
215
|
return email_list
|
160
216
|
end
|
161
217
|
|
218
|
+
# Delete Specific Email List.
|
219
|
+
# Email Group ID must be set inside the api request object.
|
220
|
+
#
|
221
|
+
# @return sets ApiRequest success attribute to 1.
|
162
222
|
def delete_email_list
|
163
223
|
url = ApiRequest.base_path("questionpro.survey.deleteEmailList")
|
164
224
|
result = self.class.get(url, body: self.options)
|
@@ -170,6 +230,10 @@ module QuestionproRails
|
|
170
230
|
return self
|
171
231
|
end
|
172
232
|
|
233
|
+
# Get Templates related to a specific survey.
|
234
|
+
# Survey ID must be set inside the api request object.
|
235
|
+
#
|
236
|
+
# @return [Array<QuestionproRails::Template>] Templates.
|
173
237
|
def get_email_templates
|
174
238
|
url = ApiRequest.base_path("questionpro.survey.getEmailTemplates")
|
175
239
|
result = self.class.get(url, body: self.options)
|
@@ -186,6 +250,10 @@ module QuestionproRails
|
|
186
250
|
return email_templates
|
187
251
|
end
|
188
252
|
|
253
|
+
# Get Specific Template.
|
254
|
+
# Template ID must be set inside the api request object.
|
255
|
+
#
|
256
|
+
# @return [QuestionproRails::Template] Template.
|
189
257
|
def get_email_template
|
190
258
|
url = ApiRequest.base_path("questionpro.survey.getEmailTemplate")
|
191
259
|
result = self.class.get(url, body: self.options)
|
@@ -198,6 +266,10 @@ module QuestionproRails
|
|
198
266
|
return email_template
|
199
267
|
end
|
200
268
|
|
269
|
+
# Delete Specific Template.
|
270
|
+
# Template ID must be set inside the api request object.
|
271
|
+
#
|
272
|
+
# @return sets ApiRequest success attribute to 1.
|
201
273
|
def delete_email_template
|
202
274
|
url = ApiRequest.base_path("questionpro.survey.deleteEmailTemplate")
|
203
275
|
result = self.class.get(url, body: self.options)
|
@@ -209,6 +281,9 @@ module QuestionproRails
|
|
209
281
|
return self
|
210
282
|
end
|
211
283
|
|
284
|
+
# Get all the accounts that belongs to the api key's owner.
|
285
|
+
#
|
286
|
+
# @return [Array<QuestionproRails::Account>] Accounts.
|
212
287
|
def get_all_accounts
|
213
288
|
url = ApiRequest.base_path("questionpro.survey.getAllAccounts")
|
214
289
|
result = self.class.get(url, body: self.options)
|
@@ -225,6 +300,10 @@ module QuestionproRails
|
|
225
300
|
return accounts
|
226
301
|
end
|
227
302
|
|
303
|
+
# Get Specific Account.
|
304
|
+
# User ID must be set inside the api request object.
|
305
|
+
#
|
306
|
+
# @return [QuestionproRails::Account] Account.
|
228
307
|
def get_account
|
229
308
|
url = ApiRequest.base_path("questionpro.survey.getAccount")
|
230
309
|
result = self.class.get(url, body: self.options)
|
@@ -237,6 +316,9 @@ module QuestionproRails
|
|
237
316
|
return account
|
238
317
|
end
|
239
318
|
|
319
|
+
# Get Unsubscribed Emails related to the api key.
|
320
|
+
#
|
321
|
+
# @return [Array<QuestionproRails::UnsubscribedEmail>] Unsubscribed Emails.
|
240
322
|
def get_unsubscribers
|
241
323
|
url = ApiRequest.base_path("questionpro.survey.getUnsubscribedEmailAddresses")
|
242
324
|
result = self.class.get(url, body: self.options)
|
@@ -253,6 +335,9 @@ module QuestionproRails
|
|
253
335
|
return unsubscribers
|
254
336
|
end
|
255
337
|
|
338
|
+
# Survey ID must be set inside the api request object.
|
339
|
+
#
|
340
|
+
# @return [QuestionproRails::SurveyMeta] Survey meta.
|
256
341
|
def get_survey_meta
|
257
342
|
url = ApiRequest.base_path("questionpro.survey.sendSurveyMetaData")
|
258
343
|
result = self.class.get(url, body: self.options)
|
@@ -265,17 +350,28 @@ module QuestionproRails
|
|
265
350
|
return survey_meta
|
266
351
|
end
|
267
352
|
|
268
|
-
|
353
|
+
# Send Specific Survey.
|
354
|
+
# Survey ID must be set inside the api request object.
|
355
|
+
#
|
356
|
+
# @param [Integer] mode (1).
|
357
|
+
# @param [Array<String>] emails to send to (nil).
|
358
|
+
# @param [Integer] template_id of email (nil).
|
359
|
+
# @return sets ApiRequest message attribute to "Message successful.".
|
360
|
+
def send_survey(mode = 1, emails = nil, template_id = nil)
|
269
361
|
url = ApiRequest.base_path("questionpro.survey.sendSurvey")
|
270
362
|
result = self.class.get(url, body: {surveyID: self.survey_id, mode: mode,
|
271
363
|
emailGroupID: self.email_group_id, emails: emails,
|
272
|
-
templateID: self.template_id, template:
|
364
|
+
templateID: self.template_id, template: template_id}.compact.to_json)
|
273
365
|
|
274
366
|
self.full_response = result
|
275
367
|
self.status = result['status']
|
276
368
|
self.message = result['response']['result']
|
277
369
|
end
|
278
370
|
|
371
|
+
# Get Send History related to a specific survey.
|
372
|
+
# Survey ID must be set inside the api request object.
|
373
|
+
#
|
374
|
+
# @return [Array<QuestionproRails::EmailBatch>] Email Batches.
|
279
375
|
def get_send_history
|
280
376
|
url = ApiRequest.base_path("questionpro.survey.emailBatchStatistics")
|
281
377
|
result = self.class.get(url, body: self.options)
|
@@ -292,6 +388,12 @@ module QuestionproRails
|
|
292
388
|
return email_batches
|
293
389
|
end
|
294
390
|
|
391
|
+
# Send Reminders.
|
392
|
+
# Survey ID must be set inside the api request object.
|
393
|
+
# Email Group ID must be set inside the api request object.
|
394
|
+
# Template ID must be set inside the api request object.
|
395
|
+
#
|
396
|
+
# @return sets ApiRequest message attribute to "Message successful.".
|
295
397
|
def send_reminders
|
296
398
|
url = ApiRequest.base_path("questionpro.survey.sendReminder")
|
297
399
|
result = self.class.get(url, body: self.options)
|
@@ -301,6 +403,12 @@ module QuestionproRails
|
|
301
403
|
self.message = result['response']['result']
|
302
404
|
end
|
303
405
|
|
406
|
+
# Create Email List.
|
407
|
+
# Survey ID must be set inside the api request object.
|
408
|
+
#
|
409
|
+
# @param [Array<String>] emails ([]).
|
410
|
+
# @param [String] email_group_name (nil).
|
411
|
+
# @return sets ApiRequest email_group_id to the created email list id.
|
304
412
|
def create_email_list (emails = [], email_group_name = nil)
|
305
413
|
url = ApiRequest.base_path("questionpro.survey.createEmailGroup")
|
306
414
|
result = self.class.get(url, body: {id: self.survey_id, emails: emails,
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module QuestionproRails
|
2
2
|
class Choice
|
3
3
|
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :id, :text, :score, :is_default, :exclude_randomize
|
5
5
|
|
6
6
|
def initialize (attributes)
|
7
|
-
@id
|
8
|
-
@score
|
9
|
-
@is_default
|
7
|
+
@id = attributes['id']
|
8
|
+
@score = attributes['score']
|
9
|
+
@is_default = attributes['isDefault']
|
10
10
|
@exclude_randomize = attributes['excludeRandomize']
|
11
|
-
@text
|
11
|
+
@text = attributes['text']
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -5,16 +5,16 @@ module QuestionproRails
|
|
5
5
|
:batch_type, :participation_pending, :timestamp, :initial_sent, :status
|
6
6
|
|
7
7
|
def initialize (attributes)
|
8
|
-
@id
|
9
|
-
@email_group
|
10
|
-
@viewed
|
11
|
-
@completed
|
12
|
-
@participation_rate
|
13
|
-
@batch_type
|
8
|
+
@id = attributes['batchID']
|
9
|
+
@email_group = attributes['emailGroup']
|
10
|
+
@viewed = attributes['viewed']
|
11
|
+
@completed = attributes['completed']
|
12
|
+
@participation_rate = attributes['participationRate']
|
13
|
+
@batch_type = attributes['batchType']
|
14
14
|
@participation_pending = attributes['participationPending']
|
15
|
-
@timestamp
|
16
|
-
@initial_sent
|
17
|
-
@status
|
15
|
+
@timestamp = attributes['timestamp']
|
16
|
+
@initial_sent = attributes['initialSent']
|
17
|
+
@status = attributes['status']
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -3,22 +3,31 @@ require "questionpro_rails/email_list_statistic"
|
|
3
3
|
module QuestionproRails
|
4
4
|
class EmailList
|
5
5
|
|
6
|
-
attr_reader :survey_id, :name, :email_group_id,
|
6
|
+
attr_reader :survey_id, :name, :email_group_id,
|
7
7
|
:unsubscribed, :total, :active, :pendin_verification, :bounced
|
8
8
|
|
9
|
+
# @return [Array<String>] Emails.
|
10
|
+
attr_reader :qp_emails
|
11
|
+
|
12
|
+
# @return [Hash] Email list statistics.
|
13
|
+
attr_reader :qp_statistics
|
14
|
+
|
9
15
|
def initialize (attributes)
|
10
|
-
@survey_id
|
11
|
-
@email_group_id
|
12
|
-
@name
|
13
|
-
@qp_emails
|
14
|
-
@qp_statistics
|
15
|
-
@unsubscribed
|
16
|
-
@total
|
17
|
-
@active
|
16
|
+
@survey_id = attributes['surveyID']
|
17
|
+
@email_group_id = attributes['emailGroupID']
|
18
|
+
@name = attributes['name']
|
19
|
+
@qp_emails = attributes['email']
|
20
|
+
@qp_statistics = attributes['statistics']
|
21
|
+
@unsubscribed = attributes['unsubscribed']
|
22
|
+
@total = attributes['total']
|
23
|
+
@active = attributes['active']
|
18
24
|
@pendin_verification = attributes['pendinVerification']
|
19
|
-
@bounced
|
25
|
+
@bounced = attributes['bounced']
|
20
26
|
end
|
21
27
|
|
28
|
+
# Extract the email list statistics from qp_statistics attribute.
|
29
|
+
#
|
30
|
+
# @return [QuestionproRails::EmailListStatistic] Email List Statistics.
|
22
31
|
def statistics
|
23
32
|
extracted_statistics = []
|
24
33
|
|
@@ -29,6 +38,9 @@ module QuestionproRails
|
|
29
38
|
return extracted_statistics
|
30
39
|
end
|
31
40
|
|
41
|
+
# Extract and seperate emails from qp_emails.
|
42
|
+
#
|
43
|
+
# @return [Array<String>] Emails.
|
32
44
|
def emails
|
33
45
|
unless self.qp_emails.empty?
|
34
46
|
return self.qp_emails.split(',')
|
@@ -5,11 +5,11 @@ module QuestionproRails
|
|
5
5
|
:pendin_verification, :bounced
|
6
6
|
|
7
7
|
def initialize (attributes)
|
8
|
-
@unsubscribed
|
9
|
-
@total
|
10
|
-
@active
|
8
|
+
@unsubscribed = attributes['unsubscribed']
|
9
|
+
@total = attributes['total']
|
10
|
+
@active = attributes['active']
|
11
11
|
@pendin_verification = attributes['pendinVerification']
|
12
|
-
@bounced
|
12
|
+
@bounced = attributes['bounced']
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -4,9 +4,9 @@ module QuestionproRails
|
|
4
4
|
attr_reader :id, :survey_id, :title, :content_summary
|
5
5
|
|
6
6
|
def initialize (attributes)
|
7
|
-
@id
|
8
|
-
@survey_id
|
9
|
-
@title
|
7
|
+
@id = attributes['templateID']
|
8
|
+
@survey_id = attributes['surveyID']
|
9
|
+
@title = attributes['title']
|
10
10
|
@content_summary = attributes['contentSummary']
|
11
11
|
end
|
12
12
|
|
@@ -3,15 +3,22 @@ require "questionpro_rails/choice"
|
|
3
3
|
module QuestionproRails
|
4
4
|
class Question
|
5
5
|
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :id, :order_number, :text
|
7
|
+
|
8
|
+
# @return [Array<Hash>] Choices available for the question.
|
9
|
+
attr_reader :qp_answers
|
7
10
|
|
8
11
|
def initialize (attributes)
|
9
|
-
@id
|
12
|
+
@id = attributes['id']
|
10
13
|
@order_number = attributes['orderNumber']
|
11
|
-
@text
|
12
|
-
@qp_answers
|
14
|
+
@text = attributes['text']
|
15
|
+
@qp_answers = attributes['answers']
|
13
16
|
end
|
14
17
|
|
18
|
+
# Extract the choices from the hashes stored
|
19
|
+
# inside qp_answers attribute.
|
20
|
+
#
|
21
|
+
# @return [Array<QuestionproRails::Choice>] Choices.
|
15
22
|
def choices
|
16
23
|
extracted_choices = []
|
17
24
|
|
@@ -4,9 +4,9 @@ module QuestionproRails
|
|
4
4
|
attr_reader :id, :answer_text, :value
|
5
5
|
|
6
6
|
def initialize (attributes)
|
7
|
-
@id
|
7
|
+
@id = attributes['id']
|
8
8
|
@answer_text = attributes['answerText']
|
9
|
-
@value
|
9
|
+
@value = attributes['value']
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
@@ -3,16 +3,23 @@ require "questionpro_rails/response_answer"
|
|
3
3
|
module QuestionproRails
|
4
4
|
class ResponseSet
|
5
5
|
|
6
|
-
attr_reader :question_code, :question_description, :question_id, :question_text
|
6
|
+
attr_reader :question_code, :question_description, :question_id, :question_text
|
7
|
+
|
8
|
+
# @return [Array<Hash>] Answers collected from the survey response.
|
9
|
+
attr_reader :qp_values
|
7
10
|
|
8
11
|
def initialize (attributes)
|
9
|
-
@question_code
|
12
|
+
@question_code = attributes['questionCode']
|
10
13
|
@question_description = attributes['questionDescription']
|
11
|
-
@question_id
|
12
|
-
@question_text
|
13
|
-
@qp_values
|
14
|
+
@question_id = attributes['questionID']
|
15
|
+
@question_text = attributes['questionText']
|
16
|
+
@qp_values = attributes['values']
|
14
17
|
end
|
15
18
|
|
19
|
+
# Extract the Answers from the hashes stored
|
20
|
+
# inside qp_values attribute.
|
21
|
+
#
|
22
|
+
# @return [Array<QuestionproRails::ResponseAnswer>] Response Answers.
|
16
23
|
def answers
|
17
24
|
extracted_answers = []
|
18
25
|
|
@@ -3,31 +3,39 @@ require "questionpro_rails/question"
|
|
3
3
|
module QuestionproRails
|
4
4
|
class Section
|
5
5
|
|
6
|
-
attr_reader :num_tasks, :exact_min_answers, :orientation, :code,
|
7
|
-
|
8
|
-
|
6
|
+
attr_reader :id, :num_tasks, :exact_min_answers, :orientation, :code,
|
7
|
+
:max_answers, :required, :has_page_break, :type,
|
8
|
+
:dynamic_explode_text, :video, :video_type, :min_answers,
|
9
|
+
:random, :random_section, :subtype, :mobile_friendly
|
10
|
+
|
11
|
+
# @return [Array<Hash>] Questions collected inside the section.
|
12
|
+
attr_reader :qp_questions
|
9
13
|
|
10
14
|
def initialize(attributes)
|
11
|
-
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@video
|
20
|
-
@type
|
21
|
-
@min_answers
|
22
|
-
@required
|
23
|
-
@has_page_break
|
24
|
-
@random
|
25
|
-
@random_section
|
26
|
-
@subtype
|
27
|
-
@mobile_friendly
|
28
|
-
@qp_questions
|
15
|
+
@id = attributes['sectionID']
|
16
|
+
@num_tasks = attributes['numTasks']
|
17
|
+
@exact_min_answers = attributes['exactMinAnswers']
|
18
|
+
@orientation = attributes['orientation']
|
19
|
+
@code = attributes['code']
|
20
|
+
@video_type = attributes['videoType']
|
21
|
+
@max_answers = attributes['maxAnswers']
|
22
|
+
@dynamic_explode_text = attributes['dynamicExplodeText']
|
23
|
+
@video = attributes['video']
|
24
|
+
@type = attributes['type']
|
25
|
+
@min_answers = attributes['minAnswers']
|
26
|
+
@required = attributes['required']
|
27
|
+
@has_page_break = attributes['hasPageBreak']
|
28
|
+
@random = attributes['random']
|
29
|
+
@random_section = attributes['randomSection']
|
30
|
+
@subtype = attributes['subtype']
|
31
|
+
@mobile_friendly = attributes['mobileFriendly']
|
32
|
+
@qp_questions = attributes['questions']
|
29
33
|
end
|
30
34
|
|
35
|
+
# Extract the Questions from the hashes stored
|
36
|
+
# inside qp_questions attribute.
|
37
|
+
#
|
38
|
+
# @return [Array<QuestionproRails::Question>] Questions.
|
31
39
|
def questions
|
32
40
|
extracted_questions = []
|
33
41
|
|
@@ -4,20 +4,27 @@ module QuestionproRails
|
|
4
4
|
class Survey
|
5
5
|
|
6
6
|
attr_reader :id, :name, :subtitle, :url, :thank_you_message,
|
7
|
-
:has_scoring_logic, :numeric_title, :status
|
7
|
+
:has_scoring_logic, :numeric_title, :status
|
8
|
+
|
9
|
+
# @return [Array<Hash>] Sections collected from the survey request.
|
10
|
+
attr_reader :qp_sections
|
8
11
|
|
9
12
|
def initialize (attributes)
|
10
|
-
@id
|
11
|
-
@name
|
12
|
-
@url
|
13
|
-
@subtitle
|
13
|
+
@id = (attributes['id'] || attributes['surveyID'])
|
14
|
+
@name = (attributes['title'] || attributes['surveyName'])
|
15
|
+
@url = (attributes['surveyURL'] || attributes['connectURL'])
|
16
|
+
@subtitle = attributes['subtitle']
|
14
17
|
@thank_you_message = attributes['thankYouMessage']
|
15
18
|
@has_scoring_logic = attributes['hasScoringLogic']
|
16
|
-
@numeric_title
|
17
|
-
@status
|
18
|
-
@qp_sections
|
19
|
+
@numeric_title = attributes['numericTitle']
|
20
|
+
@status = attributes['status']
|
21
|
+
@qp_sections = attributes['sections']
|
19
22
|
end
|
20
23
|
|
24
|
+
# Extract the Sections from the hashes stored
|
25
|
+
# inside qp_sections attribute.
|
26
|
+
#
|
27
|
+
# @return [Array<QuestionproRails::Section>] Sections.
|
21
28
|
def sections
|
22
29
|
extracted_sections = []
|
23
30
|
|
@@ -4,13 +4,21 @@ require "questionpro_rails/template"
|
|
4
4
|
module QuestionproRails
|
5
5
|
class SurveyMeta
|
6
6
|
|
7
|
-
|
7
|
+
# @return [Array<Hash>] Email Groups List collected from the survey meta.
|
8
|
+
attr_reader :email_groups_list
|
9
|
+
|
10
|
+
# @return [Array<Hash>] Templates List collected from the survey meta.
|
11
|
+
attr_reader :templates_list
|
8
12
|
|
9
13
|
def initialize (attributes)
|
10
14
|
@email_groups_list = attributes['emailGroups']
|
11
|
-
@templates_list
|
15
|
+
@templates_list = attributes['templates']
|
12
16
|
end
|
13
17
|
|
18
|
+
# Extract the Email Groups from the hashes stored
|
19
|
+
# inside email_groups_list attribute.
|
20
|
+
#
|
21
|
+
# @return [Array<QuestionproRails::EmailGroup>] Email Groups.
|
14
22
|
def email_groups
|
15
23
|
extracted_groups = []
|
16
24
|
|
@@ -23,6 +31,10 @@ module QuestionproRails
|
|
23
31
|
return extracted_groups
|
24
32
|
end
|
25
33
|
|
34
|
+
# Extract the Templates from the hashes stored
|
35
|
+
# inside templates_list attribute.
|
36
|
+
#
|
37
|
+
# @return [Array<QuestionproRails::Template>] Templates.
|
26
38
|
def templates
|
27
39
|
extracted_templates = []
|
28
40
|
|
@@ -4,22 +4,29 @@ module QuestionproRails
|
|
4
4
|
class SurveyResponse
|
5
5
|
|
6
6
|
attr_reader :id, :country, :duplicate, :external_reference,
|
7
|
-
:ip_address, :region, :
|
7
|
+
:ip_address, :region, :response_status,
|
8
8
|
:time_taken, :timestamp
|
9
9
|
|
10
|
+
# @return [Array<Hash>] Response Set collected from the survey response.
|
11
|
+
attr_reader :qp_response_set
|
12
|
+
|
10
13
|
def initialize (attributes)
|
11
|
-
@id
|
12
|
-
@country
|
13
|
-
@duplicate
|
14
|
+
@id = attributes['id']
|
15
|
+
@country = attributes['country']
|
16
|
+
@duplicate = attributes['duplicate']
|
14
17
|
@external_reference = attributes['externalReference']
|
15
|
-
@ip_address
|
16
|
-
@region
|
17
|
-
@qp_response_set
|
18
|
-
@response_status
|
19
|
-
@time_taken
|
20
|
-
@timestamp
|
18
|
+
@ip_address = attributes['ipAddress']
|
19
|
+
@region = attributes['region']
|
20
|
+
@qp_response_set = attributes['responseSet']
|
21
|
+
@response_status = attributes['responseStatus']
|
22
|
+
@time_taken = attributes['timeTaken']
|
23
|
+
@timestamp = attributes['timestamp']
|
21
24
|
end
|
22
25
|
|
26
|
+
# Extract the Response Set from the hash stored
|
27
|
+
# inside qp_response_set attribute.
|
28
|
+
#
|
29
|
+
# @return [Array<QuestionproRails::ResponseSet>] Response Sets.
|
23
30
|
def response_set
|
24
31
|
extracted_sets = []
|
25
32
|
|
@@ -6,17 +6,17 @@ module QuestionproRails
|
|
6
6
|
:complete_count, :started_count, :status
|
7
7
|
|
8
8
|
def initialize (attributes)
|
9
|
-
@id
|
10
|
-
@name
|
11
|
-
@partial_count
|
12
|
-
@overall_viewed_count
|
13
|
-
@overall_complete_count
|
9
|
+
@id = attributes['id']
|
10
|
+
@name = attributes['name']
|
11
|
+
@partial_count = attributes['partialCount']
|
12
|
+
@overall_viewed_count = attributes['overallViewedCount']
|
13
|
+
@overall_complete_count = attributes['overallCompleteCount']
|
14
14
|
@overall_terminated_count = attributes['overallTerminatedCount']
|
15
|
-
@terminated_count
|
16
|
-
@overall_started_count
|
17
|
-
@complete_count
|
18
|
-
@started_count
|
19
|
-
@status
|
15
|
+
@terminated_count = attributes['terminatedCount']
|
16
|
+
@overall_started_count = attributes['overallStartedCount']
|
17
|
+
@complete_count = attributes['completeCount']
|
18
|
+
@started_count = attributes['startedCount']
|
19
|
+
@status = attributes['status']
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -4,8 +4,8 @@ module QuestionproRails
|
|
4
4
|
attr_reader :id, :email, :unsubscribed_time
|
5
5
|
|
6
6
|
def initialize (attributes)
|
7
|
-
@id
|
8
|
-
@email
|
7
|
+
@id = attributes['id']
|
8
|
+
@email = attributes['emailAddress']
|
9
9
|
@unsubscribed_time = attributes['unsubscribedTime']
|
10
10
|
end
|
11
11
|
end
|
data/lib/questionpro_rails.rb
CHANGED
@@ -6,20 +6,29 @@ require "questionpro_rails/api_request"
|
|
6
6
|
module QuestionproRails
|
7
7
|
|
8
8
|
class << self
|
9
|
+
|
9
10
|
attr_accessor :configuration
|
10
11
|
|
12
|
+
# Get the Configurations or Reset
|
13
|
+
#
|
14
|
+
# @return [QuestionproRails::Configuration] Configuration
|
11
15
|
def configuration
|
12
16
|
@configuration ||= Configuration.new
|
13
17
|
end
|
14
18
|
|
19
|
+
# Reset Configuration to nil
|
15
20
|
def reset
|
16
21
|
@configuration = Configuration.new
|
17
22
|
end
|
18
23
|
|
24
|
+
# Holds the configurtion block
|
19
25
|
def configure
|
20
26
|
yield(configuration)
|
21
27
|
end
|
22
28
|
|
29
|
+
# Get the api key from the configurations
|
30
|
+
#
|
31
|
+
# @return [String] Api Key
|
23
32
|
def api_key
|
24
33
|
configuration.api_key
|
25
34
|
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.1.
|
4
|
+
version: 0.1.1
|
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
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: httparty
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.15.6
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.15.6
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- assem.deghady@gmail.com
|