from gitlabform.gitlab.core import GitLabCore


class GitLabMergeRequests(GitLabCore):

    def create_mr(self, project_and_group_name, source_branch, target_branch, title, description=None):
        pid = self._get_project_id(project_and_group_name)
        data = {
            "id": pid,
            "source_branch": source_branch,
            "target_branch": target_branch,
            "title": title,
            "description": description,
        }
        return self._make_requests_to_api("projects/%s/merge_requests" % pid, method='POST', data=data,
                                          expected_codes=201)

    def accept_mr(self, project_and_group_name, mr_id):  # NOT iid, like API docs suggest!
        pid = self._get_project_id(project_and_group_name)
        return self._make_requests_to_api("projects/%s/merge_request/%s/merge" % (pid, mr_id), method='PUT')

    def update_mr(self, project_and_group_name, mr_id, data):  # NOT iid, like API docs suggest!
        pid = self._get_project_id(project_and_group_name)
        self._make_requests_to_api("projects/%s/merge_request/%s" % (pid, mr_id), method='PUT', data=data)

    def get_mrs(self, project_and_group_name):
        pid = self._get_project_id(project_and_group_name)
        return self._make_requests_to_api("projects/%s/merge_requests" % pid, paginated=True)

    def get_mr(self, project_and_group_name, mr_id):  # NOT iid, like API docs suggest!
        pid = self._get_project_id(project_and_group_name)
        return self._make_requests_to_api("projects/%s/merge_requests/%s" % (pid, mr_id))

@@ -1184,24 +1184,161 @@
 roup_name):%0A
+        %22%22%22%0A        :param project_and_group_name: like 'group/project'%0A        :return: get all *open* MRs in given project%0A        %22%22%22%0A
         pid 
@@ -1445,32 +1445,55 @@
 s/merge_requests
+?scope=all&state=opened
 %22 %25 pid, paginat
@@ -1739,8 +1739,266 @@
 mr_id))%0A
+%0A    def get_mr_approvals(self, project_and_group_name, mr_id):  # NOT iid, like API docs suggest!%0A        pid = self._get_project_id(project_and_group_name)%0A        return self._make_requests_to_api(%22projects/%25s/merge_requests/%25s/approvals%22 %25 (pid, mr_id))%0A

Make getting MRs get MRs for all users and only open, add getting approvals