slidepay 0.0.2

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.
@@ -0,0 +1,463 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '../'))
2
+
3
+ require "codeclimate-test-reporter"
4
+ CodeClimate::TestReporter.start
5
+
6
+ require 'multi_json'
7
+ require 'pathname'
8
+
9
+ if Pathname.new('environment.rb').exist?
10
+ require 'environment'
11
+ end
12
+
13
+ module SlidePay
14
+ TEST_EMAIL = ENV["email"]
15
+ TEST_PASSWORD = ENV["password"]
16
+ TEST_API_KEY = ENV["api_key"]
17
+ end
18
+
19
+ def a_response_object(json=nil)
20
+ if json
21
+ SlidePay::Response.new(json)
22
+ else
23
+ SlidePay::Response.new(successful_object_response)
24
+ end
25
+ end
26
+
27
+ def set_global_api_key_from_env
28
+ SlidePay.api_key = SlidePay::TEST_API_KEY
29
+ end
30
+
31
+ def set_global_api_key
32
+ SlidePay.api_key = "TEST_API_KEY"
33
+ end
34
+
35
+ def set_global_token
36
+ SlidePay.token = "TEST_TOKEN"
37
+ end
38
+
39
+ def set_global_endpoint
40
+ SlidePay.endpoint = "TEST_ENDPOINT"
41
+ end
42
+
43
+ def clear_auth_data
44
+ SlidePay.api_key = nil
45
+ SlidePay.token = nil
46
+ end
47
+
48
+ def clear_endpoint
49
+ SlidePay.endpoint = nil
50
+ end
51
+
52
+ def clear_slidepay
53
+ SlidePay.token = nil
54
+ SlidePay.api_key = nil
55
+ SlidePay.endpoint = nil
56
+ end
57
+
58
+ def object_from_response(json)
59
+ MultiJson.decode(json)
60
+ end
61
+
62
+
63
+ def successful_deletion_response
64
+ <<-eos
65
+ {
66
+ "success": true,
67
+ "custom": null,
68
+ "operation": "DELETE person",
69
+ "endpoint": "https://dev.getcube.com:65532",
70
+ "timezone": "",
71
+ "method": "delete",
72
+ "obj": "person",
73
+ "id": 398,
74
+ "milliseconds": "3376.74",
75
+ "data": "Success",
76
+ "data_md5": "02CDC0A219FB85758EC8A9693478EC26"
77
+ }
78
+ eos
79
+ end
80
+
81
+ def failed_deletion_response
82
+ <<-eos
83
+ {
84
+ "success": false,
85
+ "custom": null,
86
+ "operation": "DELETE person",
87
+ "endpoint": "https://dev.getcube.com:65532",
88
+ "timezone": "",
89
+ "method": "delete",
90
+ "obj": "person",
91
+ "id": 0,
92
+ "milliseconds": "47.85",
93
+ "data": {
94
+ "error_code": "1",
95
+ "error_file": "l_delete_handler.cs",
96
+ "error_text": "The requested object was not found."
97
+ },
98
+ "data_md5": null
99
+ }
100
+ eos
101
+ end
102
+
103
+ def successful_object_response
104
+ <<-eos
105
+ {
106
+ "success": true,
107
+ "custom": null,
108
+ "operation": "GET person",
109
+ "endpoint": "https://dev.getcube.com:65532",
110
+ "timezone": null,
111
+ "method": "GET",
112
+ "obj": null,
113
+ "id": 0,
114
+ "milliseconds": "31.25",
115
+ "data": {
116
+ "id": "1",
117
+ "name": "Dog the Bounty Hunter"
118
+ },
119
+ "data_md5": "15D13569C731E9D77ABDCB3348A2EBDD"
120
+ }
121
+ eos
122
+ end
123
+
124
+ def failed_object_response
125
+ <<-eos
126
+ {
127
+ "success": false,
128
+ "custom": null,
129
+ "operation": "GET person",
130
+ "endpoint": "https://dev.getcube.com:65532",
131
+ "timezone": null,
132
+ "method": "GET",
133
+ "obj": null,
134
+ "id": 0,
135
+ "milliseconds": "31.25",
136
+ "data": {
137
+ "error_code": "4",
138
+ "error_file": "i_http_handler.cs",
139
+ "error_text": "ERROR_TEXT"
140
+ },
141
+ "data_md5": "15D13569C731E9D77ABDCB3348A2EBDD"
142
+ }
143
+ eos
144
+ end
145
+
146
+ def successful_endpoint_response
147
+ <<-eos
148
+ {
149
+ "success": true,
150
+ "custom": null,
151
+ "operation": "GET endpoint",
152
+ "endpoint": "https://api.getcube.com:65532",
153
+ "timezone": null,
154
+ "method": "GET",
155
+ "obj": null,
156
+ "id": 0,
157
+ "milliseconds": "31.25",
158
+ "data": "https://api.getcube.com:65532/rest.svc/API/",
159
+ "data_md5": "15D13569C731E9D77ABDCB3348A2EBDD"
160
+ }
161
+ eos
162
+ end
163
+
164
+ def failed_endpoint_response
165
+ <<-eos
166
+ {
167
+ "success": false,
168
+ "custom": null,
169
+ "operation": "GET endpoint",
170
+ "endpoint": null,
171
+ "timezone": null,
172
+ "method": "GET",
173
+ "obj": null,
174
+ "id": 0,
175
+ "milliseconds": "0.00",
176
+ "data": {
177
+ "error_code": "4",
178
+ "error_file": "i_http_handler.cs",
179
+ "error_text": "Unable to process your request at this time. Unable to locate an endpoint for your account."
180
+ },
181
+ "data_md5": null
182
+ }
183
+ eos
184
+ end
185
+
186
+ def successful_array_response
187
+ <<-eos
188
+ {
189
+ "success": true,
190
+ "custom": null,
191
+ "operation": "GET customer",
192
+ "endpoint": "https://dev.getcube.com:65532",
193
+ "timezone": "",
194
+ "method": "get",
195
+ "obj": null,
196
+ "id": 0,
197
+ "milliseconds": "15.62",
198
+ "data": [
199
+ {
200
+ "customer_id": 211,
201
+ "company_id": 213,
202
+ "location_id": 285,
203
+ "user_master_id": 297,
204
+ "first_name": "Father",
205
+ "middle_name": "",
206
+ "last_name": "Yummy Bears",
207
+ "company_name": "",
208
+ "address_1": "",
209
+ "address_2": "",
210
+ "address_3": "",
211
+ "city": "",
212
+ "state": "",
213
+ "postal_code": "",
214
+ "country": "",
215
+ "email": "",
216
+ "home_phone": "",
217
+ "cell_phone": "1234567890",
218
+ "twitter_id": "",
219
+ "facebook_email": "",
220
+ "homepage": "",
221
+ "active": 1,
222
+ "created": "2013-09-06T04:05:49",
223
+ "last_update": "2013-09-06T04:05:49"
224
+ },
225
+ {
226
+ "customer_id": 210,
227
+ "company_id": 213,
228
+ "location_id": 285,
229
+ "user_master_id": 297,
230
+ "first_name": "Customer",
231
+ "middle_name": "",
232
+ "last_name": "Robot Rabbit",
233
+ "company_name": "",
234
+ "address_1": "",
235
+ "address_2": "",
236
+ "address_3": "",
237
+ "city": "",
238
+ "state": "",
239
+ "postal_code": "",
240
+ "country": "",
241
+ "email": "",
242
+ "home_phone": "",
243
+ "cell_phone": "2222222222",
244
+ "twitter_id": "",
245
+ "facebook_email": "",
246
+ "homepage": "",
247
+ "active": 1,
248
+ "created": "2013-09-05T16:57:33",
249
+ "last_update": "2013-09-05T16:57:33"
250
+ }
251
+ ],
252
+ "data_md5": "2B4A5BF8C70C97022E4824643E96C695"
253
+ }
254
+ eos
255
+ end
256
+
257
+ def bank_account_array_response
258
+ <<-eos
259
+ {
260
+ "success": true,
261
+ "custom": null,
262
+ "operation": "GET bank_account",
263
+ "endpoint": "https://dev.getcube.com:65532",
264
+ "timezone": "",
265
+ "method": "get",
266
+ "obj": null,
267
+ "id": 0,
268
+ "milliseconds": "15.62",
269
+ "data": [
270
+ {
271
+ "bank_account_id": 211,
272
+ "company_id": 213,
273
+ "location_id": 285,
274
+ "user_master_id": 297,
275
+ "account_first_name": "Father",
276
+ "account_last_name": "Yummy Bears",
277
+ "name": "ACCOUNT 211",
278
+ "routing_number": "211123456",
279
+ "account_number": "211211211",
280
+ "created": "2013-09-06T04:05:49",
281
+ "last_update": "2013-09-06T04:05:49"
282
+ },
283
+ {
284
+ "customer_id": 210,
285
+ "company_id": 213,
286
+ "location_id": 285,
287
+ "user_master_id": 297,
288
+ "account_first_name": "Customer",
289
+ "account_last_name": "Robot Rabbit",
290
+ "name": "ACCOUNT 210",
291
+ "routing_number": "210123456",
292
+ "account_number": "210210210",
293
+ "created": "2013-09-05T16:57:33",
294
+ "last_update": "2013-09-05T16:57:33"
295
+ }
296
+ ],
297
+ "data_md5": "2B4A5BF8C70C97022E4824643E96C695"
298
+ }
299
+ eos
300
+ end
301
+
302
+ def successful_token_detail_response
303
+ <<-eos
304
+ {
305
+ "success": true,
306
+ "custom": null,
307
+ "operation": "GET token detail",
308
+ "endpoint": "https://dev.getcube.com:65532",
309
+ "timezone": "",
310
+ "method": "get",
311
+ "obj": null,
312
+ "id": 0,
313
+ "milliseconds": "15.62",
314
+ "data": {
315
+ "created": "2013-09-15T01:11:20",
316
+ "server_name": "cubeuswdev1",
317
+ "endpoint": "https://dev.getcube.com:65532",
318
+ "email": "matt@slidepay.com",
319
+ "password": null,
320
+ "ip_address": "12.12.12.12",
321
+ "random": null,
322
+ "timezone": "",
323
+ "company_id": 99,
324
+ "company_name": "AWESOME CO.",
325
+ "location_id": 99,
326
+ "location_name": "AWESOME LOC.",
327
+ "user_master_id": 99,
328
+ "first_name": "Matt",
329
+ "last_name": "Rothstein",
330
+ "is_clerk": 1,
331
+ "is_locmgr": 1,
332
+ "is_comgr": 1,
333
+ "is_admin": 0,
334
+ "is_isv": 0
335
+ },
336
+ "data_md5": "2B4A5BF8C70C97022E4824643E96C695"
337
+ }
338
+ eos
339
+ end
340
+
341
+ def failed_token_detail_response
342
+ <<-eos
343
+ {
344
+ "success": false,
345
+ "custom": null,
346
+ "operation": "get /API/token/detail",
347
+ "endpoint": "https://dev.getcube.com:65532",
348
+ "timezone": null,
349
+ "method": "get",
350
+ "obj": null,
351
+ "id": 0,
352
+ "milliseconds": "15.62",
353
+ "data": {
354
+ "error_code": "6",
355
+ "error_file": "i_http_handler.cs",
356
+ "error_text": "Token not present. Please login."
357
+ },
358
+ "data_md5": null
359
+ }
360
+ eos
361
+ end
362
+
363
+ def successful_payment_response
364
+ <<-eos
365
+ {
366
+ "success": true,
367
+ "custom": null,
368
+ "operation": "POST payment simple",
369
+ "endpoint": "https://dev.getcube.com:65532",
370
+ "timezone": "",
371
+ "method": "post",
372
+ "obj": null,
373
+ "id": 0,
374
+ "milliseconds": "15.62",
375
+ "data": {
376
+ "payment_id": "12",
377
+ "order_master_id": "10",
378
+ "method": "CreditCard",
379
+ "amount": "1.22"
380
+ },
381
+ "data_md5": "2B4A5BF8C70C97022E4824643E96C695"
382
+ }
383
+ eos
384
+ end
385
+
386
+ def failed_payment_response
387
+ <<-eos
388
+ {
389
+ "success": false,
390
+ "custom": null,
391
+ "operation": "POST payment simple",
392
+ "endpoint": "https://dev.getcube.com:65532",
393
+ "timezone": null,
394
+ "method": "post",
395
+ "obj": null,
396
+ "id": 0,
397
+ "milliseconds": "15.62",
398
+ "data": {
399
+ "status_message": "TEST_PAYMENT_FAILED_MESSAGE",
400
+ "order_master_id": "10",
401
+ "method": "CreditCard",
402
+ "amount": "1.22"
403
+ },
404
+ "data_md5": null
405
+ }
406
+ eos
407
+ end
408
+
409
+ def api_key_json
410
+ <<-eos
411
+ {
412
+ "api_key_id": 99,
413
+ "company_id": 99,
414
+ "location_id": 99,
415
+ "user_master_id": 99,
416
+ "guid": "TEST_API_KEY",
417
+ "active": 1,
418
+ "notes": "TEST DESCRIPTION",
419
+ "created": "2013-09-15T05:58:16",
420
+ "last_update": "2013-09-15T05:58:16"
421
+ }
422
+ eos
423
+ end
424
+
425
+ def successful_token_response
426
+ <<-eos
427
+ {
428
+ "success": true,
429
+ "custom": null,
430
+ "operation": "GET login",
431
+ "endpoint": "https://dev.getcube.com:65532",
432
+ "timezone": null,
433
+ "method": "get",
434
+ "obj": null,
435
+ "id": 0,
436
+ "milliseconds": "0.00",
437
+ "data": "TOKEN_FROM_THE_BEYOND",
438
+ "data_md5": "2A28E72629AA92B440F3A74F7CA4F9D5"
439
+ }
440
+ eos
441
+ end
442
+
443
+ def failed_token_response
444
+ <<-eos
445
+ {
446
+ "success": false,
447
+ "custom": null,
448
+ "operation": "GET login",
449
+ "endpoint": "https://dev.getcube.com:65532",
450
+ "timezone": null,
451
+ "method": "get",
452
+ "obj": null,
453
+ "id": 0,
454
+ "milliseconds": "0.00",
455
+ "data": {
456
+ "error_code": "5",
457
+ "error_file": "l_login.cs",
458
+ "error_text": "Authorization failed."
459
+ },
460
+ "data_md5": null
461
+ }
462
+ eos
463
+ end