Sha256: 49de03f8fc7c0efd13c7ed16d78d9128e18a1dd3c286b6d0486e4cb3d1fa27fe
Contents?: true
Size: 842 Bytes
Versions: 6
Compression:
Stored size: 842 Bytes
Contents
module MyMoip class Request include HTTParty attr_reader :id, :response def initialize(id) @id = id end def api_call(params, opts = {}) opts[:logger] ||= MyMoip.logger opts[:username] ||= MyMoip.token opts[:password] ||= MyMoip.key opts[:logger].info "New #{self.class} being sent to MoIP." opts[:logger].debug "#{self.class} of ##{@id} with #{params.inspect}" url = MyMoip.api_url + params.delete(:path) params[:basic_auth] = { username: opts[:username], password: opts[:password] } @response = HTTParty.send params.delete(:http_method), url, params opts[:logger].debug "#{self.class} of ##{@id} to #{url} had response #{@response.inspect}" end end end requests = Dir[File.dirname(__FILE__) + "/requests/*.rb"] requests.each { |f| require f }
Version data entries
6 entries across 6 versions & 1 rubygems