questionpro_rails 0.0.5 → 0.0.6

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: ef961772ad89a7964a173d02cd4ca93a3853363c
4
- data.tar.gz: bceb92de666f5666b19c84ebceaf16030f2a7715
3
+ metadata.gz: 25fa27421feff20182934df930901dcef7f57ee0
4
+ data.tar.gz: 9e5bb13740c6376682e0ba2e351dd288a89327f3
5
5
  SHA512:
6
- metadata.gz: 79eada3ac1f1262c992aff1256e793e1b3ca664d7b823123d93ab0bee8aa4bd3d2f7e6a58bc9d79b0243cfcdcf95099c8b88e7181f9a7a3c9fc45f2d62a37189
7
- data.tar.gz: 0aca497dd1ba4ca0078cd1d56f675d7501a4e3b44d153c4b6d22cacebc9ab67a40929b6022a8fe91864abdae532340480eccbd4e7dab6a58d42632e3d9940490
6
+ metadata.gz: 3a4ea56c30791509b56041690d81f759fe8959528525e2bd97776d022c36dc370d80ce19998d4502397b98b2af03cff3a785d97359d91a647b64da544634ac07
7
+ data.tar.gz: c2d0f10996afa38501b5fac4929f8baf4d6044a205a568248a169b2f88a1fcd6dd4c521a53f20f5d6d7c7a425d924e199d7f657d5e21478b3772b6b5f1b58e75
@@ -0,0 +1,18 @@
1
+ module QuestionproRails
2
+ class Account
3
+
4
+ attr_reader :id, :first_name, :last_name, :last_login, :email_address,
5
+ :account_type, :creation_date, :phone
6
+
7
+ def initialize (attributes)
8
+ @id = attributes['userID']
9
+ @first_name = attributes['firstName']
10
+ @last_name = attributes['lastName']
11
+ @last_login = attributes['lastLogin']
12
+ @email_address = attributes['emailAddress']
13
+ @phone = attributes['phone']
14
+ @account_type = attributes['accountType']
15
+ @creation_date = attributes['creationDate']
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,10 @@
1
1
  require "questionpro_rails/survey"
2
+ require "questionpro_rails/account"
3
+ require "questionpro_rails/email_list"
4
+ require "questionpro_rails/email_template"
2
5
  require "questionpro_rails/survey_response"
3
6
  require "questionpro_rails/survey_response_count"
7
+ require "questionpro_rails/unsubscribed_email"
4
8
 
5
9
  module QuestionproRails
6
10
  class ApiRequest
@@ -8,16 +12,19 @@ module QuestionproRails
8
12
  format :json
9
13
  base_uri 'www.questionpro.com'
10
14
 
11
- attr_accessor :id, :response_id,:result_mode, :start_date, :end_date, :starting_response_counter,
12
- :status, :full_response, :success
15
+ attr_accessor :survey_id, :response_id, :result_mode, :start_date, :end_date, :starting_response_counter,
16
+ :email_group_id, :template_id, :user_id,:status, :full_response, :success
13
17
 
14
- def initialize(id, response_id = nil, result_mode = 0, start_date = nil, end_date = nil, starting_response_counter = nil)
15
- @id = id
18
+ 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)
19
+ @survey_id = survey_id
16
20
  @response_id = response_id
17
21
  @result_mode = result_mode
18
22
  @start_date = start_date
19
23
  @end_date = end_date
20
- @starting_response_counter = starting_response_counter
24
+ @starting_response_counter = starting_response_counter
25
+ @email_group_id = email_group_id
26
+ @template_id = template_id
27
+ @user_id = user_id
21
28
  end
22
29
 
23
30
  def self.base_path(method_url)
@@ -25,8 +32,10 @@ module QuestionproRails
25
32
  end
26
33
 
27
34
  def options
28
- {id: self.id, surveyID: self.id, responseID: self.response_id, resultMode: self.result_mode, startDate: self.start_date,
29
- endDate: self.end_date, startingResponseCounter: self.starting_response_counter}.compact.to_json
35
+ {id: self.survey_id, surveyID: self.survey_id, responseID: self.response_id,
36
+ resultMode: self.result_mode, startDate: self.start_date, userID: self.user_id,
37
+ endDate: self.end_date, startingResponseCounter: self.starting_response_counter,
38
+ emailGroupID: self.email_group_id, templateID: self.template_id}.compact.to_json
30
39
  end
