bitbucket_rest_api2 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +7 -0
  3. data/README.md +169 -0
  4. data/lib/bitbucket_rest_api.rb +90 -0
  5. data/lib/bitbucket_rest_api/api.rb +106 -0
  6. data/lib/bitbucket_rest_api/api/actions.rb +35 -0
  7. data/lib/bitbucket_rest_api/api_factory.rb +30 -0
  8. data/lib/bitbucket_rest_api/authorization.rb +34 -0
  9. data/lib/bitbucket_rest_api/client.rb +56 -0
  10. data/lib/bitbucket_rest_api/configuration.rb +106 -0
  11. data/lib/bitbucket_rest_api/connection.rb +98 -0
  12. data/lib/bitbucket_rest_api/constants.rb +58 -0
  13. data/lib/bitbucket_rest_api/core_ext/array.rb +7 -0
  14. data/lib/bitbucket_rest_api/core_ext/hash.rb +46 -0
  15. data/lib/bitbucket_rest_api/deprecation.rb +39 -0
  16. data/lib/bitbucket_rest_api/error.rb +38 -0
  17. data/lib/bitbucket_rest_api/error/bad_events.rb +9 -0
  18. data/lib/bitbucket_rest_api/error/bad_request.rb +12 -0
  19. data/lib/bitbucket_rest_api/error/blank_value.rb +9 -0
  20. data/lib/bitbucket_rest_api/error/client_error.rb +20 -0
  21. data/lib/bitbucket_rest_api/error/forbidden.rb +12 -0
  22. data/lib/bitbucket_rest_api/error/internal_server_error.rb +12 -0
  23. data/lib/bitbucket_rest_api/error/invalid_options.rb +18 -0
  24. data/lib/bitbucket_rest_api/error/no_events.rb +9 -0
  25. data/lib/bitbucket_rest_api/error/not_found.rb +12 -0
  26. data/lib/bitbucket_rest_api/error/required_params.rb +18 -0
  27. data/lib/bitbucket_rest_api/error/service_error.rb +19 -0
  28. data/lib/bitbucket_rest_api/error/service_unavailable.rb +12 -0
  29. data/lib/bitbucket_rest_api/error/unauthorized.rb +12 -0
  30. data/lib/bitbucket_rest_api/error/unknown_value.rb +18 -0
  31. data/lib/bitbucket_rest_api/error/unprocessable_entity.rb +12 -0
  32. data/lib/bitbucket_rest_api/error/validations.rb +18 -0
  33. data/lib/bitbucket_rest_api/invitations.rb +15 -0
  34. data/lib/bitbucket_rest_api/issues.rb +230 -0
  35. data/lib/bitbucket_rest_api/issues/comments.rb +118 -0
  36. data/lib/bitbucket_rest_api/issues/components.rb +106 -0
  37. data/lib/bitbucket_rest_api/issues/milestones.rb +107 -0
  38. data/lib/bitbucket_rest_api/normalizer.rb +27 -0
  39. data/lib/bitbucket_rest_api/parameter_filter.rb +32 -0
  40. data/lib/bitbucket_rest_api/repos.rb +264 -0
  41. data/lib/bitbucket_rest_api/repos/changesets.rb +54 -0
  42. data/lib/bitbucket_rest_api/repos/commits.rb +40 -0
  43. data/lib/bitbucket_rest_api/repos/default_reviewers.rb +59 -0
  44. data/lib/bitbucket_rest_api/repos/download.rb +21 -0
  45. data/lib/bitbucket_rest_api/repos/following.rb +39 -0
  46. data/lib/bitbucket_rest_api/repos/forks.rb +69 -0
  47. data/lib/bitbucket_rest_api/repos/keys.rb +87 -0
  48. data/lib/bitbucket_rest_api/repos/pull_request.rb +160 -0
  49. data/lib/bitbucket_rest_api/repos/services.rb +103 -0
  50. data/lib/bitbucket_rest_api/repos/sources.rb +39 -0
  51. data/lib/bitbucket_rest_api/repos/webhooks.rb +96 -0
  52. data/lib/bitbucket_rest_api/request.rb +76 -0
  53. data/lib/bitbucket_rest_api/request/basic_auth.rb +31 -0
  54. data/lib/bitbucket_rest_api/request/jsonize.rb +46 -0
  55. data/lib/bitbucket_rest_api/request/oauth.rb +53 -0
  56. data/lib/bitbucket_rest_api/response.rb +28 -0
  57. data/lib/bitbucket_rest_api/response/helpers.rb +21 -0
  58. data/lib/bitbucket_rest_api/response/jsonize.rb +30 -0
  59. data/lib/bitbucket_rest_api/response/mashify.rb +24 -0
  60. data/lib/bitbucket_rest_api/response/raise_error.rb +31 -0
  61. data/lib/bitbucket_rest_api/response/xmlize.rb +26 -0
  62. data/lib/bitbucket_rest_api/result.rb +140 -0
  63. data/lib/bitbucket_rest_api/user.rb +101 -0
  64. data/lib/bitbucket_rest_api/users.rb +24 -0
  65. data/lib/bitbucket_rest_api/users/account.rb +53 -0
  66. data/lib/bitbucket_rest_api/utils/url.rb +56 -0
  67. data/lib/bitbucket_rest_api/validations.rb +25 -0
  68. data/lib/bitbucket_rest_api/validations/format.rb +24 -0
  69. data/lib/bitbucket_rest_api/validations/presence.rb +25 -0
  70. data/lib/bitbucket_rest_api/validations/required.rb +44 -0
  71. data/lib/bitbucket_rest_api/validations/token.rb +43 -0
  72. data/lib/bitbucket_rest_api/version.rb +11 -0
  73. data/spec/bitbucket_rest_api/api/actions_spec.rb +17 -0
  74. data/spec/bitbucket_rest_api/api_factory_spec.rb +30 -0
  75. data/spec/bitbucket_rest_api/api_spec.rb +86 -0
  76. data/spec/bitbucket_rest_api/authorization_spec.rb +72 -0
  77. data/spec/bitbucket_rest_api/client_spec.rb +15 -0
  78. data/spec/bitbucket_rest_api/core_ext/array_spec.rb +12 -0
  79. data/spec/bitbucket_rest_api/core_ext/hash_spec.rb +49 -0
  80. data/spec/bitbucket_rest_api/deprecation_spec.rb +30 -0
  81. data/spec/bitbucket_rest_api/error/bad_events_spec.rb +10 -0
  82. data/spec/bitbucket_rest_api/error/blank_value_spec.rb +13 -0
  83. data/spec/bitbucket_rest_api/error/no_events_spec.rb +10 -0
  84. data/spec/bitbucket_rest_api/invitations_spec.rb +21 -0
  85. data/spec/bitbucket_rest_api/issues/comments_spec.rb +89 -0
  86. data/spec/bitbucket_rest_api/issues/components_spec.rb +88 -0
  87. data/spec/bitbucket_rest_api/issues/milestones_spec.rb +88 -0
  88. data/spec/bitbucket_rest_api/issues_spec.rb +90 -0
  89. data/spec/bitbucket_rest_api/normalizer_spec.rb +30 -0
  90. data/spec/bitbucket_rest_api/parameter_filter_spec.rb +41 -0
  91. data/spec/bitbucket_rest_api/repos/changesets_spec.rb +43 -0
  92. data/spec/bitbucket_rest_api/repos/commits_spec.rb +20 -0
  93. data/spec/bitbucket_rest_api/repos/default_reviewers_spec.rb +64 -0
  94. data/spec/bitbucket_rest_api/repos/download_spec.rb +9 -0
  95. data/spec/bitbucket_rest_api/repos/following_spec.rb +52 -0
  96. data/spec/bitbucket_rest_api/repos/forks_spec.rb +45 -0
  97. data/spec/bitbucket_rest_api/repos/keys_spec.rb +72 -0
  98. data/spec/bitbucket_rest_api/repos/pull_request_spec.rb +288 -0
  99. data/spec/bitbucket_rest_api/repos/sources_spec.rb +77 -0
  100. data/spec/bitbucket_rest_api/repos/webhooks_spec.rb +245 -0
  101. data/spec/bitbucket_rest_api/repos_spec.rb +157 -0
  102. data/spec/bitbucket_rest_api/request/jsonize_spec.rb +18 -0
  103. data/spec/bitbucket_rest_api/request/oauth_spec.rb +27 -0
  104. data/spec/bitbucket_rest_api/request_spec.rb +81 -0
  105. data/spec/bitbucket_rest_api/response/jsonize_spec.rb +12 -0
  106. data/spec/bitbucket_rest_api/response/mashify_spec.rb +32 -0
  107. data/spec/bitbucket_rest_api/response/raise_error_spec.rb +41 -0
  108. data/spec/bitbucket_rest_api/user_spec.rb +77 -0
  109. data/spec/bitbucket_rest_api/utils/url_spec.rb +33 -0
  110. data/spec/bitbucket_rest_api/validations/format_spec.rb +29 -0
  111. data/spec/bitbucket_rest_api/validations/presence_spec.rb +12 -0
  112. data/spec/bitbucket_rest_api/validations/required_spec.rb +43 -0
  113. data/spec/bitbucket_rest_api/validations/token_spec.rb +16 -0
  114. data/spec/bitbucket_rest_api_spec.rb +17 -0
  115. data/spec/spec_helper.rb +24 -0
  116. metadata +373 -0
