quest_back 0.0.1 → 0.0.2

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: 71ac294356aae1fe3423d0cba13cb705a1245cfd
4
- data.tar.gz: 99bf75d03a7984badd0291ba474d27e07b9796fd
3
+ metadata.gz: 11586d8a26f2c49c1fa272a5a0f74f93c1682f0d
4
+ data.tar.gz: cbda0b537c75e65812d6904271e66a74003fad9b
5
5
  SHA512:
6
- metadata.gz: 83d3d479391da098c8c62d9bc1d157c0fe14708c1ad320cb76d61605519b3404ce133648a8a38007c00cc9a436882f8f052d269786c05590e8b3ab56ce180d91
7
- data.tar.gz: f030b1fa5a1f02645e39386cc630cde2c08d5f5e06d2a7dd02938bb941c15905192df38c24bfe467ae3bec4c645cdffb16d5a0fb299977aa8d5c223cfe7d9299
6
+ metadata.gz: 936152bee1653f4d3633f8b5ce8d68e7a3dbe615b316fbe824466039836dfd6c27685034dab9e8d9bb335ce6d9b38e98cc48fe058e62d1867ddab5f2e4780800
7
+ data.tar.gz: 3c165b8129933a20cac0fb18420efec47c7ce7826f805bb66c58fcb27050f11cf077bd1e68a139ea494b99cb28a855759fb93d2f6d248fe723ed2bacb8b8f0ea
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ ## 0.0.2 (unreleased)
2
+ * Support for operation `add_respondents_data_with_sms_invitation`.
3
+
4
+ ## 0.0.1
5
+ * Added `QuestBack.debug!` option. Does not send request, logs generated XML.
6
+ * Basic operations `test_connection`, `get_quests`, `get_language_list`,
7
+ `add_email_invitees` and `add_respondents_data`.
8
+ * Simple `QuestBack::Response` object for wrapping Savon's response and
9
+ provide an interface for reading out response's `result` or `results`.
10
+ * Configuration and authentication.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # QuestBack
2
2
 
3
- Simply Ruby client for QuestBack's SOAP API.
3
+ Simple Ruby client for QuestBack's SOAP API.
4
4
 
5
5
  ### WARNING
6
6
 
@@ -8,8 +8,8 @@ This gem is not complete and may lack many functions provided by QuestBack.
8
8
  Please feel free to contribute and make pull requests.
9
9
 
10
10
  It is also very simplistic, only using simple hashes for both sending in arguments to the API and returning responses.
11
- The hash you send as argument to operation methods is more or less sent on to QuestBack.
12
- Maybe this will change in the future with real objects sent in to the API.
11
+ The hash you send as argument to an operation methods is more or less passed on directly to QuestBack. We do some
12
+ transformation of the has to match the expectations of QuestBack's API.
13
13
 
14
14
 
15
15
 
@@ -30,17 +30,25 @@ Or install it yourself as:
30
30
 
31
31
  ## Usage
32
32
 
33
- ### Get access - test client in console
33
+ ### Getting access to API
34
34
 
35
35
  1. Go to https://response.questback.com/soapdocs/integration/ and request white listing of the IP you will make requests from.
36
36
  2. Sign in to QuestBack. Go to your account's page and fill in "Integration username and password".
37
37
  If you have no fields under Integration Information you have to contact QuestBack to get access.
38
- 3. Copy config.example.yml to config.yml and insert your username and password.
39
- 4. `QuestBack.conf!` to load config.yml as default config.
40
- 5. `QuestBack::Client.new.test_connection` to make a test connection API call. On successful connection this returns string with current namespace of integration library.
41
38
 
39
+ ### Create an API client
42
40
 
43
- ### Example of usage
41
+ ```ruby
42
+ api = QuestBack::Api.new(
43
+ config: QuestBack::Configuration.new(username: "username", password: "password")
44
+ )
45
+
46
+ response = api.test_connection
47
+ response.result
48
+ => "Connection sucessful. you are connected to namespace: https://integration.questback.com/2011/03"
49
+ ```
50
+
51
+ ### Examples
44
52
 
