lib/gateway/Gateway.rb in mundipagg_sdk-1.2.4 vs lib/gateway/Gateway.rb in mundipagg_sdk-1.3.0
- old
+ new
@@ -563,52 +563,58 @@
response
end
# funcao de post generica
def postRequest(payload, url)
- response = nil
begin
response = RestClient.post(url, payload, headers=@@SERVICE_HEADERS)
rescue RestClient::ExceptionWithResponse => err
- return err.response
+ response = err.response
end
- json_response = JSON.load response
- json_response
+
+ JSON.load response
+ rescue JSON::ParserError => err
+ response
end
# funcao patch generica
def patchRequest(payload, url)
begin
response = RestClient.patch(url, payload, headers=@@SERVICE_HEADERS)
rescue RestClient::ExceptionWithResponse => err
- return err.response
+ response = err.response
end
- json_response = JSON.load response
- json_response
+
+ JSON.load response
+ rescue JSON::ParserError => err
+ response
end
# funcao de delete generica
def deleteRequest(url)
begin
response = RestClient.delete(url, headers=@@SERVICE_HEADERS)
rescue RestClient::ExceptionWithResponse => err
- return err.response
+ response = err.response
end
- json_response = JSON.load response
- json_response
+
+ JSON.load response
+ rescue JSON::ParserError => err
+ response
end
# funcao get generica
def getRequest(url)
- response = nil
begin
response = RestClient.get(url, headers=@@SERVICE_HEADERS)
rescue RestClient::ExceptionWithResponse => err
- return err.response
+ response = err.response
end
- json_response = JSON.load response
- json_response
+
+ JSON.load response
+ rescue JSON::ParserError => err
+ response
end
def getReportFile(url)
begin
response = RestClient.get(url, headers={:MerchantKey => "#{@merchantKey}"})
@@ -616,6 +622,6 @@
return err.response
end
return response
end
end
-end
\ No newline at end of file
+end