@@ -0,0 +1,103 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::Services < API
5
+
6
+ REQUIRED_KEY_PARAM_NAMES = %w[ type ].freeze
7
+
8
+ # List services
9
+ #
10
+ # = Examples
11
+ # bitbucket = BitBucket.new
12
+ # bitbucket.repos.services.list 'user-name', 'repo-name'
13
+ # bitbucket.repos.services.list 'user-name', 'repo-name' { |service| ... }
14
+ #
15
+ def list(user_name, repo_name, params={})
16
+ _update_user_repo_params(user_name, repo_name)
17
+ _validate_user_repo_params(user, repo) unless user? && repo?
18
+ normalize! params
19
+
20
+ response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/services", params)
21
+ return response unless block_given?
22
+ response.each { |el| yield el }
23
+ end
24
+ alias :all :list
25
+
26
+ # Gets a single service
27
+ #
28
+ # = Examples
29
+ # @bitbucket = BitBucket.new
30
+ # @bitbucket.repos.services.get 'user-name', 'repo-name', 109172378)
31
+ #
32
+ def get(user_name, repo_name, service_id, params={})
33
+ _update_user_repo_params(user_name, repo_name)
34
+ _validate_user_repo_params(user, repo) unless user? && repo?
35
+ _validate_presence_of(service_id)
36
+ normalize! params
37
+
38
+ get_request("/2.0/repositories/#{user}/#{repo.downcase}/services/#{service_id}", params)
39
+ end
40
+ alias :find :get
41
+
42
+ # Create a service
43
+ #
44
+ # = Inputs
45
+ # * <tt>:type</tt> - One of the supported services. The type is a case-insensitive value.
46
+ #
47
+ # = Examples
48
+ # bitbucket = BitBucket.new
49
+ # bitbucket.repos.services.create 'user-name', 'repo-name',
50
+ # "type" => "Basecamp",
51
+ # "Password" => "...",
52
+ # "Username" => "...",
53
+ # "Discussion URL" => "..."
54
+ #
55
+ def create(user_name, repo_name, params={})
56
+ _update_user_repo_params(user_name, repo_name)
57
+ _validate_user_repo_params(user, repo) unless user? && repo?
58
+ normalize! params
59
+ assert_required_keys(REQUIRED_KEY_PARAM_NAMES, params)
60
+
61
+ post_request("/2.0/repositories/#{user}/#{repo.downcase}/services", params)
62
+ end
63
+
64
+ # Edit a service
65
+ #
66
+ # = Inputs
67
+ # * <tt>:type</tt> - One of the supported services. The type is a case-insensitive value.
68
+ #
69
+ # = Examples
70
+ # bitbucket = BitBucket.new
71
+ # bitbucket.repos.services.edit 'user-name', 'repo-name', 109172378,
72
+ # "type" => "Basecamp",
73
+ # "Password" => "...",
74
+ # "Username" => "...",
75
+ # "Discussion URL" => "..."
76
+ #
77
+ def edit(user_name, repo_name, service_id, params={})
78
+ _update_user_repo_params(user_name, repo_name)
79
+ _validate_user_repo_params(user, repo) unless user? && repo?
80
+ _validate_presence_of(service_id)
81
+
82
+ normalize! params
83
+
84
+ put_request("/2.0/repositories/#{user}/#{repo.downcase}/services/#{service_id}", params)
85
+ end
86
+
87
+ # Delete service
88
+ #
89
+ # = Examples
90
+ # @bitbucket = BitBucket.new
91
+ # @bitbucket.repos.services.delete 'user-name', 'repo-name', 109172378
92
+ #
93
+ def delete(user_name, repo_name, service_id, params={})
94
+ _update_user_repo_params(user_name, repo_name)
95
+ _validate_user_repo_params(user, repo) unless user? && repo?
96
+ _validate_presence_of(service_id)
97
+ normalize! params
98
+
99
+ delete_request("/2.0/repositories/#{user}/#{repo.downcase}/services/#{service_id}", params)
100
+ end
101
+
102
+ end # Repos::Keys
103
+ end # BitBucket
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::Sources < API
5
+
6
+ # Gets a list of the src in a repository.
7
+ #
8
+ # = Examples
9
+ # @bitbucket = BitBucket.new
10
+ # @bitbucket.repos.sources.list 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6', 'app/contorllers/')
11
+ #
12
+ def list(user_name, repo_name, sha, path)
13
+ _update_user_repo_params(user_name, repo_name)
14
+ _validate_user_repo_params(user, repo) unless user? && repo?
15
+ _validate_presence_of(sha, path)
16
+
17
+ get_request("/2.0/repositories/#{user}/#{repo.downcase}/src/#{sha}/#{path}")
18
+ end
19
+ alias :all :list
20
+
21
+ # Gets information about an individual file. This method returns the file's
22
+ # size and contents. If the file is encoded, this method returns the files
23
+ # encoding; Currently, Bitbucket supports only base64 encoding.
24
+ #
25
+ # = Examples
26
+ # @bitbucket = BitBucket.new
27
+ # @bitbucket.repos.sources.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6', 'app/assets/images/logo.jpg')
28
+ #
29
+ def get(user_name, repo_name, sha, path)
30
+ _update_user_repo_params(user_name, repo_name)
31
+ _validate_user_repo_params(user, repo) unless user? && repo?
32
+ _validate_presence_of(sha, path)
33
+
34
+ get_request("/2.0/repositories/#{user}/#{repo.downcase}/raw/#{sha}/#{path}")
35
+ end
36
+ alias :find :get
37
+
38
+ end # Repos::Sources
39
+ end # BitBucket
@@ -0,0 +1,96 @@
1
+ module BitBucket
2
+ class Repos::Webhooks < API
3
+ EVENTS = [
4
+ 'repo:push',
5
+ 'repo:fork',
6
+ 'repo:commit_comment_created',
7
+ 'repo:commit_status_created',
8
+ 'repo:commit_status_updated',
9
+ 'issue:created',
10
+ 'issue:updated',
11
+ 'issue:comment_created',
12
+ 'pullrequest:created',
13
+ 'pullrequest:updated',
14
+ 'pullrequest:approved',
15
+ 'pullrequest:unapproved',
16
+ 'pullrequest:fulfilled',
17
+ 'pullrequest:rejected',
18
+ 'pullrequest:comment_created',
19
+ 'pullrequest:comment_updated',
20
+ 'pullrequest:comment_deleted'
21
+ ]
22
+
23
+ def create(user_name, repo_name, params = {})
24
+ _update_user_repo_params(user_name, repo_name)
25
+ _validate_user_repo_params(user, repo) unless user? && repo?
26
+ normalize! params
27
+ assert_required_keys(%w[description url active events], params)
28
+ _validate_given_events(params)
29
+ assert_required_values_present(
30
+ params,
31
+ 'description',
32
+ 'url',
33
+ 'active',
34
+ 'events'
35
+ )
36
+
37
+ post_request("/2.0/repositories/#{user_name}/#{repo_name}/hooks", params)
38
+ end
39
+
40
+ def list(user_name, repo_name)
41
+ _update_user_repo_params(user_name, repo_name)
42
+ _validate_user_repo_params(user, repo) unless user? && repo?
43
+
44
+ get_request("/2.0/repositories/#{user_name}/#{repo_name}/hooks")
45
+ end
46
+
47
+ def get(user_name, repo_name, hook_uuid)
48
+ _update_user_repo_params(user_name, repo_name)
49
+ _validate_user_repo_params(user, repo) unless user? && repo?
50
+
51
+ get_request(
52
+ "/2.0/repositories/#{user_name}/#{repo_name}/hooks/#{hook_uuid}"
53
+ )
54
+ end
55
+
56
+ def edit(user_name, repo_name, hook_uuid, params = {})
57
+ _update_user_repo_params(user_name, repo_name)
58
+ _validate_user_repo_params(user, repo) unless user? && repo?
59
+ normalize! params
60
+ assert_required_keys(%w[description url active events], params)
61
+ _validate_given_events(params)
62
+ assert_required_values_present(
63
+ params,
64
+ 'description',
65
+ 'url',
66
+ 'active',
67
+ 'events'
68
+ )
69
+
70
+ put_request(
71
+ "/2.0/repositories/#{user_name}/#{repo_name}/hooks/#{hook_uuid}",
72
+ params
73
+ )
74
+ end
75
+
76
+ def delete(user_name, repo_name, hook_uuid)
77
+ _update_user_repo_params(user_name, repo_name)
78
+ _validate_user_repo_params(user, repo) unless user? && repo?
79
+
80
+ delete_request(
81
+ "/2.0/repositories/#{user_name}/#{repo_name}/hooks/#{hook_uuid}"
82
+ )
83
+ end
84
+
85
+ private
86
+ def _validate_given_events(params)
87
+ given_events = params['events']
88
+ raise BitBucket::Error::NoEvents if given_events.empty?
89
+ given_events.each do |k|
90
+ unless EVENTS.include?(k)
91
+ raise BitBucket::Error::BadEvents, k
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ # Defines HTTP verbs
5
+ module Request
6
+
7
+ METHODS = [:get, :post, :put, :delete, :patch]
8
+ METHODS_WITH_BODIES = [ :post, :put, :patch ]
9
+
10
+ def get_request(path, params={}, options={})
11
+ request(:get, path, params, options)
12
+ end
13
+
14
+
15
+ def patch_request(path, params={}, options={})
16
+ request(:patch, path, params, options)
17
+ end
18
+
19
+ def post_request(path, params={}, options={})
20
+ request(:post, path, params, options)
21
+ end
22
+
23
+ def put_request(path, params={}, options={})
24
+ request(:put, path, params, options)
25
+ end
26
+
27
+ def delete_request(path, params={}, options={})
28
+ request(:delete, path, params, options)
29
+ end
30
+
31
+ def request(method, path, params, options={})
32
+ if !METHODS.include?(method)
33
+ raise ArgumentError, "unkown http method: #{method}"
34
+ end
35
+ # _extract_mime_type(params, options)
36
+
37
+ puts "EXECUTED: #{method} - #{path} with #{params} and #{options}" if ENV['DEBUG']
38
+
39
+ conn = connection(options)
40
+ path = (conn.path_prefix + path).gsub(/\/\//,'/') if conn.path_prefix != '/'
41
+
42
+ response = conn.send(method) do |request|
43
+ request['Authorization'] = "Bearer #{new_access_token}" unless new_access_token.nil?
44
+ case method.to_sym
45
+ when *(METHODS - METHODS_WITH_BODIES)
46
+ request.body = params.delete('data') if params.has_key?('data')
47
+ request.url(path, params)
48
+ when *METHODS_WITH_BODIES
49
+ request.path = path
50
+ unless params.empty?
51
+ # data = extract_data_from_params(params)
52
+ # request.body = MultiJson.dump(data)
53
+ request.body = MultiJson.dump(params)
54
+ end
55
+ end
56
+ end
57
+ response.body
58
+ end
59
+
60
+ private
61
+
62
+ # def extract_data_from_params(params) # :nodoc:
63
+ # if params.has_key?('data') and !params['data'].nil?
64
+ # params['data']
65
+ # else
66
+ # params
67
+ # end
68
+ # end
69
+
70
+ def _extract_mime_type(params, options) # :nodoc:
71
+ options['resource'] = params['resource'] ? params.delete('resource') : ''
72
+ options['mime_type'] = params['resource'] ? params.delete('mime_type') : ''
73
+ end
74
+
75
+ end # Request
76
+ end # BitBucket
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+ require 'base64'
5
+
6
+ module BitBucket
7
+ module Request
8
+ class BasicAuth < Faraday::Middleware
9
+ dependency 'base64'
10
+
11
+ def call(env)
12
+ env[:request_headers].merge!('Authorization' => "Basic #{@auth}\"")
13
+
14
+ @app.call env
15
+ end
16
+
17
+ def initialize(app, *args)
18
+ @app = app
19
+ credentials = ""
20
+ options = args.extract_options!
21
+ if options.has_key? :login
22
+ credentials = "#{options[:login]}:#{options[:password]}"
23
+ elsif options.has_key? :basic_auth
24
+ credentials = "#{options[:basic_auth]}"
25
+ end
26
+ @auth = Base64.encode64(credentials)
27
+ @auth.gsub!("\n", "")
28
+ end
29
+ end # BasicAuth
30
+ end # Request
31
+ end # BitBucket
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+
5
+ module BitBucket
6
+ class Request::Jsonize < Faraday::Middleware
7
+
8
+ CONTENT_TYPE = 'Content-Type'.freeze
9
+ MIME_TYPE = 'application/json'.freeze
10
+
11
+ dependency 'multi_json'
12
+
13
+ def call(env)
14
+ if request_with_body?(env)
15
+ env[:request_headers][CONTENT_TYPE] ||= MIME_TYPE
16
+ env[:body] = encode_body env unless env[:body].respond_to?(:to_str)
17
+ end
18
+ @app.call env
19
+ end
20
+
21
+ def encode_body(env)
22
+ if MultiJson.respond_to?(:dump)
23
+ MultiJson.dump env[:body]
24
+ else
25
+ MultiJson.encode env[:body]
26
+ end
27
+ end
28
+
29
+ def request_with_body?(env)
30
+ type = request_type(env)
31
+ has_body?(env) and (type.empty? or type == MIME_TYPE)
32
+ end
33
+
34
+ # Don't encode bodies in string form
35
+ def has_body?(env)
36
+ body = env[:body] and !(body.respond_to?(:to_str) and body.empty?)
37
+ end
38
+
39
+ def request_type(env)
40
+ type = env[:request_headers][CONTENT_TYPE].to_s
41
+ type = type.split(';', 2).first if type.index(';')
42
+ type
43
+ end
44
+
45
+ end # Request::Jsonize
46
+ end # BitBucket
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'faraday'
4
+
5
+ module BitBucket
6
+ module Request
7
+ class OAuth < Faraday::Middleware
8
+ include BitBucket::Utils::Url
9
+
10
+ AUTH_HEADER = 'Authorization'.freeze
11
+
12
+ dependency 'simple_oauth'
13
+
14
+ def call(env)
15
+ # Extract parameters from the query
16
+ request = Rack::Request.new env
17
+ env[:url] = URI.parse(request.url) if env[:url].nil?
18
+ params = { }.update query_params(env[:url])
19
+
20
+ if (@token and @secret) and (!@token.empty? and !@secret.empty?)
21
+ access_token = ::OAuth::AccessToken.new(@consumer, @token, @secret)
22
+ env[:url].query = build_query params
23
+
24
+ puts oauth_helper.header
25
+ puts oauth_helper.header.class
26
+ env[:request_headers].merge!(AUTH_HEADER => oauth_helper.header)
27
+ end
28
+
29
+ env[:url].query = build_query params
30
+
31
+
32
+
33
+ @app.call env
34
+ end
35
+
36
+ def initialize(app, *args)
37
+ super app
38
+ @app = app
39
+ @consumer = args.shift
40
+ @token = args.shift
41
+ @secret = args.shift
42
+ end
43
+
44
+ def query_params(url)
45
+ if url.query.nil? or url.query.empty?
46
+ {}
47
+ else
48
+ parse_query url.query
49
+ end
50
+ end
51
+ end # OAuth
52
+ end # Request
53
+ end # BitBucket