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,54 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::Changesets < API
5
+
6
+ REQUIRED_COMMENT_PARAMS = %w[
7
+ body
8
+ changeset_id
9
+ line
10
+ path
11
+ position
12
+ ].freeze
13
+
14
+ # List changesets on a repository
15
+ #
16
+ # = Parameters
17
+ # * <tt>:limit</tt> Optional integer. An integer representing how many changesets to return. You can specify a limit between 0 and 50.
18
+ # * <tt>:start</tt> Optional string. A hash value representing the earliest node to start with.
19
+ #
20
+ # = Examples
21
+ # bitbucket = BitBucket.new
22
+ # bitbucket.repos.changesets.list 'user-name', 'repo-name', :start => '...'
23
+ # bitbucket.repos.changesets.list 'user-name', 'repo-name', :start => '...' { |changeset| ... }
24
+ #
25
+ def list(user_name, repo_name, params={})
26
+ _update_user_repo_params(user_name, repo_name)
27
+ _validate_user_repo_params(user, repo) unless user? && repo?
28
+ normalize! params
29
+ filter! %w[ limit start], params
30
+
31
+ response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/changesets", params)
32
+ return response unless block_given?
33
+ response.each { |el| yield el }
34
+ end
35
+ alias :all :list
36
+
37
+ # Gets a single changeset
38
+ #
39
+ # = Examples
40
+ # @bitbucket = BitBucket.new
41
+ # @bitbucket.repos.changesets.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
42
+ #
43
+ def get(user_name, repo_name, sha, params={})
44
+ _update_user_repo_params(user_name, repo_name)
45
+ _validate_user_repo_params(user, repo) unless user? && repo?
46
+ _validate_presence_of sha
47
+ normalize! params
48
+
49
+ get_request("/2.0/repositories/#{user}/#{repo.downcase}/changesets/#{sha}", params)
50
+ end
51
+ alias :find :get
52
+
53
+ end # Repos::Commits
54
+ end # BitBucket
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::Commits < API
5
+
6
+ VALID_KEY_PARAM_NAMES = %w(include exclude).freeze
7
+
8
+ # Gets the commit information associated with a repository. By default, this
9
+ # call returns all the commits across all branches, bookmarks, and tags. The
10
+ # newest commit is first.
11
+ #
12
+ # = Parameters
13
+ # *<tt>include</tt> - The SHA, branch, bookmark, or tag to include, for example, v10 or master. You can repeat the parameter multiple times.
14
+ # *<tt>exclude</tt> - The SHA, branch, bookmark, or tag to exclude, for example, v10 or master . You can repeat the parameter multiple times.
15
+ #
16
+ # = Examples
17
+ # bitbucket = BitBucket.new
18
+ # bitbucket.repos.commits.list 'user-name', 'repo-name'
19
+ # bitbucket.repos.commits.list 'user-name', 'repo-name', 'master'
20
+ # bitbucket.repos.commits.list 'user-name', 'repo-name' { |key| ... }
21
+ # bitbucket.repos.commits.list 'user-name', 'repo-name', nil,
22
+ # "include" => "feature-branch",
23
+ # "exclude" => "master"
24
+ #
25
+ def list(user_name, repo_name, branchortag=nil, params={})
26
+ _update_user_repo_params(user_name, repo_name)
27
+ _validate_user_repo_params(user, repo) unless user? && repo?
28
+ normalize! params
29
+ filter! VALID_KEY_PARAM_NAMES, params
30
+
31
+ path = "/2.0/repositories/#{user}/#{repo.downcase}/commits"
32
+ path << "/#{branchortag}" if branchortag
33
+ response = get_request(path, params)
34
+ return response unless block_given?
35
+ response.each { |el| yield el }
36
+ end
37
+ alias :all :list
38
+
39
+ end # Repos::Commits
40
+ end # BitBucket
@@ -0,0 +1,59 @@
1
+ module BitBucket
2
+ class Repos::DefaultReviewers < API
3
+
4
+ # List default reviewers
5
+ #
6
+ # = Examples
7
+ # bitbucket = BitBucket.new
8
+ # bitbucket.repos.default_reviewers.list 'user-name', 'repo-name'
9
+ # bitbucket.repos.default_reviewers.list 'user-name', 'repo-name' { |reviewer| ... }
10
+ #
11
+ def list(user_name, repo_name, params={})
12
+ update_and_validate_user_repo_params(user_name, repo_name)
13
+ normalize! params
14
+
15
+ response = get_request("/2.0/repositories/#{user_name}/#{repo_name}/default-reviewers", params)
16
+ return response unless block_given?
17
+ response.each { |el| yield el }
18
+ end
19
+ alias :all :list
20
+
21
+ # Get a default reviewer's info
22
+ #
23
+ # = Examples
24
+ # bitbucket = BitBucket.new
25
+ # bitbucket.repos.default_reviewers.get 'user-name', 'repo-name', 'reviewer-username'
26
+ #
27
+ def get(user_name, repo_name, reviewer_username, params={})
28
+ update_and_validate_user_repo_params(user_name, repo_name)
29
+ normalize! params
30
+
31
+ get_request("/2.0/repositories/#{user_name}/#{repo_name}/default-reviewers/#{reviewer_username}", params)
32
+ end
33
+
34
+ # Add a user to the default-reviewers list for the repo
35
+ #
36
+ # = Examples
37
+ # bitbucket = BitBucket.new
38
+ # bitbucket.repos.default_reviewers.add 'user-name', 'repo-name', 'reviewer-username'
39
+ #
40
+ def add(user_name, repo_name, reviewer_username, params={})
41
+ update_and_validate_user_repo_params(user_name, repo_name)
42
+ normalize! params
43
+
44
+ put_request("/2.0/repositories/#{user_name}/#{repo_name}/default-reviewers/#{reviewer_username}", params)
45
+ end
46
+
47
+ # Remove a user from the default-reviewers list for the repo
48
+ #
49
+ # = Examples
50
+ # bitbucket = BitBucket.new
51
+ # bitbucket.repos.default_reviewers.remove 'user-name', 'repo-name', 'reviewer-username'
52
+ #
53
+ def remove(user_name, repo_name, reviewer_username, params={})
54
+ update_and_validate_user_repo_params(user_name, repo_name)
55
+ normalize! params
56
+ delete_request("/2.0/repositories/#{user_name}/#{repo_name}/default-reviewers/#{reviewer_username}", params)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::Download < API
5
+ REQUIRED_KEY_PARAM_NAMES = %w[ commit_hash ].freeze
6
+ def get(user_name, repo_name, params={})
7
+ _update_user_repo_params(user_name, repo_name)
8
+ _validate_user_repo_params(user, repo) unless user? && repo?
9
+ # normalize! params
10
+ # assert_required_keys(REQUIRED_KEY_PARAM_NAMES, params)
11
+
12
+ #https://bitbucket.org/jhanley85/eternum_canvas_demo/get/fd931f96f12d.zip
13
+ "https://bitbucket.org/#{user}/#{repo.downcase}/get/#{params[:commit_hash]}.tar.gz"
14
+ end
15
+
16
+
17
+
18
+
19
+
20
+ end # Repos::Keys
21
+ end # BitBucket
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::Following < API
5
+
6
+ # List repo followers
7
+ #
8
+ # = Examples
9
+ # bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo-name'
10
+ # bitbucket.repos.following.followers
11
+ # bitbucket.repos.following.followers { |watcher| ... }
12
+ #
13
+ def followers(user_name, repo_name, params={})
14
+ _update_user_repo_params(user_name, repo_name)
15
+ _validate_user_repo_params(user, repo) unless user? && repo?
16
+ normalize! params
17
+
18
+ response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/followers/", params)
19
+ return response unless block_given?
20
+ response.each { |el| yield el }
21
+ end
22
+
23
+ # List repos being followed by the authenticated user
24
+ #
25
+ # = Examples
26
+ # bitbucket = BitBucket.new :oauth_token => '...', :oauth_secret => '...'
27
+ # bitbucket.repos.following.followed
28
+ #
29
+ def followed(*args)
30
+ params = args.extract_options!
31
+ normalize! params
32
+
33
+ response = get_request("/2.0/user/follows", params)
34
+ return response unless block_given?
35
+ response.each { |el| yield el }
36
+ end
37
+
38
+ end # Repos::Watching
39
+ end # BitBucket
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::Forks < API
5
+
6
+ REQUIRED_KEY_PARAM_NAMES = %w[ name ].freeze
7
+ DEFAULT_REPO_OPTIONS = {
8
+ "website" => "",
9
+ "is_private" => false,
10
+ "has_issues" => false,
11
+ "has_wiki" => false,
12
+ "scm" => "git",
13
+ "no_public_forks" => false
14
+ }.freeze
15
+
16
+ VALID_REPO_OPTIONS = %w[
17
+ owner
18
+ name
19
+ description
20
+ website
21
+ is_private
22
+ has_issues
23
+ has_wiki
24
+ no_public_forks
25
+ language
26
+ scm
27
+ ].freeze
28
+
29
+ # List forks of a repo
30
+ #
31
+ # = Examples
32
+ # bitbucket = BitBucket.new
33
+ # bitbucket.repos.forks.list 'user-name', 'repo-name'
34
+ # bitbucket.repos.forks.list 'user-name', 'repo-name' { |fork| ... }
35
+ #
36
+ def list(user_name, repo_name, params={})
37
+ _update_user_repo_params(user_name, repo_name)
38
+ _validate_user_repo_params(user, repo) unless user? && repo?
39
+ normalize! params
40
+
41
+ response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/forks/", params)
42
+ return response unless block_given?
43
+ response.each { |el| yield el }
44
+ end
45
+ alias :all :list
46
+
47
+ # Create a fork
48
+ #
49
+ # = Inputs
50
+ # * <tt>:type</tt> - One of the supported services. The type is a case-insensitive value.
51
+ #
52
+ # = Examples
53
+ # bitbucket = BitBucket.new
54
+ # bitbucket.repos.forks.create 'user-name', 'repo-name',
55
+ # "name" => "Basecamp",
56
+ #
57
+ def create(user_name, repo_name, params={})
58
+ _update_user_repo_params(user_name, repo_name)
59
+ _validate_user_repo_params(user, repo) unless user? && repo?
60
+ normalize! params
61
+ assert_required_keys(REQUIRED_KEY_PARAM_NAMES, params)
62
+ filter! VALID_REPO_OPTIONS, params
63
+
64
+ post_request("/2.0/repositories/#{user}/#{repo.downcase}/fork", params)
65
+ end
66
+
67
+
68
+ end # Repos::Keys
69
+ end # BitBucket
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::Keys < API
5
+
6
+ VALID_KEY_PARAM_NAMES = %w[ label key ].freeze
7
+
8
+ # List deploy keys
9
+ #
10
+ # = Examples
11
+ # bitbucket = BitBucket.new
12
+ # bitbucket.repos.keys.list 'user-name', 'repo-name'
13
+ # bitbucket.repos.keys.list 'user-name', 'repo-name' { |key| ... }
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}/deploy-keys/", params)
21
+ return response unless block_given?
22
+ response.each { |el| yield el }
23
+ end
24
+ alias :all :list
25
+
26
+ # Create a key
27
+ #
28
+ # = Inputs
29
+ # * <tt>:title</tt> - Required string.
30
+ # * <tt>:key</tt> - Required string.
31
+ #
32
+ # = Examples
33
+ # bitbucket = BitBucket.new
34
+ # bitbucket.repos.keys.create 'user-name', 'repo-name',
35
+ # "label" => "octocat@octomac",
36
+ # "key" => "ssh-rsa AAA..."
37
+ #
38
+ def create(user_name, repo_name, params={})
39
+ _update_user_repo_params(user_name, repo_name)
40
+ _validate_user_repo_params(user, repo) unless user? && repo?
41
+ normalize! params
42
+ filter! VALID_KEY_PARAM_NAMES, params
43
+ assert_required_keys(VALID_KEY_PARAM_NAMES, params)
44
+
45
+ post_request("/2.0/repositories/#{user}/#{repo.downcase}/deploy-keys/", params)
46
+ end
47
+
48
+ # Edit a key
49
+ #
50
+ # = Inputs
51
+ # * <tt>:title</tt> - Required string.
52
+ # * <tt>:key</tt> - Required string.
53
+ #
54
+ # = Examples
55
+ # bitbucket = BitBucket.new
56
+ # bitbucket.repos.keys.edit 'user-name', 'repo-name',
57
+ # "label" => "octocat@octomac",
58
+ # "key" => "ssh-rsa AAA..."
59
+ #
60
+ def edit(user_name, repo_name, key_id, params={})
61
+ _update_user_repo_params(user_name, repo_name)
62
+ _validate_user_repo_params(user, repo) unless user? && repo?
63
+ _validate_presence_of key_id
64
+
65
+ normalize! params
66
+ filter! VALID_KEY_PARAM_NAMES, params
67
+
68
+ put_request("/2.0/repositories/#{user}/#{repo.downcase}/deploy-keys/#{key_id}", params)
69
+ end
70
+
71
+ # Delete key
72
+ #
73
+ # = Examples
74
+ # @bitbucket = BitBucket.new
75
+ # @bitbucket.repos.keys.delete 'user-name', 'repo-name', 'key-id'
76
+ #
77
+ def delete(user_name, repo_name, key_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 key_id
81
+ normalize! params
82
+
83
+ delete_request("/2.0/repositories/#{user}/#{repo.downcase}/deploy-keys/#{key_id}", params)
84
+ end
85
+
86
+ end # Repos::Keys
87
+ end # BitBucket
@@ -0,0 +1,160 @@
1
+ # encoding: utf-8
2
+
3
+ module BitBucket
4
+ class Repos::PullRequest < API
5
+
6
+ # List pull requests
7
+ #
8
+ # = Examples
9
+ # bitbucket = BitBucket.new
10
+ # bitbucket.repos.pull_request.list 'user-name', 'repo-name'
11
+ # bitbucket.repos.pull_request.list 'user-name', 'repo-name' { |status| ... }
12
+ #
13
+ def list(user_name, repo_name, params={})
14
+ _update_user_repo_params(user_name, repo_name)
15
+ _validate_user_repo_params(user, repo) unless user? && repo?
16
+ normalize! params
17
+
18
+ response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/pullrequests", params)
19
+ return response unless block_given?
20
+ response.each { |el| yield el }
21
+ end
22
+ alias :all :list
23
+
24
+ # List pull request participants
25
+ #
26
+ # = Examples
27
+ # bitbucket = BitBucket.new
28
+ # bitbucket.repos.pull_request.list 'user-name', 'repo-name'
29
+ # bitbucket.repos.pull_request.list 'user-name', 'repo-name' { |status| ... }
30
+ #
31
+ def participants(user_name, repo_name, pull_request_id, params={})
32
+ _update_user_repo_params(user_name, repo_name)
33
+ _validate_user_repo_params(user, repo) unless user? && repo?
34
+ normalize! params
35
+
36
+ response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/participants", params)
37
+ return response unless block_given?
38
+ response.each { |el| yield el }
39
+ end
40
+
41
+ def get(user_name, repo_name, pull_request_id, params={})
42
+ _update_user_repo_params(user_name, repo_name)
43
+ _validate_user_repo_params(user, repo) unless user? && repo?
44
+ normalize! params
45
+
46
+ response = request(:get, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}", params)
47
+ return response unless block_given?
48
+ end
49
+
50
+ def create(user_name, repo_name, params={})
51
+ _update_user_repo_params(user_name, repo_name)
52
+ _validate_user_repo_params(user, repo) unless user? && repo?
53
+ normalize! params
54
+
55
+ response = request(:post, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests", params)
56
+ return response unless block_given?
57
+ end
58
+
59
+ def update(user_name, repo_name, pull_request_id, params={})
60
+ _update_user_repo_params(user_name, repo_name)
61
+ _validate_user_repo_params(user, repo) unless user? && repo?
62
+ normalize! params
63
+
64
+ response = request(:put, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}", params)
65
+ return response unless block_given?
66
+ end
67
+
68
+ def commits(user_name, repo_name, pull_request_id, params={})
69
+ _update_user_repo_params(user_name, repo_name)
70
+ _validate_user_repo_params(user, repo) unless user? && repo?
71
+ normalize! params
72
+
73
+ response = request(:get, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/commits", params)
74
+ return response unless block_given?
75
+ end
76
+
77
+ def approve(user_name, repo_name, pull_request_id, params={})
78
+ _update_user_repo_params(user_name, repo_name)
79
+ _validate_user_repo_params(user, repo) unless user? && repo?
80
+ normalize! params
81
+
82
+ response = request(:post, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/approve", params)
83
+ return response unless block_given?
84
+ end
85
+
86
+ def delete_approval(user_name, repo_name, pull_request_id, params={})
87
+ _update_user_repo_params(user_name, repo_name)
88
+ _validate_user_repo_params(user, repo) unless user? && repo?
89
+ normalize! params
90
+
91
+ response = request(:delete, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/approve", params)
92
+ return response unless block_given?
93
+ end
94
+
95
+ def diff(user_name, repo_name, pull_request_id, params={})
96
+ _update_user_repo_params(user_name, repo_name)
97
+ _validate_user_repo_params(user, repo) unless user? && repo?
98
+ normalize! params
99
+
100
+ response = request(:get, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/diff", params)
101
+ return response unless block_given?
102
+ end
103
+
104
+
105
+ def all_activity(user_name, repo_name, params={})
106
+ _update_user_repo_params(user_name, repo_name)
107
+ _validate_user_repo_params(user, repo) unless user? && repo?
108
+ normalize! params
109
+
110
+ response = request(:get, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/activity", params)
111
+ return response unless block_given?
112
+ end
113
+
114
+
115
+ def activity(user_name, repo_name, pull_request_id, params={})
116
+ _update_user_repo_params(user_name, repo_name)
117
+ _validate_user_repo_params(user, repo) unless user? && repo?
118
+ normalize! params
119
+
120
+ response = request(:get, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/activity", params)
121
+ return response unless block_given?
122
+ end
123
+
124
+ def merge(user_name, repo_name, pull_request_id, params={})
125
+ _update_user_repo_params(user_name, repo_name)
126
+ _validate_user_repo_params(user, repo) unless user? && repo?
127
+ normalize! params
128
+
129
+ response = request(:post, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/merge", params)
130
+ return response unless block_given?
131
+ end
132
+
133
+ def decline(user_name, repo_name, pull_request_id, params={})
134
+ _update_user_repo_params(user_name, repo_name)
135
+ _validate_user_repo_params(user, repo) unless user? && repo?
136
+ normalize! params
137
+
138
+ response = request(:post, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/decline", params)
139
+ return response unless block_given?
140
+ end
141
+
142
+ def comments(user_name, repo_name, pull_request_id, params={})
143
+ _update_user_repo_params(user_name, repo_name)
144
+ _validate_user_repo_params(user, repo) unless user? && repo?
145
+ normalize! params
146
+
147
+ response = request(:get, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/comments", params)
148
+ return response unless block_given?
149
+ end
150
+
151
+ def comment(user_name, repo_name, pull_request_id, comment_id, params={})
152
+ _update_user_repo_params(user_name, repo_name)
153
+ _validate_user_repo_params(user, repo) unless user? && repo?
154
+ normalize! params
155
+
156
+ response = request(:get, "/2.0/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/comments/#{comment_id}", params)
157
+ return response unless block_given?
158
+ end
159
+ end # Repos::Keys
160
+ end # BitBucket