45
53
  ```ruby
46
54
  # Read quests
@@ -81,19 +89,19 @@ response = api.add_respondents_data(
81
89
  title: 'Epost',
82
90
  type: QuestBack::Api.respondent_data_header_type_for(:text),
83
91
  is_email_field: true,
84
- is_sms_field: false,
92
+ is_sms_field: false
85
93
  },
86
94
  {
87
95
  title: 'Navn',
88
96
  type: QuestBack::Api.respondent_data_header_type_for(:text),
89
97
  is_email_field: false,
90
- is_sms_field: false,
98
+ is_sms_field: false
91
99
  },
92
100
  {
93
101
  title: 'Alder',
94
102
  type: QuestBack::Api.respondent_data_header_type_for(:numeric),
95
103
  is_email_field: false,
96
- is_sms_field: false,
104
+ is_sms_field: false
97
105
  },
98
106
  ]
99
107
  },
@@ -105,6 +113,33 @@ response = api.add_respondents_data(
105
113
 
106
114
  response.result
107
115
  => "Added 1 respondent data to QuestId :4567668"
116
+
117
+
118
+ # Add respondent data with sms invitation
119
+ response = api.add_respondents_data_with_sms_invitation(
120
+ quest_info: {quest_id: 4567668, security_lock: 'm0pI8orKJp'},
121
+ respondents_data: {
122
+ respondent_data_header: {
123
+ respondent_data_header: [
124
+ {
125
+ title: 'Phone',
126
+ type: QuestBack::Api.respondent_data_header_type_for(:text),
127
+ is_email_field: false,
128
+ is_sms_field: true
129
+ }
130
+ ]
131
+ },
132
+ respondent_data: ['4711223344'],
133
+ allow_duplicate: true,
134
+ add_as_invitee: true
135
+ },
136
+ sms_from_number: 11111111,
137
+ sms_from_text: 'Inviso AS',
138
+ sms_message: 'Hello - please join our quest!'
139
+ )
140
+
141
+ response.result
142
+ => "Sms message created successfully"
108
143
  ```
109
144
 
110
145
  ### Debug XML without making a request
@@ -145,3 +180,12 @@ QuestBack.remove_debug! # Activates real requests again
145
180
  3. Commit your changes (`git commit -am 'Add some feature'`)
146
181
  4. Push to the branch (`git push origin my-new-feature`)
147
182
  5. Create new Pull Request
183
+
184
+ #### Test client in console
185
+
186
+ After cloning the repository you may do this to make it a bit more convenient working
187
+ with the code in your console while developing.
188
+
189
+ 1. Copy config.example.yml to config.yml and insert your username and password.
190
+ 2. Load console `bundle console` and do `QuestBack.conf!` to load config.yml as default config.
191
+ 3. `QuestBack::Client.new.test_connection` to make a test connection API call. On successful connection this returns string with current namespace of integration library.
@@ -19,7 +19,11 @@ module QuestBack
19
19
  ORDER = {
20
20
  get_quests: [:user_info, :paging_info, :quest_filter],
21
21
  add_email_invitees: [:user_info, :quest_info, :emails, :sendduplicate, :language_id],
22
- add_respondents_data: [:user_info, :quest_info, :respondents_data, :language_id]
22
+ add_respondents_data: [:user_info, :quest_info, :respondents_data, :language_id],
23
+ add_respondents_data_with_sms_invitation: [
24
+ :user_info, :quest_info, :respondents_data, :language_id,
25
+ :sms_from_number, :sms_from_text, :sms_message
26
+ ]
23
27
  }
24
28
 
25
29
  # In order to provide a simple response.result and response.results interface
@@ -34,7 +38,8 @@ module QuestBack
34
38
  get_quests: [:quests, :quest],
35
39
  get_language_list: [:language],
36
40
  add_email_invitees: [],
37
- add_respondents_data: []
41
+ add_respondents_data: [],
42
+ add_respondents_data_with_sms_invitation: []
38
43
  }
39
44
 
40
45
  RESPONDENTS_HEADER_TYPE = {
@@ -48,7 +53,9 @@ module QuestBack
48
53
  }
49
54
 
50
55
  def self.respondent_data_header_type_for(type)
51
- RESPONDENTS_HEADER_TYPE.fetch(type.to_sym) { fail ArgumentError, "#{type.to_s.inspect} is an unkown respondent data header type." }
56
+ RESPONDENTS_HEADER_TYPE.fetch(type.to_sym) do
57
+ fail ArgumentError, "#{type.to_s.inspect} is an unkown respondent data header type."
58
+ end
52
59
  end
53
60
 
54
61
  # Public: Creates a new API gateway object.
@@ -165,6 +172,51 @@ module QuestBack
165
172
  call :add_respondents_data, attributes, include_defaults: [:respondents_data]
166
173
  end
167
174
 
