forked from Gitlink/forgeplus
32 lines
768 B
Ruby
32 lines
768 B
Ruby
class Api::V1::Projects::Pulls::GetService < ApplicationService
|
|
|
|
attr_reader :project, :pull_request, :owner, :repo, :index, :token
|
|
attr_accessor :gitea_data
|
|
|
|
def initialize(project, pull_request, token = nil)
|
|
@project = project
|
|
@pull_request = pull_request
|
|
@owner = project&.owner.login
|
|
@repo = project&.identifier
|
|
@index = pull_request.gitea_number
|
|
@token = token
|
|
end
|
|
|
|
def call
|
|
load_gitea_data
|
|
|
|
gitea_data
|
|
end
|
|
|
|
private
|
|
def request_params
|
|
{
|
|
access_token: token
|
|
}
|
|
end
|
|
|
|
def load_gitea_data
|
|
@gitea_data = $gitea_client.get_repos_pulls_by_owner_repo_index(owner, repo, index, {query: request_params})
|
|
# raise Error, '获取合并请求失败!' unless @gitea_data.is_a?(Hash)
|
|
end
|
|
end |