19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/digifi_api/base.rb', line 19
def self.post(resource_uri, elements)
if DigifiApi.configuration.configured?
RestClient::Request.execute(:method => :post, url: (DigifiApi.configuration.base_uri + resource_uri), payload: payload(elements), headers: , use_ssl: true, verify_ssl: OpenSSL::SSL::VERIFY_NONE) do |response, request, result|
case response.code
when 200 return response
when 400 return { error: "#{response.code}: The request was incorrectly formed" }
when 401 return { error: "#{response.code}: The authentication credentials were incorrect" }
when 404 return { error: "#{response.code}: The requested strategy or model cannot be found" }
when 500 return { error: "#{response.code}: There was an error on the server" }
else
return { error: "#{response.code}" }
end
end
else
return { error: "Configuration must be valid before making a request" }
end
end
|