rubycicd_uat 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,344 @@
1
+ require 'json'
2
+
3
+
4
+ module Response
5
+ class Resp
6
+ def initialize(paramlist)
7
+ @paramlist = paramlist
8
+ puts @paramlist
9
+ end
10
+
11
+ def get_mode
12
+ modes = @paramlist['MODE'].to_s
13
+ return modes unless modes.empty?
14
+ end
15
+
16
+ def get_version
17
+ vers = @paramlist['VERS'].to_s
18
+ return vers unless vers.empty?
19
+ end
20
+
21
+ def get_transaction_id
22
+ tran = @paramlist['TRAN'].to_s
23
+ return tran unless tran.empty?
24
+ end
25
+
26
+ def get_merchant_id
27
+ merchantid = @paramlist['MERC'].to_s
28
+ return merchantid unless merchantid.empty?
29
+ end
30
+
31
+ def get_session_id
32
+ sessionid = @paramlist['SESS'].to_s
33
+ return sessionid unless sessionid.empty?
34
+ end
35
+
36
+ def get_order_number
37
+ orderno = @paramlist['ORDR'].to_s
38
+ return orderno unless orderno.empty?
39
+ end
40
+
41
+ def get_site
42
+ site = @paramlist['SITE'].to_s
43
+ return site unless site.empty?
44
+ end
45
+
46
+ def get_auto
47
+ auto = @paramlist['AUTO'].to_s
48
+ return auto unless auto.empty?
49
+ end
50
+
51
+ def get_score
52
+ score = @paramlist['SCOR'].to_s
53
+ return score unless score.empty?
54
+ end
55
+
56
+ def get_omniscore
57
+ omniscore = @paramlist['OMNISCORE'].to_s
58
+ return omniscore unless omniscore.empty?
59
+ end
60
+
61
+ def get_geox
62
+ geox = @paramlist['GEOX'].to_s
63
+ return geox unless geox.empty?
64
+ end
65
+
66
+ def get_brand
67
+ brand = @paramlist['BRND'].to_s
68
+ return brand unless brand.empty?
69
+ end
70
+
71
+ def get_velo
72
+ velo = @paramlist['VELO'].to_s
73
+ return velo unless velo.empty?
74
+ end
75
+
76
+ def get_vmax
77
+ vmax = @paramlist['VMAX'].to_s
78
+ return vmax unless vmax.empty?
79
+ end
80
+
81
+ def get_network
82
+ network = @paramlist['NETW'].to_s
83
+ return network unless network.empty?
84
+ end
85
+
86
+ def get_region
87
+ region = @paramlist['REGN'].to_s
88
+ return region unless region.empty?
89
+ end
90
+
91
+ def get_kaptcha
92
+ kapt = @paramlist['KAPT'].to_s
93
+ return kapt unless kapt.empty?
94
+ end
95
+
96
+ def get_proxy
97
+ proxy = @paramlist['PROXY'].to_s
98
+ return proxy unless proxy.empty?
99
+ end
100
+
101
+ def get_emails
102
+ email = @paramlist['EMAILS'].to_s
103
+ return email unless email.empty?
104
+ end
105
+
106
+ def get_http_country
107
+ httmcountry = @paramlist['HTTP_COUNTRY'].to_s
108
+ return httmcountry unless httmcountry.empty?
109
+ end
110
+
111
+ def get_timezone
112
+ timezone = @paramlist['TIMEZONE'].to_s
113
+ return timezone unless timezone.empty?
114
+ end
115
+
116
+ def get_cards
117
+ cards = @paramlist['CARDS'].to_s
118
+ return cards unless cards.empty?
119
+ end
120
+
121
+ def get_pc_remote
122
+ pcremote = @paramlist['PC_REMOTE'].to_s
123
+ return pcremote unless pcremote.empty?
124
+ end
125
+
126
+ def get_devices
127
+ devices = @paramlist['DEVICES'].to_s
128
+ return devices unless devices.empty?
129
+ end
130
+
131
+ def get_device_layers
132
+ device_layers = @paramlist['DEVICE_LAYERS'].to_s
133
+ return device_layers unless device_layers.empty?
134
+ end
135
+
136
+ def get_mobile_forwarder
137
+ mobile_forwarder = @paramlist['MOBILE_FORWARDER'].to_s
138
+ return mobile_forwarder unless mobile_forwarder.empty?
139
+ end
140
+
141
+ def get_voice_device
142
+ voicedevice = @paramlist['VOICE_DEVICE'].to_s
143
+ return voicedevice unless voicedevice.empty?
144
+ end
145
+
146
+ def get_local_time
147
+ localtime = @paramlist['LOCALTIME'].to_s
148
+ return localtime unless localtime.empty?
149
+ end
150
+
151
+ def get_mobile_type
152
+ mobiletype = @paramlist['MOBILE_TYPE'].to_s
153
+ return mobiletype unless mobiletype.empty?
154
+ end
155
+
156
+ def get_fingerprint
157
+ fingerprint = @paramlist['FINGERPRINT'].to_s
158
+ return fingerprint unless fingerprint.empty?
159
+ end
160
+
161
+ def get_flash
162
+ flash = @paramlist['FLASH'].to_s
163
+ return flash unless flash.empty?
164
+ end
165
+
166
+ def get_language
167
+ language = @paramlist['LANGUAGE'].to_s
168
+ return language unless language.empty?
169
+ end
170
+
171
+ def get_country
172
+ country = @paramlist['COUNTRY'].to_s
173
+ return country unless country.empty?
174
+ end
175
+
176
+ def get_javascript
177
+ javascript = @paramlist['JAVASCRIPT'].to_s
178
+ return javascript unless javascript.empty?
179
+ end
180
+
181
+ def get_cookies
182
+ cookie = @paramlist['COOKIES'].to_s
183
+ return cookie unless cookie.empty?
184
+ end
185
+
186
+ def get_mobile_device
187
+ mobiledevice = @paramlist['MOBILE_DEVICE'].to_s
188
+ return mobiledevice unless mobiledevice.empty?
189
+ end
190
+
191
+ def get_pierced_ipaddress
192
+ pip_address = @paramlist['PIP_IPAD'].to_s
193
+ return pip_address unless pip_address.empty?
194
+ end
195
+
196
+ def get_piercedipaddress_latitude
197
+ pip_lat = @paramlist['PIP_LAT'].to_s
198
+ return pip_lat unless pip_lat.empty?
199
+ end
200
+
201
+ def get_piercedipaddress_longitude
202
+ pip_long = @paramlist['PIP_LON'].to_s
203
+ return pip_long unless pip_long.empty?
204
+ end
205
+
206
+ def get_piercedipaddress_country
207
+ pip_country = @paramlist['PIP_COUNTRY'].to_s
208
+ return pip_country unless pip_country.empty?
209
+ end
210
+
211
+ def get_piercedipaddress_region
212
+ pip_region = @paramlist['PIP_REGION'].to_s
213
+ return pip_region unless pip_region.empty?
214
+ end
215
+
216
+ def get_piercedipaddress_city
217
+ pip_city = @paramlist['PIP_CITY'].to_s
218
+ return pip_city unless pip_city.empty?
219
+ end
220
+
221
+ def get_piercedipaddress_organization
222
+ pip_org = @paramlist['PIP_ORG'].to_s
223
+ return pip_org unless pip_org.empty?
224
+ end
225
+
226
+ def get_ipaddress
227
+ ip_ipad = @paramlist['IP_IPAD'].to_s
228
+ return ip_ipad unless ip_ipad.empty?
229
+ end
230
+
231
+ def get_ipaddress_latitude
232
+ ip_lat = @paramlist['IP_LAT'].to_s
233
+ return ip_lat unless ip_lat.empty?
234
+ end
235
+
236
+ def get_ipaddress_longitude
237
+ ip_long = @paramlist['IP_LON'].to_s
238
+ return ip_long unless ip_long.empty?
239
+ end
240
+
241
+ def get_ipaddress_country
242
+ ip_country = @paramlist['IP_COUNTRY'].to_s
243
+ return ip_country unless ip_country.empty?
244
+ end
245
+
246
+ def get_ipaddress_region
247
+ ip_region = @paramlist['IP_REGION'].to_s
248
+ return ip_region unless ip_region.empty?
249
+ end
250
+
251
+ def get_ipaddress_city
252
+ ip_city = @paramlist['IP_CITY'].to_s
253
+ return ip_city unless ip_city.empty?
254
+ end
255
+
256
+ def get_ipaddress_organization
257
+ ip_org = @paramlist['IP_ORG'].to_s
258
+ return ip_org unless ip_org.empty?
259
+ end
260
+
261
+ def get_date_device_firstseen
262
+ ddfs = @paramlist['DDFS'].to_s
263
+ return ddfs unless ddfs.empty?
264
+ end
265
+
266
+ def get_useragent_string
267
+ user_agent = @paramlist['UAS'].to_s
268
+ return user_agent unless user_agent.empty?
269
+ end
270
+
271
+ def get_devicescreen_resolution
272
+ dsr = @paramlist['DSR'].to_s
273
+ return dsr unless dsr.empty?
274
+ end
275
+
276
+ def get_os
277
+ os = @paramlist['OS'].to_s
278
+ return os unless os.empty?
279
+ end
280
+
281
+ def get_browser
282
+ browser = @paramlist['BROWSER'].to_s
283
+ return browser unless browser.empty?
284
+ end
285
+
286
+ def get_numberrules_triggered
287
+ no_rules_triggered = @paramlist['RULES_TRIGGERED'].to_s
288
+ no_rules_triggered
289
+ end
290
+
291
+ def get_rules_triggered
292
+ rules_count = get_numberrules_triggered
293
+ rules = []
294
+ (0..rules_count.to_i - 1).each do |i|
295
+ ruleid = @paramlist["RULE_ID_#{i}"]
296
+ rules[ruleid.to_i] = @paramlist["RULE_DESCRIPTION_#{i}"]
297
+ end
298
+ rules.compact
299
+ end
300
+
301
+ def get_warning_count
302
+ warning_count = @paramlist['WARNING_COUNT'].to_s
303
+ warning_count
304
+ end
305
+
306
+ def get_warnings
307
+ warnings = []
308
+ warningcount = get_warning_count
309
+ (0..warningcount.to_i - 1).each do |i|
310
+ warnings = @paramlist["WARNING_#{i}"]
311
+ end
312
+ warnings.compact
313
+ end
314
+
315
+ def get_error_count
316
+ errorcount = @paramlist['ERROR_COUNT'].to_s
317
+ errorcount
318
+ end
319
+
320
+ def geterrors
321
+ errors = []
322
+ error_count = get_error_count
323
+ (0..error_count.to_i - 1).each do |i|
324
+ errors = @paramlist["ERROR_#{i}"]
325
+ end
326
+ errors.compact
327
+ end
328
+
329
+ def get_numbercounters_triggered
330
+ count_triggered = @paramlist['COUNTERS_TRIGGERED'].to_s
331
+ count_triggered
332
+ end
333
+
334
+ def get_counters_triggered
335
+ counters = []
336
+ numCounters = get_numbercounters_triggered
337
+ (0..numCounters.to_i - 1).each do |i|
338
+ countername = @paramlist["COUNTER_NAME_#{i}"]
339
+ counters[countername.to_s] = @paramlist["COUNTER_VALUE_#{i}"]
340
+ end
341
+ counters.compact
342
+ end
343
+ end
344
+ end
@@ -0,0 +1,36 @@
1
+ module Kount
2
+ ##
3
+ # This class handles cart data until the get_request is ready
4
+ # to push the data into the form fields
5
+ class Cart
6
+ attr_accessor :items
7
+
8
+ # Initialize cart object
9
+ def initialize
10
+ @items = []
11
+ end
12
+
13
+ # Add cart items
14
+ #
15
+ # @param item [String] Cart item name
16
+ # @param type [String] Cart type name
17
+ # @param desc [String] Cart item long description
18
+ # @param quant [String] Cart item quantity
19
+ # @param price [String] Cart item price in cents
20
+ def add_item(item, type, desc, quant, price)
21
+ @items << { TYPE: type,
22
+ DESC: desc,
23
+ ITEM: item,
24
+ QUANT: quant,
25
+ PRICE: price }
26
+ end
27
+
28
+ # Initialize an Inquiry object
29
+ #
30
+ # @param param [String] Param type: :TYPE, :DESC, :ITEM, :PRICE, or :QUANT
31
+ # @return [Array] Ordered array of the cart contents for each param type
32
+ def get_item(param)
33
+ @items.collect { |item| item[param] }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,147 @@
1
+ require 'kount/security_mash'
2
+ require 'kount/cart'
3
+ require 'kount/request'
4
+ require 'kount/request/update'
5
+ require 'kount/request/inquiry'
6
+ require 'rest-client'
7
+ require 'uri'
8
+ require 'kount/utils/khash'
9
+ require 'logger'
10
+
11
+
12
+ module Kount
13
+ ##
14
+ # This class is where the primary interaction with
15
+ # the merchant integration will take place.
16
+ class Client
17
+ # Tells the RIS server to respond in JSON instead of key/value pairs
18
+ # This cannot be overridden.
19
+ RESPONSE_FORMAT = 'JSON'
20
+
21
+ # RIS Version. Can be overridden my merchant if required.
22
+ DEFAULT_VERSION = '0700'
23
+
24
+ # Default endpoint for production. Used by the DEFAULT_OPTIONS
25
+ ENDPOINT_PROD = 'https://risk.kount.net'
26
+
27
+ # Default endpoint for test. Used by the TEST_DEFAULT_OPTIONS
28
+ ENDPOINT_TEST = 'https://risk.test.kount.net'
29
+
30
+ # Default params for production
31
+ PROD_DEFAULT_OPTIONS = {
32
+ endpoint: ENDPOINT_PROD,
33
+ version: DEFAULT_VERSION,
34
+ is_test: false,
35
+ timeout: 10
36
+ }
37
+
38
+ # Default params for test if is_test is TRUE
39
+ TEST_DEFAULT_OPTIONS = {
40
+ endpoint: ENDPOINT_TEST,
41
+ version: DEFAULT_VERSION,
42
+ timeout: 10
43
+ }
44
+
45
+ # Initialize a client object
46
+ #
47
+ # Example usage
48
+ # {:merchant_id => "123456", :key => "trhvihsrihsta7ftadk6edkre7y8..."}
49
+ #
50
+ # @param params [Hash] Hash with merchant_id, ksalt and key, plus any
51
+ # other optional params
52
+ def initialize(params = {})
53
+ @logger = Logger.new("Logs.log")
54
+ @options = {}
55
+ if params[:is_test]
56
+ @options.merge!(TEST_DEFAULT_OPTIONS)
57
+ else
58
+ @options.merge!(PROD_DEFAULT_OPTIONS)
59
+ end
60
+ @options.merge!(params)
61
+ @logger.info("Options Params : #{@options}")
62
+ end
63
+
64
+ # Makes the call to the Kount RIS server
65
+ #
66
+ # @param request [Kount::Request] Kount inquiry or update object
67
+ # @return [Hash] RIS response formatted into a native hash
68
+ def get_response(request)
69
+ params = prepare_request_params(request)
70
+ response = {}
71
+ begin
72
+ response = RestClient::Resource.new(
73
+ endpoint,
74
+ verify_ssl: verify_ssl_option, timeout: timeout, log: @logger
75
+ ).post params, x_kount_api_key: key
76
+
77
+ @logger.info("Response Object : #{JSON.parse(response)}")
78
+ JSON.parse(response)
79
+ rescue StandardError
80
+ # RIS errors do not come back as JSON, so just pass them along raw.
81
+ # @logger.error("Error : Network Timeout Getting #{response} Response.
82
+ # Your Timeout option valus is #{timeout},
83
+ # Use Default timeout which is 10 sec.")
84
+ if response.empty?
85
+ @logger.debug("Network Timeout Getting #{response} Response.
86
+ Current Timeout option valus is #{timeout},
87
+ Use Default timeout which is 10 sec.")
88
+ else
89
+ @logger.error("#{response}")
90
+ end
91
+ response
92
+ end
93
+ end
94
+
95
+ # Give the request object what it needs to know to process the params
96
+ # to send to RIS.
97
+ def prepare_request_params(request)
98
+ request.prepare_params(version, merchant_id, RESPONSE_FORMAT, ksalt)
99
+ end
100
+
101
+ # Kount Merchant ID
102
+ def merchant_id
103
+ @options[:merchant_id]
104
+ end
105
+
106
+ # RIS Interface Version
107
+ def version
108
+ @options[:version]
109
+ end
110
+
111
+ # RIS Endpoint URL
112
+ def endpoint
113
+ @options[:endpoint]
114
+ end
115
+
116
+ # Timeout settings
117
+ def timeout
118
+ @options[:timeout]
119
+ end
120
+
121
+ # Merchant API for RIS acess
122
+ def key
123
+ @options[:key]
124
+ end
125
+
126
+ # Secret Kount salt for KHASH
127
+ def ksalt
128
+ @options[:ksalt]
129
+ end
130
+
131
+ # Is test or production setting
132
+ def test?
133
+ @options[:is_test]
134
+ end
135
+
136
+ private
137
+
138
+ # Helper method to turn on/off the SSL cert verify based on is_test config
139
+ def verify_ssl_option
140
+ if test?
141
+ OpenSSL::SSL::VERIFY_NONE
142
+ else
143
+ OpenSSL::SSL::VERIFY_PEER
144
+ end
145
+ end
146
+ end
147
+ end