Sha256: 3e853473c00aee21ba52c305a2f0a09384e34b8bd3ba07edb64a69866665cce4
Contents?: true
Size: 707 Bytes
Versions: 2
Compression:
Stored size: 707 Bytes
Contents
require "myfinance/request" require "myfinance/response" module Myfinance class Http attr_reader :token def initialize(token) @token = token end %w[get post delete put].each do |m| define_method(m) do |path, options = {}, &block| send_request(m.to_sym, path, options, &block) end end private def send_request(method, path, options, &block) request = Request.new(options.merge!({ method: method, token: token, url: "#{Myfinance.configuration.url}#{path}", user_agent: Myfinance.configuration.user_agent })) response = Response.new(request.run) response.resolve!(&block) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
myfinance-0.2.0 | lib/myfinance/http.rb |
myfinance-0.1.0 | lib/myfinance/http.rb |