Sha256: 36e078b72de91d9ad12d01720ed093c61a79a906c0937ba9f6a0ba33209028c0
Contents?: true
Size: 695 Bytes
Versions: 1
Compression:
Stored size: 695 Bytes
Contents
# frozen_string_literal: true module Lokalise module BaseRequest include Lokalise::JsonHandler private # Get rid of double slashes in the `path`, leading and trailing slash def prepare(path) path.delete_prefix('/').gsub(%r{//}, '/').gsub(%r{/+\z}, '') end def raise_on_error!(status, body) respond_with_error(status, body) if status.between?(400, 599) || (body.respond_to?(:has_key?) && body.key?('error')) end def respond_with_error(code, body) raise(Lokalise::Error, body['error'] || body) unless Lokalise::Error::ERRORS.key? code raise Lokalise::Error::ERRORS[code].from_response(body) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-lokalise-api-5.0.0 | lib/ruby-lokalise-api/base_request.rb |