Class: BankVal::GoValidate
- Inherits:
-
Object
- Object
- BankVal::GoValidate
- Defined in:
- lib/BankVal.rb
Overview
BankValUK::GoValidate
Class to make calls to Unified Softwares web services
Instance Method Summary collapse
-
#failover(ser_url, post_data) ⇒ Object
Method to make backup REST web service calls and return response if call to the main data centre fails this method is called to make a call to the back up data centre.
-
#validate(ser_url, post_data) ⇒ Object
Method to make REST web service calls and return response if call to the main data centre fails the back up method is called to make a call to the back up data centre.
Instance Method Details
#failover(ser_url, post_data) ⇒ Object
Method to make backup REST web service calls and return response if call to the main data centre fails this method is called to make a call to the back up data centre
Parameters
-
Serv_url is the services part of the URL for the REST call
-
post_data is the data for the call
Returns
The response from the web service as a string in json format or.. error message in case of error
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/BankVal.rb', line 154 def failover(ser_url, post_data) @base_url = "https://www.unifiedservices.co.uk/services/enhanced/" uriobj = URI.parse(@base_url) full_path = uriobj.path + ser_url conn = Net::HTTP.new(uriobj.host, uriobj.port) conn.use_ssl = true conn.verify_mode = OpenSSL::SSL::VERIFY_NONE begin req = Net::HTTP::Post.new(full_path, 'Content-Type' => 'application/json') req.body = post_data webresponse = conn.request(req) rescue Exception => err print(err) return "NETWORK ERROR" end return webresponse.body end |
#validate(ser_url, post_data) ⇒ Object
Method to make REST web service calls and return response if call to the main data centre fails the back up method is called to make a call to the back up data centre
Parameters
-
ser_url is the services part of the URL for the REST call
-
post_data is the data for the call
Returns
The response from the web service in JSON format
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/BankVal.rb', line 121 def validate(ser_url, post_data) @base_url = "https://www.unifiedsoftware.co.uk/services/enhanced/" uriobj = URI.parse(@base_url) full_path = uriobj.path + ser_url conn = Net::HTTP.new(uriobj.host, uriobj.port) conn.use_ssl = true conn.verify_mode = OpenSSL::SSL::VERIFY_NONE begin req = Net::HTTP::Post.new(full_path, 'Content-Type' => 'application/json') req.body = post_data webresponse = conn.request(req) rescue Exception => err return self.failover(ser_url, post_data) end if webresponse == nil return "Unknown Error-Check Local Network" end return webresponse.body end |