Sha256: 8d91fbaab06b02b5a7377f852aedd10ebae04f3a6abc6ab3f1783e3fdc6eb8ad

Contents?: true

Size: 612 Bytes

Versions: 6

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true

module ApiProxy
  class Client
    def initialize(options = {})
      @options = { namespace: :default }.merge(options)
    end

    [:get, :post, :patch, :put, :delete].each do |type|
      define_method type do |path, options = {}|
        perform_request(type, path, options)
      end
    end

    private

    def perform_request(type, path, options)
      options = @options.merge(options)

      config = ApiProxy.configuration(options[:namespace])
      url = File.join(config.api_url, path)

      ApiProxy::SignedRequest.new(type, url, options).perform
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
api_proxy-0.2.9 lib/api_proxy/client.rb
api_proxy-0.2.8 lib/api_proxy/client.rb
api_proxy-0.2.7 lib/api_proxy/client.rb
api_proxy-0.2.6 lib/api_proxy/client.rb
api_proxy-0.2.5 lib/api_proxy/client.rb
api_proxy-0.2.4 lib/api_proxy/client.rb