Sha256: f53dd03a5ffc9129a1cfcde7718e83c42031d784e08ca62e5437411a52d1fc75
Contents?: true
Size: 798 Bytes
Versions: 2
Compression:
Stored size: 798 Bytes
Contents
require "uri" module Fulfillment class Request attr_reader :path, :params def initialize(path, params={}) @path = path @params = params end def call(method) response = client.public_send(method, uri, params) response.on_error(&:raise_errors) end [:get, :post, :put, :patch, :delete].each do |method| define_method(method) do call(method) end end def uri @uri ||= build_uri end private def build_uri URI.parse(endpoint).tap do |uri| uri.merge!(path) end end def endpoint return Fulfillment.config.endpoint if Fulfillment.config.endpoint =~ /^http/ "http://#{Fulfillment.config.endpoint}" end def client Fulfillment.client end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fulfillment-api-1.1.9 | lib/fulfillment/request.rb |
fulfillment-api-1.1.7 | lib/fulfillment/request.rb |