class Gitlab::Client # Defines methods related to merge requests. # @see https://docs.gitlab.com/ce/api/merge_requests.html module MergeRequests # Gets a list of project merge requests. # # @example # Gitlab.merge_requests(5) # Gitlab.merge_requests({ per_page: 40 }) # # @param [Integer, String] project The ID or name of a project. # @param [Hash] options A customizable set of options. # @option options [Integer] :page The page number. # @option options [Integer] :per_page The number of results per page. # @return [Array] def merge_requests(project, options={}) get("/projects/#{url_encode project}/merge_requests", query: options) end # Gets a single merge request. # # @example # Gitlab.merge_request(5, 36) # # @param [Integer, String] project The ID or name of a project. # @param [Integer] id The ID of a merge request. # @return ] The merge request's commits. def merge_request_commits(project, id) get("/projects/#{url_encode project}/merge_requests/#{id}/commits") end # List issues that will close on merge # # @example # Gitlab.merge_request_closes_issues(5, 1) # # @param [Integer] project The ID of a project # @param [Integer] iid The internal ID of a merge request def merge_request_closes_issues(project_id, merge_request_iid) get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues") end # Subscribes to a merge request. # # @example # Gitlab.subscribe_to_merge_request(5, 1) # Gitlab.subscribe_to_merge_request('gitlab', 1) # # @param [Integer, String] project The ID or name of a project. # @param [Integer] id The ID of a merge request. # @return [Gitlab::ObjectifiedHash] Information about subscribed merge request. def subscribe_to_merge_request(project, id) post("/projects/#{url_encode project}/merge_requests/#{id}/subscribe") end # Unsubscribes from a merge request. # # @example # Gitlab.unsubscribe_from_merge_request(5, 1) # Gitlab.unsubscribe_from_merge_request('gitlab', 1) # # @param [Integer, String] project The ID or name of a project. # @param [Integer] id The ID of a merge request. # @return [Gitlab::ObjectifiedHash] Information about unsubscribed merge request. def unsubscribe_from_merge_request(project, id) post("/projects/#{url_encode project}/merge_requests/#{id}/unsubscribe") end end end