31
40
 
32
41
  def list_surveys
@@ -34,7 +43,7 @@ module QuestionproRails
34
43
  result = self.class.get(url, body: self.options)
35
44
 
36
45
  self.full_response = result
37
- self.status = result['status']
46
+ self.status = result['status']
38
47
 
39
48
  surveys = []
40
49
  result_surveys = result['response']['surveys']
@@ -118,5 +127,127 @@ module QuestionproRails
118
127
 
119
128
  return self
120
129
  end
130
+
131
+ def get_email_lists
132
+ url = ApiRequest.base_path("questionpro.survey.getEmailLists")
133
+ result = self.class.get(url, body: self.options)
134
+
135
+ self.full_response = result
136
+ self.status = result['status']
137
+
138
+ email_lists = []
139
+ result_email_lists = result['response']['emailLists']
140
+ result_email_lists.each do |email_list|
141
+ email_lists.push(EmailList.new(email_list))
142
+ end
143
+
144
+ return email_lists
145
+ end
146
+
147
+ def get_email_list
148
+ url = ApiRequest.base_path("questionpro.survey.getEmailList")
149
+ result = self.class.get(url, body: self.options)
150
+
151
+ self.full_response = result
152
+ self.status = result['status']
153
+
154
+ email_list = EmailList.new(result['response']['emailList'])
155
+
156
+ return email_list
157
+ end
158
+
159
+ def delete_email_list
160
+ url = ApiRequest.base_path("questionpro.survey.deleteEmailList")
161
+ result = self.class.get(url, body: self.options)
162
+
163
+ self.full_response = result
164
+ self.status = result['status']
165
+ self.success = result['response']['success']
166
+
167
+ return self
168
+ end
169
+
170
+ def get_email_templates
171
+ url = ApiRequest.base_path("questionpro.survey.getEmailTemplates")
172
+ result = self.class.get(url, body: self.options)
173
+
174
+ self.full_response = result
175
+ self.status = result['status']
176
+
177
+ email_templates = []
178
+ result_email_templates = result['response']['emailTemplates']
179
+ result_email_templates.each do |email_template|
180
+ email_templates.push(EmailTemplate.new(email_template))
181
+ end
182
+
183
+ return email_templates
184
+ end
185
+
186
+ def get_email_template
187
+ url = ApiRequest.base_path("questionpro.survey.getEmailTemplate")
188
+ result = self.class.get(url, body: self.options)
189
+
190
+ self.full_response = result
191
+ self.status = result['status']
192
+
193
+ email_template = EmailTemplate.new(result['response']['emailTemplate'])
194
+
195
+ return email_template
196
+ end
197
+
198
+ def delete_email_template
199
+ url = ApiRequest.base_path("questionpro.survey.deleteEmailTemplate")
200
+ result = self.class.get(url, body: self.options)
201
+
202
+ self.full_response = result
203
+ self.status = result['status']
204
+ self.success = result['response']['success']
205
+
206
+ return self
207
+ end
208
+
209
+ def get_all_accounts
210
+ url = ApiRequest.base_path("questionpro.survey.getAllAccounts")
211
+ result = self.class.get(url, body: self.options)
212
+
213
+ self.full_response = result
214
+ self.status = result['status']
215
+
216
+ accounts = []
217
+ result_accounts = result['response']['accounts']
218
+ result_accounts.each do |account|
219
+ accounts.push(Account.new(account))
220
+ end
221
+
222
+ return accounts
223
+ end
224
+
225
+ def get_account
226
+ url = ApiRequest.base_path("questionpro.survey.getAccount")
227
+ result = self.class.get(url, body: self.options)
228
+
229
+ self.full_response = result
230
+ self.status = result['status']
231
+
232
+ account = Account.new(result['response']['account'])
233
+
234
+ return account
235
+ end
236
+
237
+ def get_unsubscribers
238
+ url = ApiRequest.base_path("questionpro.survey.getUnsubscribedEmailAddresses")
239
+ result = self.class.get(url, body: self.options)
240
+
241
+ self.full_response = result
242
+ self.status = result['status']
243
+
244
+ unsubscribers = []
245
+ result_unsubscribers = result['response']['response']
246
+ result_unsubscribers.each do |unsubscriber|
247
+ unsubscribers.push(UnsubscribedEmail.new(unsubscriber))
248
+ end
249
+
250
+ return unsubscribers
251
+ end
121
252
  end
