Sha256: 43cfb99d40286c97d972be630f247f974cae86cc6e1c8cea9201167d5ebaa3d8
Contents?: true
Size: 798 Bytes
Versions: 15
Compression:
Stored size: 798 Bytes
Contents
require "myfinance/request" require "myfinance/response" module Myfinance class Http attr_reader :token, :account_id def initialize(token, account_id = nil) @token = token @account_id = account_id 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, account_id: account_id ) ) Response.new(request.run).resolve!(&block) end end end
Version data entries
15 entries across 15 versions & 1 rubygems