175
+ # Public: Add respondent data to a quest with SMS invitation
176
+ #
177
+ # attributes - Attributes sent to QuestBack
178
+ #
179
+ #
180
+ # Example
181
+ #
182
+ # response = api.add_respondents_data_with_sms_invitation(
183
+ # quest_info: {quest_id: 4567668, security_lock: 'm0pI8orKJp'},
184
+ # respondents_data: {
185
+ # respondent_data_header: {
186
+ # respondent_data_header: [
187
+ # {
188
+ # title: 'Epost',
189
+ # type: QuestBack::Api.respondent_data_header_type_for(:text),
190
+ # is_email_field: true,
191
+ # is_sms_field: false,
192
+ # },
193
+ # {
194
+ # title: 'Phone',
195
+ # type: QuestBack::Api.respondent_data_header_type_for(:text),
196
+ # is_email_field: false,
197
+ # is_sms_field: true,
198
+ # }
199
+ # ]
200
+ # },
201
+ # # According to QuestBack's doc you can only do one respondent data,
202
+ # # even though it for sure is an array. Phone numbers must be given
203
+ # # on with country code first.
204
+ # respondent_data: ['th@skalar.no;4711223344'],
205
+ # allow_duplicate: true,
206
+ # add_as_invitee: true
207
+ # },
208
+ # sms_from_number: 11111111,
209
+ # sms_from_text: 'Inviso AS',
210
+ # sms_message: 'Hello - please join our quest!'
211
+ # )
212
+ #
213
+ # You may override respondent_data's delimiter in string too.
214
+ #
215
+ # Returns QuestBack::Response
216
+ def add_respondents_data_with_sms_invitation(attributes = {})
217
+ call :add_respondents_data_with_sms_invitation, attributes, include_defaults: [:respondents_data]
218
+ end
219
+
168
220
 
169
221
 
170
222
 
@@ -235,7 +287,7 @@ module QuestBack
235
287
  unkown_keys = attributes.keys - order
236
288
 
237
289
  if unkown_keys.any?
238
- fail ArgumentError, "Unkown attributes given to #{options[:operation_name]}: #{unkown_keys.join(', ')}. Attributes' order needs to be configured in #{self.class.name}::ORDER."
290
+ fail ArgumentError, "Unkown attribute(s) given to #{options[:operation_name]}: #{unkown_keys.join(', ')}. Attributes' order is defined in #{self.class.name}::ORDER, but you sent in something we do not have."
239
291
  end
240
292
 
241
293
  message[:order!] = order & message.keys
@@ -1,3 +1,3 @@
1
1
  module QuestBack
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,8 @@
1
+ <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
2
+ <s:Body>
3
+ <s:Fault>
4
+ <faultcode>s:Client</faultcode>
5
+ <faultstring xml:lang="nb-NO">Invalid input: Failed to parse sms number! Number:aaaa</faultstring>
6
+ </s:Fault>
7
+ </s:Body>
8
+ </s:Envelope>
@@ -0,0 +1,7 @@
1
+ <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
2
+ <s:Body>
3
+ <AddRespondentsDataWithSmsInvitationResponse xmlns="https://integration.questback.com/2011/03">
4
+ <AddRespondentsDataWithSmsInvitationResult>Sms message created successfully</AddRespondentsDataWithSmsInvitationResult>
5
+ </AddRespondentsDataWithSmsInvitationResponse>
6
+ </s:Body>
7
+ </s:Envelope>
@@ -253,5 +253,86 @@ describe QuestBack::Api, type: :request do
253
253
  expect(response).to be_successful
254
254
  end
255
255
  end
