module Mattermost::Request
Public Instance Methods
delete(path, options = {}, &block)
click to toggle source
# File lib/mattermost/request.rb, line 28 def delete(path, options = {}, &block) connection.send(:delete) do |request| request.path = api(path) request.body = options[:body] if options.key? :body end end
get(path, options = {}, &block)
click to toggle source
# File lib/mattermost/request.rb, line 7 def get(path, options = {}, &block) puts "get #{path}, #{options}" connection.send(:get) do |request| request.url api(path), options end end
post(path, options = {}, &block)
click to toggle source
# File lib/mattermost/request.rb, line 14 def post(path, options = {}, &block) connection.send(:post) do |request| request.path = api(path) request.body = options[:body] if options.key? :body end end
put(path, options = {}, &block)
click to toggle source
# File lib/mattermost/request.rb, line 21 def put(path, options = {}, &block) connection.send(:put) do |request| request.path = api(path) request.body = options[:body] if options.key? :body end end
Private Instance Methods
api(path)
click to toggle source
# File lib/mattermost/request.rb, line 47 def api(path) "#{subdir}/api/v4#{path}" end
connection()
click to toggle source
# File lib/mattermost/request.rb, line 37 def connection Faraday::Connection.new({ :headers => self.headers, :url => server }) do |connection| connection.response :json connection.adapter :httpclient end end