Skip to content
This repository
Browse code

make changes to allow active merchant to not use the configuration

object, and instead pass all options in.
  • Loading branch information...
commit b24f3c939a9295ce2787958bc441a7fc40523cb7 1 parent be24770
Gregory Dake authored March 02, 2012
7  lib/Communications.rb
@@ -33,12 +33,11 @@ class Communications
33 33
   ##For http or https post with or without a proxy
34 34
   def Communications.http_post(post_data,config_hash)
35 35
 
36  
-    #setup optional proxy
37  
-    proxy_addr = (config_hash['proxy_addr'] or nil)
38  
-    proxy_port = ((config_hash['proxy_port']).to_i or nil)
  36
+    proxy_addr = config_hash['proxy_addr']
  37
+    proxy_port = config_hash['proxy_port']
  38
+    litle_url = config_hash['url']
39 39
 
40 40
     # setup https or http post
41  
-    litle_url = (config_hash['url'] or 'https://cert.litle.com/vap/communicator/online')
42 41
     uri = URI.parse(litle_url)
43 42
 
44 43
     http_post = Net::HTTP::Post.new(uri.request_uri)
2  lib/Configuration.rb
@@ -38,7 +38,7 @@ def config
38 38
       end
39 39
       return YAML.load_file(config_file)
40 40
     rescue
41  
-      raise 'Cannot find  the configuration file, ' + config_file + ', Please run Setup.rb first'
  41
+      return {}
42 42
     end
43 43
 
44 44
   end
28  lib/LitleOnlineRequest.rb
@@ -372,9 +372,21 @@ def get_report_group(hash_in)
372 372
   end
373 373
 
374 374
   def authentication(hash_in)
  375
+    if(hash_in['user'] == nil)
  376
+      user = @config_hash['user']
  377
+    else
  378
+      user = hash_in['user']
  379
+    end
  380
+    
  381
+    if(hash_in['password'] == nil)
  382
+      password = @config_hash['password']
  383
+    else
  384
+      password = hash_in['password']
  385
+    end
  386
+    
375 387
     hash_out = {
376  
-      :user =>required_field(@config_hash['user']),
377  
-      :password =>required_field(@config_hash['password'])
  388
+      :user =>required_field(user),
  389
+      :password =>required_field(password)
378 390
     }
379 391
     Checker.required_missing(hash_out)
380 392
   end
@@ -388,8 +400,14 @@ def optional_field(value)
388 400
   end
389 401
 
390 402
   def build_full_hash(hash_in, merge_hash)
  403
+    if(hash_in['version'] == nil)
  404
+      version = @config_hash['version']
  405
+    else
  406
+      version = hash_in['version']
  407
+    end
  408
+
391 409
     litle_online_hash = {
392  
-      "@version"=> required_field(@config_hash['version']),
  410
+      "@version"=> required_field(version),
393 411
       "@xmlns"=> "http://www.litle.com/schema",
394 412
       "@merchantId"=> get_merchant_id(hash_in),
395 413
       :authentication => authentication(hash_in)
@@ -398,6 +416,10 @@ def build_full_hash(hash_in, merge_hash)
398 416
   end
399 417
 
400 418
   def get_common_attributes(hash_in)
  419
+    @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
  420
+    @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
  421
+    @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
  422
+    
401 423
     return {
402 424
       '@id' => hash_in['id'],
403 425
       '@customerId' => hash_in['customerId'],
2  test/functional/test_sale.rb
@@ -177,8 +177,6 @@ def test_invalid_embedded_field_values
177 177
   def test_simple_sale_with_card
178 178
     hash = {
179 179
       'merchantId'=>'101',
180  
-      'proxy_addr' => '10.1.2.254',
181  
-      'proxy_port' => '8080',
182 180
       'version'=>'8.8',
183 181
       'reportGroup'=>'Planets',
184 182
       'litleTxnId'=>'123456',

0 notes on commit b24f3c9

Please sign in to comment.
Something went wrong with that request. Please try again.