Sha256: da80597c1cd738df210e5053c983a240e2ef19db6c44562b8032fb8fd3b57fe8
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
module Myfinance class Request def initialize(args) @args = args end def run request.run request.response end private attr_reader :args def request @request ||= Typhoeus::Request.new(args[:url], options) end def options { method: args[:method], params: args[:params], body: body, headers: headers, accept_encoding: "gzip" }.reject {|k,v| v.nil?} end def headers headers = args.fetch(:headers) { {} } { "Accept" => "application/json", "Content-Type" => "application/json", "User-Agent" => args[:user_agent], "Authorization" => "Basic #{authorization_hash}" }.merge(headers) end def body body = args[:body] body = MultiJson.dump(body) if body.is_a?(Hash) body end def authorization_hash ::Base64.strict_encode64("#{args[:token]}:X") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
myfinance-0.2.0 | lib/myfinance/request.rb |
myfinance-0.1.0 | lib/myfinance/request.rb |