122
- end
253
+ end
@@ -0,0 +1,41 @@
1
+ require "questionpro_rails/email_list_statistic"
2
+
3
+ module QuestionproRails
4
+ class EmailList
5
+
6
+ attr_reader :survey_id, :name, :email_group_id, :email, :qp_statistics,
7
+ :unsubscribed, :total, :active, :pendin_verification, :bounced
8
+
9
+ def initialize (attributes)
10
+ @survey_id = attributes['surveyID']
11
+ @name = attributes['name']
12
+ @email_group_id = attributes['emailGroupID']
13
+ @email = attributes['email']
14
+ @qp_statistics = attributes['statistics']
15
+ @unsubscribed = attributes['unsubscribed']
16
+ @total = attributes['total']
17
+ @active = attributes['active']
18
+ @pendin_verification = attributes['pendinVerification']
19
+ @bounced = attributes['bounced']
20
+ end
21
+
22
+ def statistics
23
+ extracted_statistics = []
24
+
25
+ if self.qp_statistics.any?
26
+ self.qp_statistics.each do |statistic|
27
+ extracted_statistics.push(EmailListStatistic.new(statistic))
28
+ end
29
+ end
30
+
31
+ return extracted_statistics
32
+ end
33
+
34
+ def emails
35
+ unless self.email.blank?
36
+ return self.email.split(',')
37
+ end
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ module QuestionproRails
2
+ class EmailListStatistic
3
+
4
+ attr_reader :statistics, :unsubscribed, :total, :active,
5
+ :pendin_verification, :bounced
6
+
7
+ def initialize (attributes)
8
+ @statistics = attributes['statistics']
9
+ @unsubscribed = attributes['unsubscribed']
10
+ @total = attributes['total']
11
+ @active = attributes['active']
12
+ @pendin_verification = attributes['pendinVerification']
13
+ @bounced = attributes['bounced']
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ module QuestionproRails
2
+ class EmailTemplate
3
+
4
+ attr_reader :id, :survey_id, :title, :content_summary
5
+
6
+ def initialize (attributes)
7
+ @id = attributes['templateID']
8
+ @survey_id = attributes['surveyID']
9
+ @title = attributes['title']
10
+ @content_summary = attributes['contentSummary']
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module QuestionproRails
2
+ class UnsubscribedEmail
3
+
4
+ attr_reader :id, :email, :unsubscribed_time
5
+
6
+ def initialize (attributes)
7
+ @id = attributes['id']
8
+ @email = attributes['emailAddress']
9
+ @unsubscribed_time = attributes['unsubscribedTime']
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module QuestionproRails
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: questionpro_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Assem Deghady
@@ -74,9 +74,13 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - lib/questionpro_rails.rb
77
+ - lib/questionpro_rails/account.rb
77
78
  - lib/questionpro_rails/api_request.rb
78
79
  - lib/questionpro_rails/choice.rb
79
80
  - lib/questionpro_rails/configuration.rb
81
+ - lib/questionpro_rails/email_list.rb
82
+ - lib/questionpro_rails/email_list_statistic.rb
83
+ - lib/questionpro_rails/email_template.rb
80
84
  - lib/questionpro_rails/question.rb
81
85
  - lib/questionpro_rails/response_answer.rb
82
86
  - lib/questionpro_rails/response_set.rb
@@ -84,6 +88,7 @@ files:
84
88
  - lib/questionpro_rails/survey.rb
85
89
  - lib/questionpro_rails/survey_response.rb
86
90
  - lib/questionpro_rails/survey_response_count.rb
91
+ - lib/questionpro_rails/unsubscribed_email.rb
87
92
  - lib/questionpro_rails/version.rb
88
93
  homepage: https://github.com/AssemDeghady/questionpro_rails
89
94
  licenses: