textkey_rest 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c918a5c5d0b323764790abb656360b2afa93cc98
4
+ data.tar.gz: 34796a2bcd7384ffe2d02ffa53be2f28a1a0ad1a
5
+ SHA512:
6
+ metadata.gz: 8db6085be1a1baf6503e266ad6ecc94b69ec1515a5b491ca7b0fac0ee807f323b34047d197a6ae0a52c56d156bf0409de30e24e3d51c8c2ea62c7196d6d72d6a
7
+ data.tar.gz: 2df70a6ad089d39abd7d0caf7931a9c63e8593216d2f0e4e94ad98e7711705c0d2cf3847e82c3124f48ea7f2ee3e7a57d8c81845f6a385f8d5a8c2ab33ec2a5e
@@ -0,0 +1,20 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ # Macisms
17
+ *.DS_Store
18
+
19
+ # Any Gem files
20
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in textkey_rest.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TextPower, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,141 @@
1
+ TextKey REST Library
2
+ ====================
3
+
4
+ This Ruby library allows you to use TextKey's REST API calls server-side from a Ruby backend.
5
+
6
+ Common use-Case
7
+ ---------------
8
+
9
+ To ensure a secure environment, you don't want to use APIs directly from the front-end, but rather through web-services inside your Ruby backend.
10
+
11
+ More Information
12
+ ----------------
13
+
14
+ To get more detailed information on the TextKey API Services or to investigate the API in more detail, you can refer to the following:
15
+
16
+ * [TextKey Developer Site](http://developer.textkey.com)
17
+ * [TextKey API Call Documentation](http://developer.textkey.com/apidocumentation.php)
18
+ * [Test All TextKey API Calls](http://developer.textkey.com/apitestapicalls.php)
19
+ * [TextKey Sample Site](http://developer.textkey.com/apitextkeyexample.php)
20
+
21
+ Installing the Library
22
+ ----------------------
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'textkey_rest'
28
+ ```
29
+
30
+ Or install it from the command line:
31
+
32
+ $ gem install textkey_rest
33
+
34
+ Building the textkey_rest GEM
35
+ -----------------------------
36
+
37
+ From the root directory, run the following:
38
+
39
+ $ gem build textkey_rest.gemspec
40
+
41
+ Then you can install it yourself locally:
42
+
43
+ $ gem install ./textkey_rest-X.X.X.gem
44
+
45
+ How to use it?
46
+ --------------
47
+
48
+ The simple use case is to create a textkey object, call the appropriate API method and handle the returned object payload. The class will handle the details between the request and response and will return an object to work with.
49
+
50
+ For example, here is a use case to check if a user has already been registered using the `doesRegistrationUserIDExist` API Call.
51
+
52
+ ```ruby
53
+ # TestDoesRegistrationUserIdExist.rb
54
+ #
55
+ require 'json'
56
+ require 'textkey_rest'
57
+
58
+ # Setup
59
+ apiKey = "PUT API KEY HERE"
60
+
61
+ # Create the textkey object
62
+ textkey = TextKeyRest.new(apiKey, false)
63
+
64
+ # Setup the API parameters
65
+ userID = "BobSmithUID"
66
+ isHashed = "TRUE"
67
+
68
+ # Make the API Call
69
+ response = textkey.perform_DoesRegistrationUserIDExist(userID, isHashed)
70
+
71
+ # Pull out the data from the response
72
+ response_obj = JSON.parse(response)
73
+ response_data = response_obj['d']
74
+
75
+ # Display the response
76
+ puts "TextKey Results:"
77
+ puts JSON.pretty_generate response_data
78
+ ```
79
+
80
+ Initialization
81
+ ---------------
82
+
83
+ The basic initialize step consists of including the REST Library and then creating a textkey object.
84
+
85
+ ```ruby
86
+ require 'json'
87
+ require 'textkey_rest'
88
+
89
+ # Setup
90
+ apiKey = "PUT API KEY HERE"
91
+
92
+ # Create the textkey object
93
+ textkey = TextKeyRest.new(apiKey, false)
94
+ ```
95
+
96
+ Making the API Call
97
+ -------------------
98
+
99
+ Once initialized, you can now make a call out to the specific TextKey API using the textkey object you just created.
100
+
101
+ ```ruby
102
+ # Setup the API parameters
103
+ userID = "BobSmithUID"
104
+ isHashed = "TRUE"
105
+
106
+ # Make the API Call
107
+ response = textkey.perform_DoesRegistrationUserIDExist(userID, isHashed)
108
+ ```
109
+
110
+ Handling the resulting payload
111
+ ------------------------------
112
+
113
+ The API call will return back a JSON string with all of the API fields included. It is wrapped in the `d` parent element so that wrapper should be removed.
114
+
115
+ ```ruby
116
+ # Pull out the data from the response
117
+ response_obj = JSON.parse(response)
118
+ response_data = response_obj['d']
119
+
120
+ # Display the response
121
+ puts "TextKey Results:"
122
+ puts JSON.pretty_generate response_data
123
+ ```
124
+
125
+ NOTE: If there is an error, the `errorDescr` field of the returned JSON payload will contain a value.
126
+
127
+ Sample/Test Code
128
+ ----------------
129
+
130
+ There is sample/test code in the [test Folder](https://github.com/TEXTPOWER/RESTLibrary-ruby/tree/master/test) for each TextKey API call using the shared library. Just set your API Key in the configuration.rb file in the test folder. To run all of the tests, run TestAll.rb.
131
+
132
+ Contributing to this SDK
133
+ ------------------------
134
+
135
+ **Issues**
136
+
137
+ Please discuss issues and features on Github Issues. We'll be happy to answer to your questions and improve the SDK based on your feedback.
138
+
139
+ **Pull requests**
140
+
141
+ You are welcome to fork this SDK and to make pull requests on Github. We'll review each of them, and integrate in a future release if they are relevant.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ require "textkey_rest/version"
2
+ require "textkey_rest/textkey"
3
+
4
+ module TextkeyRest
5
+ end
@@ -0,0 +1,5 @@
1
+ module TextkeyRest
2
+ module Config
3
+ TK_BASE = { :rest_url => "https://secure.textkey.com/REST/TKRest.asmx/" }
4
+ end
5
+ end
@@ -0,0 +1,417 @@
1
+ #
2
+ # textkey.rb
3
+ #
4
+ # This library allows for making RESTful API requests
5
+ # to the TextKey REST API Service
6
+ #
7
+ # Author:: Stan Shaul
8
+ # Copyright:: Copyright (c) 2014 TextPower, Inc.
9
+ # License:: Distributes under the same terms as Ruby
10
+
11
+ require 'rest_client'
12
+ require 'json'
13
+ require 'textkey_rest/configuration'
14
+
15
+ class TextKeyRest
16
+ @authKey
17
+ @displayInfo
18
+
19
+ # constructor
20
+ def initialize(authKey, displayInfo=false)
21
+ # Set the API Key
22
+ @authKey = authKey
23
+
24
+ # Set the display options
25
+ @displayInfo = displayInfo
26
+ end
27
+
28
+ #
29
+ # performs the POST request
30
+ #
31
+ # * *Args* :
32
+ # - +url+ -> The TextKey REST URL
33
+ # - +postdata+ -> The post data for the request
34
+ #
35
+ # * *Returns* :
36
+ # - +The returned JSON payload as a string
37
+ #
38
+ # * *Raises* :
39
+ #
40
+ def sendAPIRequest(url, postdata)
41
+ # If show flag is set show the parameters
42
+ if @displayInfo
43
+ puts 'url: ' + url
44
+ puts 'Payload:'
45
+ puts JSON.pretty_generate postdata
46
+ end
47
+
48
+ # Send the API request
49
+ response = RestClient.post(url,
50
+ postdata.to_json,
51
+ :content_type => 'application/json')
52
+
53
+ # If show flag is set show the return payload
54
+ if @displayInfo
55
+ puts 'Results:'
56
+ puts JSON.pretty_generate JSON.parse(response)
57
+ end
58
+
59
+ return response.body
60
+ end
61
+
62
+ #
63
+ # perform_GetTempAPI_Key - Sends the gettempAPIKey API Request and return the results
64
+ #
65
+ # * *Args* :
66
+ # - +minutesDuration+ -> The number of minutes that this API key will be valid
67
+ #
68
+ # * *Returns* :
69
+ # - +The returned JSON payload as a string
70
+ #
71
+ # * *Raises* :
72
+ #
73
+ def perform_GetTempAPI_Key(minutesDuration)
74
+ # Build the URL
75
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "gettempAPIKey";
76
+
77
+ # Setup the payload
78
+ restpayload = { :DataIn => { :apiKey => @authKey, :minutesDuration => minutesDuration } }
79
+
80
+ # Make the API request
81
+ return sendAPIRequest(resturl, restpayload)
82
+ end
83
+
84
+ #
85
+ # perform_registerTextKeyUser - Send the perform_registerTextKeyUser API Request
86
+ # and return the results
87
+ #
88
+ # * *Args* :
89
+ # - +command+ -> The register command
90
+ # - +cellNumber+ -> The Cell Number that you are registering
91
+ # - +ownerFName+ -> User's First Name
92
+ # - +ownerLName+ -> User's Last Name
93
+ # - +suppl1+ -> An additional identifier chosen by the customer
94
+ # - +suppl2+ -> Another additional identifier chosen by the customer
95
+ # - +userID+ -> The user id that the end user has entered on the web site login page
96
+ # - +isHashed+ -> Is the user id hashed
97
+ # - +pinCode+ -> The numeric Pin Code
98
+ # - +distressPinCode+ -> The numeric Distress Pin Code
99
+ # - +textKeyMode+ -> The TextKey validation mode
100
+ # - +receiveMode+ -> The TextKey receive mode
101
+ #
102
+ # * *Returns* :
103
+ # - +The returned JSON payload as a string
104
+ #
105
+ def perform_registerTextKeyUser(command, cellNumber, ownerFName, ownerLName, suppl1, suppl2, userID, isHashed, pinCode, distressPinCode, textKeyMode, receiveMode)
106
+ # Build the URL
107
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "registerTextKeyUser";
108
+
109
+ # Setup the payload
110
+ restpayload = { :DataIn => { :apiKey => @authKey, :command => command, :cellNumber => cellNumber, :ownerFName => ownerFName, :ownerLName => ownerLName, :suppl1 => suppl1, :suppl2 => suppl2, :userID => userID, :isHashed => isHashed, :pinCode => pinCode, :distresspinCode => distressPinCode, :textKeyMode => textKeyMode, :receiveMode => receiveMode } }
111
+
112
+ # Make the API request
113
+ return sendAPIRequest(resturl, restpayload)
114
+ end
115
+
116
+ #
117
+ # perform_registerTextKeyUserCSA - Send the perform_registerTextKeyUserCSA API Request
118
+ # and return the results
119
+ #
120
+ # * *Args* :
121
+ # - +command+ -> The register command
122
+ # - +cellNumber+ -> The Cell Number that you are registering
123
+ # - +ownerFName+ -> User's First Name
124
+ # - +ownerLName+ -> User's Last Name
125
+ # - +suppl1+ -> An additional identifier chosen by the customer
126
+ # - +suppl2+ -> Another additional identifier chosen by the customer
127
+ # - +ownerBirthDate+ -> Users birth date. The format should be MM/DD/YYYY (i.e. 12/25/1984)
128
+ # - +gender+ -> The users gender. The values should be either M or F.
129
+ # - +userID+ -> The user id that the end user has entered on the web site login page
130
+ # - +isHashed+ -> Is the user id hashed
131
+ # - +pinCode+ -> The numeric Pin Code
132
+ # - +q1+ -> The first user profile question.
133
+ # - +a1+ -> The answer to the first user question.
134
+ # - +q2+ -> The second user profile question.
135
+ # - +a2+ -> The answer to the second user question.
136
+ # - +q3+ -> The third user profile question.
137
+ # - +a3+ -> The answer to the third user question.
138
+ # - +textKeyMode+ -> The TextKey validation mode
139
+ # - +receiveMode+ -> The TextKey receive mode.
140
+ #
141
+ # * *Returns* :
142
+ # - +The returned JSON payload as a string
143
+ #
144
+ def perform_registerTextKeyUserCSA(command,
145
+ cellNumber,
146
+ ownerFName,
147
+ ownerLName,
148
+ suppl1,
149
+ suppl2,
150
+ ownerBirthDate,
151
+ gender,
152
+ userID,
153
+ isHashed,
154
+ pinCode,
155
+ distressPinCode,
156
+ q1,
157
+ a1,
158
+ q2,
159
+ a2,
160
+ q3,
161
+ a3,
162
+ textKeyMode,
163
+ receiveMode)
164
+
165
+ # Build the URL
166
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "registerTextKeyUser";
167
+
168
+ # Setup the payload
169
+ restpayload = { :DataIn => { :apiKey => @authKey, :command => command, :cellNumber => cellNumber, :ownerFName => ownerFName, :ownerLName => ownerLName, :suppl1 => suppl1, :suppl2 => suppl2, :ownerBirthDate => ownerBirthDate, :ownergender => gender, :userID => userID, :isHashed => isHashed, :pinCode => pinCode, :distresspinCode => distressPinCode, :q1 => q1, :a1 => a1, :q2 => q2, :a2 => a2, :q3 => q3, :a3 => a3, :textKeyMode => textKeyMode, :receiveMode => receiveMode } }
170
+
171
+ # Make the API request
172
+ return sendAPIRequest(resturl, restpayload)
173
+ end
174
+
175
+ #
176
+ # perform_IssueTextKeyFromUserId - Send the perform_IssueTextKeyFromUserId API Request
177
+ # and return the results
178
+ #
179
+ # * *Args* :
180
+ # - +userID+ -> The unique identifier that was used when the user was registered with
181
+ # - +isHashed+ -> Indicates if the userID was hashed before the user was registered.
182
+ #
183
+ # * *Returns* :
184
+ # - +The returned JSON payload as a string
185
+ #
186
+ def perform_IssueTextKeyFromUserId(userID,
187
+ isHashed)
188
+
189
+ # Build the URL
190
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "issueTextKeyFromUserId";
191
+
192
+ # Setup the payload
193
+ restpayload = { :DataIn => { :apiKey => @authKey, :userID => userID, :isHashed => isHashed } }
194
+
195
+ # Make the API request
196
+ return sendAPIRequest(resturl, restpayload)
197
+ end
198
+
199
+ #
200
+ # perform_IssueTextKeyFromUserId - Send the perform_IssueTextKeyFromUserId API Request
201
+ # and return the results
202
+ #
203
+ # * *Args* :
204
+ # - +retrieveBy+ -> Defines the type of retrieve option to use
205
+ # - +cellNumber+ -> The Cell Number that you are registering
206
+ # - +suppl1+ -> The suppl1 field value that you are searching for
207
+ # - +suppl2+ -> The suppl2 field value that you are searching fo
208
+ #
209
+ # * *Returns* :
210
+ # - +The returned JSON payload as a string
211
+ #
212
+ def perform_getTextKeyRegistration(retrieveBy,
213
+ cellNumber,
214
+ suppl1,
215
+ suppl2)
216
+
217
+ # Build the URL
218
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "getTextKeyRegistration";
219
+
220
+ # Setup the payload
221
+ restpayload = { :DataIn => { :apiKey => @authKey, :retrieveBy => retrieveBy, :cellNumber => cellNumber, :suppl1 => suppl1, :suppl2 => suppl2 } }
222
+
223
+ # Make the API request
224
+ return sendAPIRequest(resturl, restpayload)
225
+ end
226
+
227
+ #
228
+ # perform_DoesRegistrationUserIDExist - Send the perform_DoesRegistrationUserIDExist API Request
229
+ # and return the results
230
+ #
231
+ # * *Args* :
232
+ # - +userID+ -> The unique identifier that was used when the user was registered with
233
+ # - +isHashed+ -> Indicates if the userID was hashed before the user was registered.
234
+ #
235
+ # * *Returns* :
236
+ # - +The returned JSON payload as a string
237
+ #
238
+ def perform_DoesRegistrationUserIDExist(userID,
239
+ isHashed)
240
+
241
+ # Build the URL
242
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "doesRegistrationUserIdExist";
243
+
244
+ # Setup the payload
245
+ restpayload = { :DataIn => { :apiKey => @authKey, :userID => userID, :isHashed => isHashed } }
246
+
247
+ # Make the API request
248
+ return sendAPIRequest(resturl, restpayload)
249
+ end
250
+
251
+ #
252
+ # perform_DoesRegistrationCellNumberExist - Send the doesRegistrationcellNumberExist API Request
253
+ # and return the results
254
+ #
255
+ # * *Args* :
256
+ # - +cellNumber+ -> The Cell Number that was used when the user was registered with
257
+ #
258
+ # * *Returns* :
259
+ # - +The returned JSON payload as a string
260
+ #
261
+ def perform_DoesRegistrationCellNumberExist(cellNumber)
262
+
263
+ # Build the URL
264
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "doesRegistrationcellNumberExist";
265
+
266
+ # Setup the payload
267
+ restpayload = { :DataIn => { :apiKey => @authKey, :cellNumber => cellNumber } }
268
+
269
+ # Make the API request
270
+ return sendAPIRequest(resturl, restpayload)
271
+ end
272
+
273
+ #
274
+ # perform_CreateNewCellNumberProxy - Send the createNewcellNumberProxy API Request
275
+ # and return the results
276
+ #
277
+ # * *Args* :
278
+ # - +cellNumber+ -> The Cell Number that was used when the user was registered with
279
+ #
280
+ # * *Returns* :
281
+ # - +The returned JSON payload as a string
282
+ #
283
+ def perform_CreateNewCellNumberProxy(cellNumber)
284
+
285
+ # Build the URL
286
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "createNewcellNumberProxy";
287
+
288
+ # Setup the payload
289
+ restpayload = { :DataIn => { :apiKey => @authKey, :truecellNumber => cellNumber } }
290
+
291
+ # Make the API request
292
+ return sendAPIRequest(resturl, restpayload)
293
+ end
294
+
295
+ #
296
+ # perform_RemoveTempAPIKey - Send the removetempAPIKey API Request
297
+ # and return the results
298
+ #
299
+ # * *Args* :
300
+ # - +tempAPIKey+ -> The temporary API Key to remove
301
+ # - +minutesDuration+ -> This parameter is ignored but still must still be passed in with an integer value
302
+ #
303
+ # * *Returns* :
304
+ # - +The returned JSON payload as a string
305
+ #
306
+ def perform_RemoveTempAPIKey(tempAPIKey,
307
+ minutesDuration)
308
+
309
+ # Build the URL
310
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "removetempAPIKey";
311
+
312
+ # Setup the payload
313
+ restpayload = { :DataIn => { :apiKey => @authKey, :apiKey => tempAPIKey, :minutesDuration => minutesDuration } }
314
+
315
+ # Make the API request
316
+ return sendAPIRequest(resturl, restpayload)
317
+ end
318
+
319
+ #
320
+ # perform_IssueTextKeyFromCellNumber - Send the issueTextKeyFromcellNumber API Request
321
+ # and return the results
322
+ #
323
+ # * *Args* :
324
+ # - +cellNumber+ -> The Cell Number that was used when the user was registered with
325
+ #
326
+ # * *Returns* :
327
+ # - +The returned JSON payload as a string
328
+ #
329
+ def perform_IssueTextKeyFromCellNumber(cellNumber)
330
+
331
+ # Build the URL
332
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "issueTextKeyFromcellNumber";
333
+
334
+ # Setup the payload
335
+ restpayload = { :DataIn => { :apiKey => @authKey, :cellNumber => cellNumber } }
336
+
337
+ # Make the API request
338
+ return sendAPIRequest(resturl, restpayload)
339
+ end
340
+
341
+ #
342
+ # perform_PollForIncomingTextKey - Send the pollForIncomingTextKey API Request
343
+ # and return the results
344
+ #
345
+ # * *Args* :
346
+ # - +TextKey+ -> The TextKey to check for
347
+ #
348
+ # * *Returns* :
349
+ # - +The returned JSON payload as a string
350
+ #
351
+ def perform_PollForIncomingTextKey(textKey)
352
+
353
+ # Build the URL
354
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "pollForIncomingTextKey";
355
+
356
+ # Setup the payload
357
+ restpayload = { :DataIn => { :apiKey => @authKey, :textKey => textKey } }
358
+
359
+ # Make the API request
360
+ return sendAPIRequest(resturl, restpayload)
361
+ end
362
+
363
+ #
364
+ # perform_ValidateTextKeyFromUserId - Send the validateTextKeyFromUserId API Request
365
+ # and return the results
366
+ #
367
+ # * *Args* :
368
+ # - +userID+ -> The unique identifier that was used when the user was registered with
369
+ # - +TextKey+ -> The TextKey to check for
370
+ # - +TextKeyVC+ -> The TextKey Validation Code to check for
371
+ # - +isHashed+ -> Indicates if the userID was hashed before the user was registered.
372
+ #
373
+ # * *Returns* :
374
+ # - +The returned JSON payload as a string
375
+ #
376
+ def perform_ValidateTextKeyFromUserId(userID,
377
+ textKey,
378
+ textKeyVC,
379
+ isHashed)
380
+
381
+ # Build the URL
382
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "validateTextKeyFromUserId";
383
+
384
+ # Setup the payload
385
+ restpayload = { :DataIn => { :apiKey => @authKey, :userID => userID, :textKey => textKey, :validationCode => textKeyVC, :isHashed => isHashed } }
386
+
387
+ # Make the API request
388
+ return sendAPIRequest(resturl, restpayload)
389
+ end
390
+
391
+ #
392
+ # perform_ValidateTextKeyFromCellNumber - Send the validateTextKeyFromcellNumber API Request
393
+ # and return the results
394
+ #
395
+ # * *Args* :
396
+ # - +cellNumber+ -> The Cell Number that was used when the user was registered with
397
+ # - +TextKey+ -> The TextKey to check for
398
+ # - +TextKeyVC+ -> The TextKey Validation Code to check for
399
+ #
400
+ # * *Returns* :
401
+ # - +The returned JSON payload as a string
402
+ #
403
+ def perform_ValidateTextKeyFromCellNumber(cellNumber,
404
+ textKey,
405
+ textKeyVC)
406
+
407
+ # Build the URL
408
+ resturl = TextkeyRest::Config::TK_BASE[:rest_url] + "validateTextKeyFromcellNumber";
409
+
410
+ # Setup the payload
411
+ restpayload = { :DataIn => { :apiKey => @authKey, :cellNumber => cellNumber, :textKey => textKey, :validationCode => textKeyVC } }
412
+
413
+ # Make the API request
414
+ return sendAPIRequest(resturl, restpayload)
415
+ end
416
+
417
+ end
@@ -0,0 +1,3 @@
1
+ module TextkeyRest
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,10 @@
1
+ # TestAll.rb
2
+ #
3
+ Dir.glob("test_*.rb") do |file|
4
+ puts "--------------------------------------------------------------------------------"
5
+ puts "Testing: " + file
6
+ puts "--------------------------------------------------------------------------------"
7
+
8
+ # process
9
+ load file
10
+ end
@@ -0,0 +1,5 @@
1
+ module TextkeyRestTest
2
+ module Config
3
+ API_KEY = "9021fa44-f1bc-4590-b975-42fee031e078"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # TestCreateNewCellNumberProxy.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ cellNumber = "8054100577"
15
+
16
+ # Make the API Call
17
+ response = textkey.perform_CreateNewCellNumberProxy(cellNumber)
18
+
19
+ # Pull out the data from the response
20
+ response_obj = JSON.parse(response)
21
+ response_data = response_obj['d']
22
+
23
+ # Display the response
24
+ puts "TextKey Results:"
25
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,25 @@
1
+ # TestDoesRegistrationCellNumberExist.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ cellNumber = "8054100577"
15
+
16
+ # Make the API Call
17
+ response = textkey.perform_DoesRegistrationCellNumberExist(cellNumber)
18
+
19
+ # Pull out the data from the response
20
+ response_obj = JSON.parse(response)
21
+ response_data = response_obj['d']
22
+
23
+ # Display the response
24
+ puts "TextKey Results:"
25
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,26 @@
1
+ # TestDoesRegistrationUserIdExist.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ userID = "Stan"
15
+ isHashed = "TRUE"
16
+
17
+ # Make the API Call
18
+ response = textkey.perform_DoesRegistrationUserIDExist(userID, isHashed)
19
+
20
+ # Pull out the data from the response
21
+ response_obj = JSON.parse(response)
22
+ response_data = response_obj['d']
23
+
24
+ # Display the response
25
+ puts "TextKey Results:"
26
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,25 @@
1
+ # TextGetTempAPI_Key.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ minutesDuration = 2
15
+
16
+ # Make the API Call
17
+ response = textkey.perform_GetTempAPI_Key(minutesDuration)
18
+
19
+ # Pull out the data from the response
20
+ response_obj = JSON.parse(response)
21
+ response_data = response_obj['d']
22
+
23
+ # Display the response
24
+ puts "TextKey Results:"
25
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,31 @@
1
+ # TestGetTextKeyRegistration.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ retrieveBy = 0
15
+ cellNumber = "8054100577"
16
+ suppl1 = ""
17
+ suppl2 = ""
18
+
19
+ # Make the API Call
20
+ response = textkey.perform_getTextKeyRegistration(retrieveBy,
21
+ cellNumber,
22
+ suppl1,
23
+ suppl2)
24
+
25
+ # Pull out the data from the response
26
+ response_obj = JSON.parse(response)
27
+ response_data = response_obj['d']
28
+
29
+ # Display the response
30
+ puts "TextKey Results:"
31
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,25 @@
1
+ # TestIssueTextKeyFromCellNumber.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ cellNumber = "8054100577"
15
+
16
+ # Make the API Call
17
+ response = textkey.perform_IssueTextKeyFromCellNumber(cellNumber)
18
+
19
+ # Pull out the data from the response
20
+ response_obj = JSON.parse(response)
21
+ response_data = response_obj['d']
22
+
23
+ # Display the response
24
+ puts "TextKey Results:"
25
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,26 @@
1
+ # TestIssueTextKeyFromUserId.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ userID = "Stan"
15
+ isHashed = "TRUE"
16
+
17
+ # Make the API Call
18
+ response = textkey.perform_IssueTextKeyFromUserId(userID, isHashed)
19
+
20
+ # Pull out the data from the response
21
+ response_obj = JSON.parse(response)
22
+ response_data = response_obj['d']
23
+
24
+ # Display the response
25
+ puts "TextKey Results:"
26
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,25 @@
1
+ # TestPollForIncomingTextKey.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ textKey = "5347788"
15
+
16
+ # Make the API Call
17
+ response = textkey.perform_PollForIncomingTextKey(textKey)
18
+
19
+ # Pull out the data from the response
20
+ response_obj = JSON.parse(response)
21
+ response_data = response_obj['d']
22
+
23
+ # Display the response
24
+ puts "TextKey Results:"
25
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,47 @@
1
+ # TestRegisterTextKeyUser.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ command = 0
15
+ cellNumber = "8054100577"
16
+ ownerFName = ""
17
+ ownerLName = ""
18
+ suppl1 = ""
19
+ suppl2 = ""
20
+ userID = ""
21
+ isHashed = "TRUE"
22
+ pinCode = ""
23
+ distressPinCode = ""
24
+ textKeyMode = 0
25
+ receiveMode = 0
26
+
27
+ # Make the API Call
28
+ response = textkey.perform_registerTextKeyUser(command,
29
+ cellNumber,
30
+ ownerFName,
31
+ ownerLName,
32
+ suppl1,
33
+ suppl2,
34
+ userID,
35
+ isHashed,
36
+ pinCode,
37
+ distressPinCode,
38
+ textKeyMode,
39
+ receiveMode)
40
+
41
+ # Pull out the data from the response
42
+ response_obj = JSON.parse(response)
43
+ response_data = response_obj['d']
44
+
45
+ # Display the response
46
+ puts "TextKey Results:"
47
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,63 @@
1
+ # TestRegisterTextKeyUserCSA.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ command = 1
15
+ cellNumber = "8054100577"
16
+ ownerFName = "Stan"
17
+ ownerLName = ""
18
+ suppl1 = "Suppl1"
19
+ suppl2 = "Suppl2"
20
+ ownerBirthDate = "01/01/1970"
21
+ ownerGender = "M"
22
+ userID = "Stan"
23
+ isHashed = "TRUE"
24
+ pinCode = "1234"
25
+ distressPinCode = "4321"
26
+ q1 = "Question 1"
27
+ a1 = "Answer 1"
28
+ q2 = "Question 2"
29
+ a2 = "Answer 2"
30
+ q3 = "Question 3"
31
+ a3 = "Answer 3"
32
+ textKeyMode = 0
33
+ receiveMode = 0
34
+
35
+ # Make the API Call
36
+ response = textkey.perform_registerTextKeyUserCSA(command,
37
+ cellNumber,
38
+ ownerFName,
39
+ ownerLName,
40
+ suppl1,
41
+ suppl2,
42
+ ownerBirthDate,
43
+ ownerGender,
44
+ userID,
45
+ isHashed,
46
+ pinCode,
47
+ distressPinCode,
48
+ q1,
49
+ a1,
50
+ q2,
51
+ a2,
52
+ q3,
53
+ a3,
54
+ textKeyMode,
55
+ receiveMode)
56
+
57
+ # Pull out the data from the response
58
+ response_obj = JSON.parse(response)
59
+ response_data = response_obj['d']
60
+
61
+ # Display the response
62
+ puts "TextKey Results:"
63
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,37 @@
1
+ # TestRemoveTempAPIKey.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ minutesDuration = 2
15
+
16
+ # Make the API Call to get an API Key
17
+ response = textkey.perform_GetTempAPI_Key(minutesDuration)
18
+
19
+ # If show flag is set show the return payload
20
+ if response
21
+ # Pull out the data from the response
22
+ response_obj = JSON.parse(response)
23
+ tempAPI = response_obj['d']['apiKey']
24
+
25
+ if response
26
+ # Make the API Call to release the API Key
27
+ response = textkey.perform_RemoveTempAPIKey(tempAPI, minutesDuration)
28
+
29
+ # Pull out the data from the response
30
+ response_obj = JSON.parse(response)
31
+ response_data = response_obj['d']
32
+ end
33
+ end
34
+
35
+ # Display the response
36
+ puts "TextKey Results:"
37
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,29 @@
1
+ # TestValidateTextKeyFromCellNumber.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ cellNumber = "8054100577"
15
+ textKey = "4819399"
16
+ textKeyVC = "57G14"
17
+
18
+ # Make the API Call
19
+ response = textkey.perform_ValidateTextKeyFromCellNumber(cellNumber,
20
+ textKey,
21
+ textKeyVC)
22
+
23
+ # Pull out the data from the response
24
+ response_obj = JSON.parse(response)
25
+ response_data = response_obj['d']
26
+
27
+ # Display the response
28
+ puts "TextKey Results:"
29
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,30 @@
1
+ # TestValidateTextKeyFromUserId.rb
2
+ #
3
+ require 'json'
4
+ require 'textkey_rest'
5
+ require './configuration'
6
+
7
+ # Setup
8
+ apiKey = TextkeyRestTest::Config::API_KEY
9
+
10
+ # Create the textkey object
11
+ textkey = TextKeyRest.new(apiKey, false)
12
+
13
+ # Setup the API parameters
14
+ userID = "Stan"
15
+ isHashed = "TRUE"
16
+ textKey = "5233019"
17
+ textKeyVC = "4DE30"
18
+
19
+ # Make the API Call
20
+ response = textkey.perform_ValidateTextKeyFromUserId(userID,
21
+ textKey,
22
+ textKeyVC,
23
+ isHashed)
24
+ # Pull out the data from the response
25
+ response_obj = JSON.parse(response)
26
+ response_data = response_obj['d']
27
+
28
+ # Display the response
29
+ puts "TextKey Results:"
30
+ puts JSON.pretty_generate response_data
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'textkey_rest/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "textkey_rest"
8
+ spec.version = TextkeyRest::VERSION
9
+ spec.authors = ["Stan Shaul"]
10
+ spec.email = ["textkey@textpower.com"]
11
+ spec.summary = %q{Allows use of all of TextKey's REST API calls.}
12
+ spec.description = %q{TextKey is an award winning, patent-pending next-generation omni-factor authenticationTM (seven-factors of authentication) system that is highly secure, simple to install and easy to use. It can be used to protect web sites, mobile devices, virtual private networks (VPNs) or any other data that requires privacy, confidentiality or restricted access. It works by having users send a simple text message (SMS) FROM their cell phones INTO the TextKeyTM system to authenticate their identity.}
13
+ spec.homepage = "http://developer.textkey.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "json", "~> 0"
24
+ spec.add_development_dependency "rest-client", "~> 0"
25
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: textkey_rest
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Stan Shaul
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: TextKey is an award winning, patent-pending next-generation omni-factor
70
+ authenticationTM (seven-factors of authentication) system that is highly secure,
71
+ simple to install and easy to use. It can be used to protect web sites, mobile devices,
72
+ virtual private networks (VPNs) or any other data that requires privacy, confidentiality
73
+ or restricted access. It works by having users send a simple text message (SMS)
74
+ FROM their cell phones INTO the TextKeyTM system to authenticate their identity.
75
+ email:
76
+ - textkey@textpower.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - lib/textkey_rest.rb
87
+ - lib/textkey_rest/configuration.rb
88
+ - lib/textkey_rest/textkey.rb
89
+ - lib/textkey_rest/version.rb
90
+ - test/TestAll.rb
91
+ - test/configuration.rb
92
+ - test/test_CreateNewCellNumberProxy.rb
93
+ - test/test_DoesRegistrationCellNumberExist.rb
94
+ - test/test_DoesRegistrationUserIdExist.rb
95
+ - test/test_GetTempAPIKey.rb
96
+ - test/test_GetTextKeyRegistration.rb
97
+ - test/test_IssueTextKeyFromCellNumber.rb
98
+ - test/test_IssueTextKeyFromUserId.rb
99
+ - test/test_PollForIncomingTextKey.rb
100
+ - test/test_RegisterTextKeyUser.rb
101
+ - test/test_RegisterTextKeyUserCSA.rb
102
+ - test/test_RemoveTempAPIKey.rb
103
+ - test/test_ValidateTextKeyFromCellNumber.rb
104
+ - test/test_ValidateTextKeyFromUserId.rb
105
+ - textkey_rest.gemspec
106
+ homepage: http://developer.textkey.com
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Allows use of all of TextKey's REST API calls.
130
+ test_files:
131
+ - test/TestAll.rb
132
+ - test/configuration.rb
133
+ - test/test_CreateNewCellNumberProxy.rb
134
+ - test/test_DoesRegistrationCellNumberExist.rb
135
+ - test/test_DoesRegistrationUserIdExist.rb
136
+ - test/test_GetTempAPIKey.rb
137
+ - test/test_GetTextKeyRegistration.rb
138
+ - test/test_IssueTextKeyFromCellNumber.rb
139
+ - test/test_IssueTextKeyFromUserId.rb
140
+ - test/test_PollForIncomingTextKey.rb
141
+ - test/test_RegisterTextKeyUser.rb
142
+ - test/test_RegisterTextKeyUserCSA.rb
143
+ - test/test_RemoveTempAPIKey.rb
144
+ - test/test_ValidateTextKeyFromCellNumber.rb
145
+ - test/test_ValidateTextKeyFromUserId.rb