Sha256: a99f774132512385949075c765d5423bd6ab8a7fb28c65ba2c9b13be35a74d5f
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
module SantanderChile module ApiClient class Resource include Template attr_reader :client def initialize(client) @client = client end private def post_request(url, body: {}, headers: {}) handle_response client.connection.post(url, body: body, headers: headers) end def handle_response(response) case response.status when 400 raise Error, "Your request was malformed. #{response.body["error"]}" when 401 raise Error, "You did not supply valid authentication credentials. #{response.body["error"]}" when 403 raise Error, "You are not allowed to perform that action. #{response.body["error"]}" when 404 raise Error, "No results were found for your request. #{response.body["error"]}" #when 429 # raise Error, "Your request exceeded the API rate limit. #{response.body["error"]}" when 500 raise Error, "We were unable to perform the request due to server-side problems. #{response.body["error"]}" #when 503 # raise Error, "You have been rate limited for sending more than X requests per second. #{response.body["error"]}" end response end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
santander_chile-api_client-1.1.1 | lib/santander_chile/api_client/resources/resource.rb |
santander_chile-api_client-1.1.0 | lib/santander_chile/api_client/resources/resource.rb |