Sha256: 349c8d486fbd4199d58640681f8077a368eb6e270dfded268c023b8e69a180b6
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module SchoologyClient class Resource attr_reader :client def initialize(client) @client = client end def post_request(url, body:, headers: {}) handle_response client.connection.post(url, body, 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 20 requests per second. #{response.body["error"]}" end response end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
strongmind-schoology-client-0.1.0 | lib/schoology-client/resource.rb |