Sha256: 8989c31fc5d5d7b895479c6a48fffa25a9e603b55e269854168695cdb72d7aee
Contents?: true
Size: 957 Bytes
Versions: 8
Compression:
Stored size: 957 Bytes
Contents
module Emites 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, userpwd: token, 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] }.merge(headers) end def body body = args[:body] body = MultiJson.dump(body) if body.is_a?(Hash) body end def token "#{args[:token]}:x" end end end
Version data entries
8 entries across 8 versions & 1 rubygems