module Locked::API

this class is responsible for making requests to api

this class is responsible for making requests to api

Constants

HANDLED_ERRORS

Errors we handle internally

Public Class Methods

request(command, headers = {}) click to toggle source
# File lib/locked/api.rb, line 20
def request(command, headers = {})
  raise Locked::ConfigurationError, 'configuration is not valid' unless Locked.config.valid?

  begin
    Locked::API::Response.call(
      Locked::API::Request.call(
        command,
        Locked.config.api_key,
        headers
      )
    )
  rescue *HANDLED_ERRORS => error
    # @note We need to initialize the error, as the original error is a cause for this
    # custom exception. If we would do it the default Ruby way, the original error
    # would get converted into a string
    raise Locked::RequestError.new(error) # rubocop:disable Style/RaiseArgs
  end
end