public Models.Requests GetMergeReadyPullRequests()
        {
            Mapper.CreateMap<Author, Models.Author>();
            Mapper.CreateMap<ChangesetMetadata, Models.ChangesetMetadata>();
            Mapper.CreateMap<Clone, Models.Clone>();
            Mapper.CreateMap<Details, Models.Details>();
            Mapper.CreateMap<FromRef, Models.FromRef>();
            Mapper.CreateMap<Link, Models.Link>();
            Mapper.CreateMap<Links, Models.Links>();
            Mapper.CreateMap<Metadata, Models.Metadata>();
            Mapper.CreateMap<OutGoingPullRequest, Models.OutGoingPullRequest>();
            Mapper.CreateMap<Project, Models.Project>();
            Mapper.CreateMap<PullRequest, Models.PullRequest>();
            Mapper.CreateMap<Contract.Repository, Models.Repository>();
            Mapper.CreateMap<Requests, Models.Requests>();
            Mapper.CreateMap<RequestValues, Models.RequestValues>();
            Mapper.CreateMap<Reviewers, Models.Reviewers>();
            Mapper.CreateMap<Self, Models.Self>();
            Mapper.CreateMap<ToRef, Models.ToRef>();
            Mapper.CreateMap<User, Models.User>();

            var mergeReadyPullRequest = new List<PullRequest>();

            var repositories = GetProjectRepos();

            foreach (var repository in repositories.Values)
            {
                var requestValues = new List<RequestValues>();

                var mergeReadyRequest = new PullRequest();

                mergeReadyRequest.Values = new List<RequestValues>();

                var responseJson = _requestProcessFacade.GetMergeReadyPullRequest(repository.Slug);

                var mergeReadyRequestObj = JsonConvertor.JsonDeserializer<PullRequest>(responseJson);

                requestValues.AddRange(mergeReadyRequestObj.Values.Where(pullRequest => pullRequest.Reviewers.Any(reviewer => reviewer.Approved)));

                foreach (var value in requestValues)
                {
                    value.Link.Url = configurationInstance.UrlDomain + value.Link.Url;
                }

                if (requestValues.Count <= 0) continue;

                mergeReadyRequest.Values = requestValues;

                mergeReadyPullRequest.Add(mergeReadyRequest);
            }

            var requests = new Requests { PullRequests = mergeReadyPullRequest };

            var modelRequests = Mapper.Map<Models.Requests>(requests);

            return modelRequests;
        }
        public Models.Requests GetOpenBranches()
        {
            Mapper.CreateMap<Author, Models.Author>();
            Mapper.CreateMap<ChangesetMetadata, Models.ChangesetMetadata>();
            Mapper.CreateMap<Clone, Models.Clone>();
            Mapper.CreateMap<Details, Models.Details>();
            Mapper.CreateMap<FromRef, Models.FromRef>();
            Mapper.CreateMap<Link, Models.Link>();
            Mapper.CreateMap<Links, Models.Links>();
            Mapper.CreateMap<Metadata, Models.Metadata>();
            Mapper.CreateMap<OutGoingPullRequest, Models.OutGoingPullRequest>();
            Mapper.CreateMap<Project, Models.Project>();
            Mapper.CreateMap<PullRequest, Models.PullRequest>();
            Mapper.CreateMap<Contract.Repository, Models.Repository>();
            Mapper.CreateMap<Requests, Models.Requests>();
            Mapper.CreateMap<RequestValues, Models.RequestValues>();
            Mapper.CreateMap<Reviewers, Models.Reviewers>();
            Mapper.CreateMap<Self, Models.Self>();
            Mapper.CreateMap<ToRef, Models.ToRef>();
            Mapper.CreateMap<User, Models.User>();

            var openBranchPullRequest = new List<PullRequest>();

            var repositories = GetProjectRepos();

            foreach (var repository in repositories.Values)
            {
                var requestValues = new List<RequestValues>();

                var openBranchRequest = new PullRequest();

                var responseJson = _requestProcessFacade.GetOpenBranches(repository.Slug);

                var openBranchRequestObj = JsonConvertor.JsonDeserializer<PullRequest>(responseJson);

                foreach (var openBranch in openBranchRequestObj.Values)
                {
                    object value;
                    if (!openBranch.MetaData.TryGetValue("com.atlassian.stash.stash-ref-metadata-plugin:outgoing-pull-request-metadata", out value) && !openBranch.IsDefault)
                    {
                        openBranch.MetaData.TryGetValue(
                            "com.atlassian.stash.stash-branch-utils:latest-changeset-metadata", out value);

                        if (value != null)
                        {
                            var sourceInfo = JsonConvertor.JsonDeserializer<ChangesetMetadata>(value.ToString());
                            var newopenBranch = BuildBranchResponse(repository.Slug, openBranch, sourceInfo);
                            requestValues.Add(newopenBranch);
                        }

                    }
                }

                openBranchRequest.Values = requestValues;

                openBranchPullRequest.Add(openBranchRequest);
            }

            var requests = new Requests { PullRequests = openBranchPullRequest };

            var modelRequests = Mapper.Map<Models.Requests>(requests);

            return modelRequests;
        }