256
+
257
+ describe "#add_respondents_data_with_sms_invitation" do
258
+ it "makes call with expected arguments" do
259
+ expected_message = expected_default_message.merge(
260
+ quest_info: {'QuestId' => 4567668, 'SecurityLock' => 'm0pI8orKJp'},
261
+ respondents_data: {
262
+ 'RespondentDataHeader' => {
263
+ 'RespondentDataHeader' => [
264
+ {
265
+ 'Title' => 'Epost',
266
+ 'enum:Type' => 2,
267
+ 'IsEmailField' => true,
268
+ 'IsSmsField' => false
269
+ },
270
+ {
271
+ 'Title' => 'Mobil',
272
+ 'enum:Type' => 2,
273
+ 'IsEmailField' => false,
274
+ 'IsSmsField' => true
275
+ }
276
+ ]
277
+ },
278
+ 'RespondentData' => {'array:string' => ['th@skalar.no;404 40 404']},
279
+ 'Delimiter' => ';',
280
+ 'AllowDuplicate' => true,
281
+ 'AddAsInvitee' => true,
282
+ order!: ["RespondentDataHeader", "RespondentData", "Delimiter", "AllowDuplicate", "AddAsInvitee"]
283
+ },
284
+ sms_from_number: 11111111,
285
+ sms_from_text: 'Inviso AS',
286
+ sms_message: 'Hello - please join our quest!',
287
+ order!: QuestBack::Api::ORDER[:add_respondents_data_with_sms_invitation] - [:language_id]
288
+ )
289
+
290
+
291
+ savon.expects(:add_respondents_data_with_sms_invitation)
292
+ .with(message: expected_message)
293
+ .returns success_fixture_for 'add_respondents_data_with_sms_invitation'
294
+
295
+
296
+ response = subject.add_respondents_data_with_sms_invitation(
297
+ quest_info: {quest_id: 4567668, security_lock: 'm0pI8orKJp'},
298
+ respondents_data: {
299
+ respondent_data_header: {
300
+ respondent_data_header: [
301
+ {
302
+ title: 'Epost',
303
+ type: QuestBack::Api.respondent_data_header_type_for(:text),
304
+ is_email_field: true,
305
+ is_sms_field: false,
306
+ },
307
+ {
308
+ title: 'Mobil',
309
+ type: QuestBack::Api.respondent_data_header_type_for(:text),
310
+ is_email_field: false,
311
+ is_sms_field: true,
312
+ }
313
+ ]
314
+ },
315
+ respondent_data: ['th@skalar.no;404 40 404'],
316
+ allow_duplicate: true,
317
+ add_as_invitee: true
318
+ },
319
+ sms_from_number: 11111111,
320
+ sms_from_text: 'Inviso AS',
321
+ sms_message: 'Hello - please join our quest!'
322
+ )
323
+
324
+ expect(response).to be_successful
325
+ end
326
+
327
+ it "fails with soap error when phone number isn't parsable" do
328
+ savon.expects(:add_respondents_data_with_sms_invitation)
329
+ .with(message: :any)
330
+ .returns failure_fixture_for 'add_respondents_data_with_sms_invitation'
331
+
332
+ expect {
333
+ subject.add_respondents_data_with_sms_invitation
334
+ }.to raise_error Savon::SOAPFault
335
+ end
336
+ end
256
337
  end
257
338
  end
metadata CHANGED
@@ -1,89 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quest_back
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorbjørn Hermansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-21 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.14
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.14
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: savon
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: 2.3.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ~>
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 2.3.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ~>
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.5'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ~>
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.5'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: 2.14.1
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ~>
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: 2.14.1
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rake
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '>='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  description:
@@ -93,7 +93,8 @@ executables: []
93
93
  extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
- - .gitignore
96
+ - ".gitignore"
97
+ - CHANGELOG.md
97
98
  - Gemfile
98
99
  - LICENSE.txt
99
100
  - README.md
@@ -109,6 +110,8 @@ files:
109
110
  - quest_back.gemspec
110
111
  - spec/fixtures/add_email_invitees_success.xml
111
112
  - spec/fixtures/add_respondents_data_success.xml
113
+ - spec/fixtures/add_respondents_data_with_sms_invitation_failure.xml
114
+ - spec/fixtures/add_respondents_data_with_sms_invitation_success.xml
112
115
  - spec/fixtures/get_language_list_success.xml
113
116
  - spec/fixtures/get_quests_multiple_response_success.xml
114
117
  - spec/fixtures/get_quests_success.xml
@@ -129,23 +132,25 @@ require_paths:
129
132
  - lib
130
133
  required_ruby_version: !ruby/object:Gem::Requirement
131
134
  requirements:
132
- - - '>='
135
+ - - ">="
133
136
  - !ruby/object:Gem::Version
134
137
  version: '0'
135
138
  required_rubygems_version: !ruby/object:Gem::Requirement
136
139
  requirements:
137
- - - '>='
140
+ - - ">="
138
141
  - !ruby/object:Gem::Version
139
142
  version: '0'
140
143
  requirements: []
141
144
  rubyforge_project:
142
- rubygems_version: 2.0.0
145
+ rubygems_version: 2.2.2
143
146
  signing_key:
144
147
  specification_version: 4
145
148
  summary: Ruby client for QuestBack's SOAP API.
146
149
  test_files:
147
150
  - spec/fixtures/add_email_invitees_success.xml
148
151
  - spec/fixtures/add_respondents_data_success.xml
152
+ - spec/fixtures/add_respondents_data_with_sms_invitation_failure.xml
153
+ - spec/fixtures/add_respondents_data_with_sms_invitation_success.xml
149
154
  - spec/fixtures/get_language_list_success.xml
150
155
  - spec/fixtures/get_quests_multiple_response_success.xml
151
156
  - spec/fixtures/get_quests_success.xml