module BitBucket::Request
Defines HTTP verbs
Constants
- METHODS
- METHODS_WITH_BODIES
Public Instance Methods
delete_request(path, params={}, options={})
click to toggle source
# File lib/bitbucket_rest_api/request.rb, line 27 def delete_request(path, params={}, options={}) request(:delete, path, params, options) end
get_request(path, params={}, options={})
click to toggle source
# File lib/bitbucket_rest_api/request.rb, line 10 def get_request(path, params={}, options={}) request(:get, path, params, options) end
patch_request(path, params={}, options={})
click to toggle source
# File lib/bitbucket_rest_api/request.rb, line 15 def patch_request(path, params={}, options={}) request(:patch, path, params, options) end
post_request(path, params={}, options={})
click to toggle source
# File lib/bitbucket_rest_api/request.rb, line 19 def post_request(path, params={}, options={}) request(:post, path, params, options) end
put_request(path, params={}, options={})
click to toggle source
# File lib/bitbucket_rest_api/request.rb, line 23 def put_request(path, params={}, options={}) request(:put, path, params, options) end
request(method, path, params, options={})
click to toggle source
# File lib/bitbucket_rest_api/request.rb, line 31 def request(method, path, params, options={}) if !METHODS.include?(method) raise ArgumentError, "unkown http method: #{method}" end # _extract_mime_type(params, options) puts "EXECUTED: #{method} - #{path} with #{params} and #{options}" if ENV['DEBUG'] conn = connection(options) path = (conn.path_prefix + path).gsub(/\/\//,'/') if conn.path_prefix != '/' response = conn.send(method) do |request| request['Authorization'] = "Bearer #{new_access_token}" unless new_access_token.nil? case method.to_sym when *(METHODS - METHODS_WITH_BODIES) request.body = params.delete('data') if params.has_key?('data') request.url(path, params) when *METHODS_WITH_BODIES request.path = path unless params.empty? # data = extract_data_from_params(params) # request.body = MultiJson.dump(data) request.body = MultiJson.dump(params) end end end response.body end